I want to do the following
declare variable:
$usernames = [ "chris", "bob", "tim" ]
How would I iterate over it to create something like:
user { "$username":
home => "/home/$username",
}
Also is it possible to create a more complex structure with $UID and
$Shell
I'm thinking of something like this:
$users = [ "chris": {
UID => 800,
Shell => "/usr/bin/bash",
},
"bob": {
UID => 801,
Shell => "/usr/bin/zsh",
}, ]
Then I can reference via
foreach $user $users {
user { "$user":
home => "/home/$user",
UID => $user=>UID,
Shell => $user=>Shell,
}
}
Again this is only pseudocode, but I'm wondering if puppet has this
kind of functionality or if there's another way to do this that
haven't found.
Also I want to iterate over an array of names to create individual
files:
$usernames = [ "bob", "tim" ]
foreach $username $usernames {
file { "/etc/httpd/conf.d/${username}-www.conf
ensure => present,
owner => "root",
group => "root",
mode => "644",
notify => Service["httpd"],
content => $environment ? {
production => template("services/www/prod-www.conf.erb"),
staging => template("services/www/stg-www.conf.erb"),
development => template("services/www/dev-www.conf.erb"),
}
}
With $username in various point in the template.
Are either of these possible? Can anyone suggest a better way?
I know for the file I can iterate with the template and create one
large conf file, but I'd rather keep the conf files separate based on
user.
Thanks
Chris
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.