we can no set a user absent and cleaning everything up

This commit is contained in:
mh 2009-03-07 11:53:21 +00:00
parent 56a602adf7
commit 7aa32b98a3

View file

@ -22,6 +22,7 @@
# if you supply a uid. # if you supply a uid.
# Default: true # Default: true
define user::managed( define user::managed(
$ensure = present,
$name_comment = 'absent', $name_comment = 'absent',
$uid = 'absent', $uid = 'absent',
$gid = 'uid', $gid = 'uid',
@ -56,6 +57,7 @@ define user::managed(
} }
user { $name: user { $name:
ensure => $ensure,
allowdupe => false, allowdupe => false,
comment => "$real_name_comment", comment => "$real_name_comment",
ensure => present, ensure => present,
@ -68,6 +70,16 @@ define user::managed(
if $managehome { if $managehome {
case $ensure {
absent: {
file{"$real_homedir":
ensure => absent,
purge => true,
force => true,
recurese => true,
}
}
default: {
file{"$real_homedir": file{"$real_homedir":
ensure => directory, ensure => directory,
require => User[$name], require => User[$name],
@ -86,6 +98,7 @@ define user::managed(
} }
} }
} }
}
case $uid { case $uid {
'absent': { info("Not defining a uid for user $name") } 'absent': { info("Not defining a uid for user $name") }
@ -129,7 +142,7 @@ define user::managed(
if $manage_group { if $manage_group {
group { $name: group { $name:
allowdupe => false, allowdupe => false,
ensure => present, ensure => $ensure,
} }
if $real_gid { if $real_gid {
Group[$name]{ Group[$name]{
@ -142,6 +155,8 @@ define user::managed(
} }
} }
case $ensure {
present: {
case $sshkey { case $sshkey {
'absent': { info("no sshkey to manage for user $name") } 'absent': { info("no sshkey to manage for user $name") }
default: { default: {
@ -184,10 +199,12 @@ define user::managed(
} }
} }
} }
}
}
# gid: by default it will take the same as the uid # gid: by default it will take the same as the uid
define user::sftp_only( define user::sftp_only(
$ensure = present,
$managehome = false, $managehome = false,
$uid = 'absent', $uid = 'absent',
$gid = 'uid', $gid = 'uid',
@ -197,6 +214,7 @@ define user::sftp_only(
) { ) {
include user::groups::sftponly include user::groups::sftponly
user::managed{"${name}": user::managed{"${name}":
ensure => present,
uid => $uid, uid => $uid,
gid => $gid, gid => $gid,
name_comment => "SFTP-only_user_${name}", name_comment => "SFTP-only_user_${name}",