From 3ad4b14c2d655c34a31a48a5c0e7b1dce06b2c42 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 22 Mar 2011 22:40:03 -0300 Subject: Avoiding deletion of user's primary group before deleting the user when ensure is absent --- manifests/init.pp | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'manifests/init.pp') diff --git a/manifests/init.pp b/manifests/init.pp index 17501ed..50704f2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -139,24 +139,41 @@ class apache { } if $mpm == true and $manage_user == true and $user != 'root' { - if !defined(Group[$gid]) { - group { "$gid": - ensure => $ensure, + if $ensure == present { + if !defined(Group[$gid]) { + group { "$gid": + ensure => present, + } + } + + if !defined(User["$user"]) { + user::manage { "$user": + tag => "virtual", + password => $password, + gid => $gid, + comment => $comment, + ticket => $ticket, + groups => $groups, + sshkey => $sshkey, + shell => $shell, + ensure => present, + require => Group[$gid], + } } } - - if !defined(User["$user"]) { - user::manage { "$user": - tag => "virtual", - password => $password, - gid => $gid, - comment => $comment, - ticket => $ticket, - groups => $groups, - sshkey => $sshkey, - shell => $shell, - ensure => $ensure, - require => Group[$gid], + else { + if !defined(Group[$gid]) { + group { "$gid": + ensure => absent, + require => User[$user], + } + } + + if !defined(User["$user"]) { + user::manage { "$user": + tag => "virtual", + ensure => absent, + } } } } -- cgit v1.2.3