To sort of meta example the pseudo code :)
On Wed, Mar 12, 2014 at 12:11 PM, Kenton Brede <[email protected]> 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 [email protected].
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.