hieradata in add mode

29 views
Skip to first unread message

Albert Shih

unread,
Jan 6, 2016, 10:11:46 PM1/6/16
to puppet...@googlegroups.com
Hi,

I'm asking something maybe stupid but well...

I've got a

hieradata
- common.yaml
- hostname.yaml

I would like to have in common.yaml

users_list :
- user1 user1_ssh_key
- user2 user2_ssh_key
- user3 user3_ssh_key

and in someway I would like to add some users in

hostname.yaml

so something like

users_list"+":
- user4 user4_ssh_key
- user5 user5_ssh_key

The purpose is to add some users for specific host, but always keep some
basic users.

Regards.

JAS

--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
5 Place Jules Janssen
92195 Meudon Cedex
France
Téléphone : +33 1 45 07 76 26/+33 6 86 69 95 71
xmpp: j...@obspm.fr
Heure local/Local time:
mer 6 jan 2016 23:00:37 CET

Johan De Wit

unread,
Jan 7, 2016, 6:35:51 AM1/7/16
to puppet...@googlegroups.com

Hi,


Have a look at https://docs.puppetlabs.com/hiera/latest/lookup_types.html#array-merge


You do have to do explicit hiera calls in your manifests.


Also a litlle remark about your hieradata :  best practice is to put common.yaml as last.  


Grts


Johan


-- 
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20160106220924.GA26535%40pcjas.obspm.fr.
For more options, visit https://groups.google.com/d/optout.

Fraser Goffin

unread,
Jan 8, 2016, 12:24:32 PM1/8/16
to Puppet Users
Personally I try to avoid putting hiera calls in manifests since this can make debugging significantly harder not to mention potentially clouding the intent of that module/class. I prefer exposing the data needs of a module via its API (i.e. class parameters) which also helps to make its intent clear along with providing [controlled] flexibility for the caller. In most cases automatic parameter binding (to hiera) will mean that you can retain the benefits of idempotent include. The one exception I allow is in a 'profile' class (when using the popular 'roles and profiles' pattern) since its job is to coordinate the execution of the modules below satisfying their data needs as required. ... but YMMV

Felix Frank

unread,
Feb 7, 2016, 3:41:02 PM2/7/16
to puppet...@googlegroups.com
Hi,

very valid question.

Traditionally, you will get this behavior not through Hiera notation,
but by using an alternative lookup function, hiera_array.

$users = hiera_array('users_list')

Here's how it works:
http://docs.puppetlabs.com/puppet/latest/reference/function.html#hieraarray

Do note that since Puppet 4.3, you can actually express your desired
lookup mode in the data, which will work when using puppet-lookup. The
latter made it into the release notes:

https://docs.puppetlabs.com/puppet/4.3/reference/release_notes.html#new-feature-puppet-lookup

Not sure whether the deep merge functionality is already documented
well, so I'll just refer you to the Jira issue. Please look at the
latest comments to find out what the final design ended up being.

https://tickets.puppetlabs.com/browse/PUP-5395

If this is helpful to you, please share your findings and final design
with the list.

Thanks!
Felix
Reply all
Reply to author
Forward
0 new messages