Puppet Class: sudo::allow
- Defined in:
- manifests/allow.pp
Summary
Creates a file in sudoers.d that permits specific users and groups to sudo.Overview
This class allows you to take complete advantage of automatic parameter lookup using a Hiera database. Providing a singleton class that accepts arrays in the parameters makes it possible to implement specific user or group configuration in Hiera, whereas the use of defined types is normally restricted to Puppet manifests.
Furthermore, having separate parameters for “add” and “replace” modes allows you to take full advantage of inheritance in the Hiera database while still allowing for exceptions if required.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'manifests/allow.pp', line 44
class sudo::allow (
Array $add_users = [],
Array $add_groups = [],
Optional[Array] $replace_users = undef,
Optional[Array] $replace_groups = undef
) {
if $replace_users != undef {
$users = $replace_users
} else {
$users = lookup("${module_name}::allow::add_users", Array, 'unique', $add_users)
}
if $replace_groups != undef {
$groups = $replace_groups
} else {
$groups = lookup("${module_name}::allow::add_groups", Array, 'unique', $add_groups)
}
sudo::conf { 'sudo_users_groups':
content => template("${module_name}/users_groups.erb"),
}
}
|