Remove hardcoded commands
Add more modern and convenient way to remove users and directories. Change-Id: I4bc0e7ced93a0c6b3faf7f65e5036ed0cd9bee89 Counter: 2
This commit is contained in:
parent
4fda217d25
commit
94a556de46
@ -6,9 +6,8 @@ define user::virtual::disable(
|
|||||||
) {
|
) {
|
||||||
$username = $title
|
$username = $title
|
||||||
#1. Remove user
|
#1. Remove user
|
||||||
exec { "disable_${username}":
|
user { "${username}":
|
||||||
command => "userdel ${username}",
|
ensure => absent,
|
||||||
onlyif => "grep ^${username}: /etc/passwd",
|
|
||||||
}
|
}
|
||||||
#2. remove sshkeys file(s)
|
#2. remove sshkeys file(s)
|
||||||
file { "rm_authorized_keys_${username}":
|
file { "rm_authorized_keys_${username}":
|
||||||
@ -20,9 +19,12 @@ define user::virtual::disable(
|
|||||||
path => "/home/${username}/.ssh/authorized_keys2",
|
path => "/home/${username}/.ssh/authorized_keys2",
|
||||||
}
|
}
|
||||||
#3. rm screen dir (just in case)
|
#3. rm screen dir (just in case)
|
||||||
exec { "rm_screen_${username}":
|
file { "rm_screen_${username}":
|
||||||
command => "rm -rf /var/run/screen/S-${username}",
|
ensure => absent,
|
||||||
onlyif => "ls /var/run/screen/S-${username}",
|
path => "/var/run/screen/S-${username}",
|
||||||
|
recurse => true,
|
||||||
|
purge => true,
|
||||||
|
force => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user