From ac00daa6538e86cb852ba7ed97d123a61b0050a1 Mon Sep 17 00:00:00 2001 From: Aaron Greengrass Date: Thu, 23 Jan 2014 11:50:13 -0800 Subject: [PATCH] Extend user module, add 'disable user' This patch adds the user::virtual::disable function to the user module. This will allow puppet to remove a user, ssh keys, and screen sessions while preserving the user home directory. This patch adds future functionality without impacting the currently configured infrastructure. Change-Id: I2933e6857094398f86c2a7e6eaabe9898a1d3078 --- manifests/virtual/disable.pp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 manifests/virtual/disable.pp diff --git a/manifests/virtual/disable.pp b/manifests/virtual/disable.pp new file mode 100644 index 0000000..e7aef18 --- /dev/null +++ b/manifests/virtual/disable.pp @@ -0,0 +1,28 @@ +# used to remove a user +# example: +# user::virtual::disable { 'baduser': } + +define user::virtual::disable( +) { + $username = $title + #1. Remove user + exec { "disable_${username}": + command => "userdel ${username}", + onlyif => "grep ^${username}: /etc/passwd", + } + #2. remove sshkeys file(s) + file { "rm_authorized_keys_${username}": + ensure => absent, + path => "/home/${username}/.ssh/authorized_keys", + } + file { "rm_authorized_keys2_${username}": + ensure => absent, + path => "/home/${username}/.ssh/authorized_keys2", + } + #3. rm screen dir (just in case) + exec { "rm_screen_${username}": + command => "rm -rf /var/run/screen/S-${username}", + onlyif => "ls /var/run/screen/S-${username}", + } +} +