Ask Your Question
0

hiera interpretation problem

asked 2017-07-06 01:23:32 -0600

bigfoot74 gravatar image

Hello,

I am using hiera variables in puppet with a default value like this:

users        => [hiera('base::linux::monitoring::servicecontact', 'base::linux::motd::contact')]

Can I do the same in hiera? I tried something like this:

mail.notification.users: "%{hiera('base::linux::monitoring::servicecontact','base::linux::motd::contact')}"

But I keep getting a syntax error..

Can someone help me please ?

Cheers,

  • Pascal
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-07-07 10:20:56 -0600

updated 2017-07-07 10:45:20 -0600

DarylW gravatar image

would something like this work:

cat common.yaml 
---
base::linux::monitoring::servicecontact:
  - 'john'
  - 'paul'
  - 'george'
  - 'ringo'
base::linux::motd::contact:
  - 'bjorn'
  - 'benny'
  - 'agnetha'
  - 'anni'
mailnotificationusers: ("%{hiera('base::linux::monitoring::servicecontact')}","%{hiera('base::linux::motd::contact')}")
root@ubuntu:/etc/puppet/code/hiera# hiera mailnotificationusers

("["john", "paul", "george", "ringo"]","["bjorn", "benny", "agnetha", "anni"]")
root@ubuntu:/etc/puppet/code/hiera#
edit flag offensive delete link more

Comments

this produces strings...

Henrik Lindberg gravatar imageHenrik Lindberg ( 2017-07-10 05:04:36 -0600 )edit
0

answered 2017-07-10 05:03:26 -0600

Henrik Lindberg gravatar image

updated 2017-07-10 05:04:13 -0600

With hiera before hiera 5 this is not really doable since you cannot compose a new array using only syntax available in the data files. In hiera 5 you can write your own function and stick it into your hiera.yaml. That function should return the array with the two arrays that it obtains from calls to lookup for base::linux::monitoring::servicecontact and base::linux::motd::contact. It returns this when there is a lookup of the key mail.notification.users for which it returns the constructed array.

The documentation for how to do this is found here.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-07-06 01:23:32 -0600

Seen: 37 times

Last updated: Jul 10