Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # useradd { $username : ... }
- #
- # Adds a local user to the system, but only if the username is not
- # already present in /etc/passwd.
- #
- # This will always create the user's home directory if it does not
- # exist.
- #
- define useradd($uid,$gid,$home,$shell="/bin/bash",$password="*",$comment="") {
- exec { "useradd-$title":
- path => "/bin:/usr/bin:/sbin:/usr/sbin",
- command => "useradd -u $uid -g $gid -d $home -s $shell -p $password -c $comment -m $title",
- unless => "grep -q '^$title:' /etc/passwd"
- }
- }
- #
- # userdel { $username : }
- #
- # Deletes a local user from the system, but only if the username is
- # present in /etc/passwd.
- #
- # This will delete the account even if the user is currently logged
- # in.
- #
- define userdel {
- exec { "userdel-$title":
- path => "/bin:/usr/bin:/sbin:/usr/sbin",
- command => "userdel -f $title",
- onlyif => "grep -q '^$title:' /etc/passwd"
- }
- }
Add Comment
Please, Sign In to add comment