From ee30f9e1adc7bfd8b98fc7032ccfbdc87e089b65 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Wed, 27 Nov 2013 08:22:51 +0200 Subject: [PATCH] sudo: File name fix for sudoer --- sudo/manifests/init.pp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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"], }