In regard to: Re: [Puppet Users] Puppet visudo/ sudoers help, Tony Caffe...:
> I understand but that is not what I asked for help. I would like some help
> on making or writing the code needed to add users to visudo.
$ cat puppet/modules/sudo/manifests/config.pp
define sudo::config($content='', $source='') {
case $content {
'': {
file {"/etc/sudoers.d/${name}":
ensure => file,
owner => 'root',
group => 'root',
mode => '0440',
source => $source,
}
}
default: {
file {"/etc/sudoers.d/${name}":
ensure => file,
owner => 'root',
group => 'root',
mode => '0440',
content => $content,
}
}
}
}
# vim:sm:ts=2:expandtab
Example usage for "source":
sudo::config{ 'networker-jukebox':
source => 'puppet:///networker/networker_jb_sudoers',
}
Example usage for "contents":
sudo::config{ 'myuser':
content => "myuser ALL = (ALL) ALL\n"
}
Note that both RHEL 5.x and 6.x have a sudo that supports the include
mechanism, but only RHEL 6.x ships with an /etc/sudoers.d and an
/etc/sudoers that has the "include /etc/sudoers.d/*" pre-populated.
Since both flavors support it, we just have our sudo init.pp make sure
the directory is present and make certain that the /etc/sudoers has the
necessary "include" statement. From then on, it's just puppet dropping
files into /etc/sudoers.d via the sudo::config() define.
The bad part about our current implementation is that there's no syntax
checking for the contents/source, so a bad entry can sneak in and cause
sudo to completely not work until it's fixed. There are ways around this
but it's more complicated than we felt like getting for now.
If you need to support systems where sudo is old enough that "include"
isn't even an option, then I highly recommend you look at the "concat"
module, and build up your sudoers file from file fragments.
Another option for older sudo versions that don't support including
fragments is using file_line from puppetlabs-stdlib.
Tim
>>> To post to this group, send email to
puppet...@googlegroups.com<javascript:>.
>>
>>> To unsubscribe from this group, send email to
>>
puppet-users...@googlegroups.com <javascript:>.
--
Tim Mooney
Tim.M...@ndsu.edu
Enterprise Computing & Infrastructure
701-231-1076 (Voice)
Room 242-J6, IACC Building
701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164