Now that you have installed saz-sudo module from pupper forge the next thing you should probably do is to
Step 1: create a module that will contain the previlages class.
You'll have to create the privileges module directory, its manifests subdirectory, and an init.pp manifest file that contains the privileges class.
cd /etc/puppetlabs/code/environments/production/modules
mkdir -p privileges/manifests
class privileges {
sudo::conf { 'admins':
ensure => present,
content => '%admin ALL=(ALL) ALL',
}
}
The sudo::conf 'admins' line creates a sudoers rule that ensures that members of the admins group have the ability to run any command using sudo. This resource creates a configuration fragment file to define this rule in /etc/sudoers.d/. It's called something like 10_admins.
Step 2: Next, add the privileges and sudo classes to default nodes.
cd /etc/puppetlabs/code/environments/production/manifests
class { 'sudo': }
sudo::conf { 'web':
content => "web ALL=(ALL) NOPASSWD: ALL",
}
class { 'privileges': }
sudo::conf { 'jargyle':
priority => 60,
content => "jargyle ALL=(ALL) NOPASSWD: ALL",
}
The sudo::conf ‘web’ line creates a sudoers rule to ensure that members of the web group can run any command using sudo. This resource creates a configuration fragment file to define this rule in /etc/sudoers.d/.
The sudo::conf ‘jargyle’ line creates a sudoers rule to ensure that the user jargyle can run any command using sudo. This resource creates a configuration fragment to define this rule in /etc/sudoers.d/. It's called something like 60_jargyle.
puppet parser validate site.pp
Puppet: puppet agent -t
-
That’s it! You have successfully applied sudo and privileges classes to nodes.
-
To confirm it worked, run the following command on an agent:
sudo -l -U jargyle
Matching Defaults entries for jargyle on this host: !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", secure_path=/usr/local/bin\:/sbin\:/bin\:/usr/sbin\:/usr/bin User jargyle may run the following commands on this host: (ALL) NOPASSWD: ALL
For more information on using puppet to manage sudo users you could have a look at: https://puppet.com/blog/module-of-week-saz-sudo-manage-sudo-configuration