Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread Kenton Brede
Thanks all!  Hiera is smarter than I knew.  This is great. :)
Kent


On Wed, Mar 12, 2014 at 1:42 PM, José Luis Ledesma <
joseluis.lede...@gmail.com> wrote:

> Try my code, its just what you want.
> El 12/03/2014 19:14, "Kenton Brede"  escribió:
>
>> Thanks for the help all.  Maybe I'm approaching this in the wrong way but
>> the example puts all users on each box.  I'm trying to do something like:
>>
>> users_common = admin1, admin2
>> server1 = users_common + user1
>> server2 = users_common
>> server3 = users_common + user1, user3
>>
>> The goal is to not have to list the admin users in each host.yaml file,
>> but include them.
>>
>> From what I gather hiera doesn't allow:
>>
>> sever1.yaml
>> include users_common
>>
>> server1_users:
>>   user1:
>> ensure: present
>> home: /home/user1
>>
>> Thanks,
>> Kent
>>
>>
>>
>>
>>
>>
>> On Wed, Mar 12, 2014 at 12:38 PM, José Luis Ledesma <
>> joseluis.lede...@gmail.com> wrote:
>>
>>>
>>> El 12/03/2014 17:19, "Jonathan Proulx"  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 
>>> 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-sgYSky1BzZ6Vf1OHuYonAhL

Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread José Luis Ledesma
Try my code, its just what you want.
El 12/03/2014 19:14, "Kenton Brede"  escribió:

> Thanks for the help all.  Maybe I'm approaching this in the wrong way but
> the example puts all users on each box.  I'm trying to do something like:
>
> users_common = admin1, admin2
> server1 = users_common + user1
> server2 = users_common
> server3 = users_common + user1, user3
>
> The goal is to not have to list the admin users in each host.yaml file,
> but include them.
>
> From what I gather hiera doesn't allow:
>
> sever1.yaml
> include users_common
>
> server1_users:
>   user1:
> ensure: present
> home: /home/user1
>
> Thanks,
> Kent
>
>
>
>
>
>
> On Wed, Mar 12, 2014 at 12:38 PM, José Luis Ledesma <
> joseluis.lede...@gmail.com> wrote:
>
>>
>> El 12/03/2014 17:19, "Jonathan Proulx"  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 
>> 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+unsub

Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread Jonathan Proulx
To sort of meta example the pseudo code :)

On Wed, Mar 12, 2014 at 12:11 PM, Kenton Brede  wrote:

> 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
> ..

in stead of using users_common and server1_users just call both 'users':

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

 server1.yaml
 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: }
> }

You can then collect all the users with hiera_hash('users') rather
than fussing with seperate $users_common and $users_hosts

 class users::ldap {
   # regular users
   $users = hiera('users')
   $users_keys = keys($users)

   # create ldap user home directories
   users::admin_homedir_define { $users_keys: }
 }

Note I just copy pasted your code example & substituted syntax didn't
test, seems a bit odd that you're operating on just the keys not the
collected hash but left that as is since I don't knwo what it's
ultimately being fed to.


-Jon

-- 
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-sgk7SFULe_oQ5zLwDaXkMj_-4JTC9yTHzgZzSUcgrvcjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread Kenton Brede
Thanks for the help all.  Maybe I'm approaching this in the wrong way but
the example puts all users on each box.  I'm trying to do something like:

users_common = admin1, admin2
server1 = users_common + user1
server2 = users_common
server3 = users_common + user1, user3

The goal is to not have to list the admin users in each host.yaml file, but
include them.

>From what I gather hiera doesn't allow:

sever1.yaml
include users_common

server1_users:
  user1:
ensure: present
home: /home/user1

Thanks,
Kent






On Wed, Mar 12, 2014 at 12:38 PM, José Luis Ledesma <
joseluis.lede...@gmail.com> wrote:

>
> El 12/03/2014 17:19, "Jonathan Proulx"  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  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

Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread José Luis Ledesma
El 12/03/2014 17:19, "Jonathan Proulx"  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  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.


Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread Jonathan Proulx
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)

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  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.


Re: [Puppet Users] Replicating += with hiera

2014-03-12 Thread Felix Frank
Hi,

On 03/12/2014 05:11 PM, Kenton Brede wrote:
>   $users_hosts = hiera("${::hostname}_users")
> 
> Works great until there are no users for "${::hostname}_users."
> 
> How can I make this work when "${::hostname}_users" is empty?

I don't fully understand you problem, but I believe you want to pass a
default value to your hiera call so that it will work in the absence of
the key. E.g.

$users_hosts = hiera("${::hostname}_users", [])

HTH,
Felix

-- 
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/53208903.8090307%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Replicating += with hiera

2014-03-12 Thread Kenton Brede
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.