diff --git a/sudo/manifests/init.pp b/sudo/manifests/init.pp index 0118199..6b21b1f 100644 --- a/sudo/manifests/init.pp +++ b/sudo/manifests/init.pp @@ -41,8 +41,8 @@ class sudo { # # === Parameters # -# $name: -# User or group. Prefix group name with %. +# $who: +# User or group. Prefix group name with %. Defaults to $name. # $where: # Defaults to ALL. # $as_whom: @@ -50,9 +50,22 @@ class sudo { # $what: # Defaults to ALL. # -define sudo::sudoer($where="ALL", $as_whom="ALL", $what="ALL") { +define sudo::sudoer( + $who=undef, + $where="ALL", + $as_whom="ALL", + $what="ALL" +) { - file { "/etc/sudoers.d/${name}": + if ! $who { + $who_real = $name + } else { + $who_real = $who + } + + $name_real = regsubst($name, '%', '_') + + file { "/etc/sudoers.d/${name_real}": ensure => present, mode => "0440", owner => "root", @@ -60,7 +73,7 @@ define sudo::sudoer($where="ALL", $as_whom="ALL", $what="ALL") { "openbsd" => "wheel", default => "root", }, - content => "${name}\t${where}=(${as_whom})\t${what}\n", + content => "${who_real}\t${where}=(${as_whom})\t${what}\n", require => File["/etc/sudoers"], }