Hi, I'm trying to set up Puppet here for the first time and
have run into some problems.
To set up our users, I'm trying to define many users at once as virtual
resources for later realisation in sets. However, I'd like to have it
properly create the home directory:
@user { 'foo':
ensure => "present",
managehome => true,
home => $operatingsystem ? {
solaris => "/export/home/foo",
default => "/home/foo",
},
}
Now, this works; what I want to do is to make the 'foo' bit parameterised, so
that I can do:
$admins = [ 'foo', 'bar' ]
@user { $admins:
ensure => "present",
managehome => true,
home => $operatingsystem ? {
solaris => "/export/home/$name",
default => "/home/$name",
},
}
However this doesn't work; the $name is taken from the class that we're running
this in. Is there any way to do this? I'd use a loop over the
$admins list, except that I cant find any loop structures in the puppet config
language, only if/else.
I've tried using a define to do it:
define users::addVirt() {
@user { $name:
ensure => "present",
managehome => true,
home => $operatingsystem ? {
solaris => "/export/home/$name",
default => "/home/$name",
},
}
}
class users {
$admins = [ 'foo', 'bar' ]
users::addVirt { [ $admins ]: }
}
and this works; however when I later try to realise the users:
class users::admins inherits users {
$admingroup = $operatingsystem ? {
solaris => 'sysadmin',
default => 'unixadmin'
}
User[ $admins ] {
groups +> [ $admingroup ],
}
realize( User[ $admins ] )
}
I end up with:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Only
subclasses can override parameters at /etc/puppet/manifests/classes/users.pp:96
on node secpupprd01.its.auckland.ac.nz
which is complaining about the part:
User[ $admins ] {
groups +> [ $admingroup ],
}
although I cannot see why.
Does anyone have any advice for me on what is going wrong here, or a better way
to achieve this? Thanks in advance for any help...
Steve
Steve Shipway
University of Auckland ITS
UNIX Systems Design Lead
This explains a lot, then. I was thinking of a define as a macro or a function block, whereas in fact it is more like a class (albeit with multiple instances).
A parameterised class isn't going to work.
Maybe I can make users::virt as the define, and then then a subclass users::virt::admins which inherits users and is included by users::admins in order to get around this? I'll try it and see what it says...
Thanks for the help; in a couple of days the Puppet book should arrive here and hopefully fill in the large gaps in the online manual for us.
Steve
Steve Shipway
st...@steveshipway.org
Routers2.cgi web frontend for MRTG/RRD; NagEventLog Nagios agent for Windows Event Log monitoring; check_vmware plugin for VMWare monitoring in Nagios and MRTG; and other Open Source projects.
Web: http://www.steveshipway.org/software
Please consider the environment before printing this e-mail