El 12/03/2014 17:19, "Jonathan Proulx" <j...@jonproulx.com> escribió:
>
> see http://docs.puppetlabs.com/hiera/1/puppet.html
>
> "If you need to merge arrays or merge hashes from multiple hierarchy
> levels, you will have to use the hiera_array or hiera_hash functions
> in the body of your classes."
>
> There's not really a good example in that page, but essentially where
> 'hiera' takes the most specific patch hiera_array and heira_hash
> collect all the values across all matching hierarchies (though you
> needn't define the key in every level)
>

+1 it should be something like

common.yaml
users:
  user1:
    ensure: present
    home: /home/user1
    ......

server1.yaml
users:
  user3:
    ensure: present
    home: /home/user3

And then
$users= hiera_hash('users')
users::admin_homedir_define { $users: }

Note: code not tested

Regards

> we use this for packages to install:
>
>   $basepackages = hiera_array('basepackages')
>   ensure_packages($basepackages)
>
> Then in hiera be define (or not) arrays of packages by os version, role,
etc...
>
> -Jon
>
> On Wed, Mar 12, 2014 at 12:11 PM, Kenton Brede <kbr...@gmail.com> wrote:
> > I'm in the process of moving to Puppet 3 and hiera.
> >
> > With my old setup I placed users that were on all servers in basenode.
 Then
> > did a += for any additional users in the node definition.
> >
> > node basenode {
> >   users = ['user1', 'user2']
> > }
> >
> > node server.example.com inherits basenode {
> >   users += ['user3']
> >   # or simple exclude the line, if there were no additional users
> > }
> >
> > With the new setup I've got a common.yaml that contains a hash of users
with
> > access to all boxes.  Then I thought I'd place additional users for
> > "server1" in server1.yaml.
> >
> > common.yaml
> > users_common:
> >   user1:
> >     ensure: present
> >     home: /home/user1
> >     ......
> >
> > server1.yaml
> > server1_users:
> >   user3:
> >     ensure: present
> >     home: /home/user3
> >     ......
> >
> > Then I call like this, which just pulls the usernames from the hash and
> > creates home directories with a file type:
> >
> > class users::ldap {
> >   # regular users
> >   $users_common = hiera('users_common')
> >   $users_common_keys = keys($users_common)
> >   $users_hosts = hiera("${::hostname}_users")
> >   $users_hosts_keys = keys($users_hosts)
> >   $adusers_combined = flatten([ $users_common_keys, $users_hosts_keys ])
> >
> >   # create ldap user home directories
> >   users::admin_homedir_define { $adusers_combined: }
> > }
> >
> > Works great until there are no users for "${::hostname}_users."
> >
> > How can I make this work when "${::hostname}_users" is empty?
> > Thanks,
> >
> > --
> > Kent
> >
> >
> >
> >
> > --
> > 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+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> >
https://groups.google.com/d/msgid/puppet-users/CA%2BnSE3-%3D9zQvajiNMt9e%2BOA64fHrYwPkk4WEwhm0JBPHN598PA%40mail.gmail.com
.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CABZB-sgYSky1BzZ6Vf1OHuYonAhLh-gKV%2BN_RmiQreRyWbVk_w%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAF_B3dcgKzCVPdEBSjEQ5y6cMR0soodHcETwJOhZnSdW4QCrNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to