Defined Type: sudo::user
- Defined in:
- modules/sudo/manifests/user.pp
Overview
SPDX-License-Identifier: Apache-2.0
Define: sudo::user
Manages a sudo specification in /etc/sudoers.d.
Parameters
- privileges
-
Array of sudo privileges.
- user
-
User to which privileges should be assigned. Defaults to the resource title.
Examples
sudo::user { 'nagios_check_raid':
user => 'nagios',
privileges => [
'ALL = NOPASSWD: /usr/local/lib/nagios/plugins/check-raid'
],
}
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'modules/sudo/manifests/user.pp', line 24
define sudo::user(
Array[String] $privileges = [],
$ensure = present,
$user = $title,
) {
require sudo
$title_safe = regsubst($title, '\W', '-', 'G')
$filename = "/etc/sudoers.d/${title_safe}"
if $ensure == 'present' {
file { $filename:
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0440',
content => template('sudo/sudoers.erb'),
validate_cmd => '/usr/sbin/visudo -cqf %',
}
} else {
file { $filename:
ensure => $ensure,
}
}
}
|