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="*") {
- exec { "useradd-$title":
- path => "/bin:/usr/bin:/sbin:/usr/sbin",
- command => "luseradd -r -u $uid -g $gid -d $home -s $shell -p '$password' -M $title",
- unless => "grep -q '^$title:' /etc/passwd",
- require => Groupadd["$title"];
- }
- }
- #
- # 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 => "luserdel -f $title",
- onlyif => "grep -q '^$title:' /etc/passwd"
- }
- }
- #
- # groupadd { $groupname : ... }
- #
- # Adds a local group to the system, but only if the groupname is not
- # already present in /etc/group.
- #
- # This will always create the user's home directory if it does not
- # exist.
- #
- define groupadd($gid) {
- exec { "groupadd-$title":
- path => "/bin:/usr/bin:/sbin:/usr/sbin",
- command => "lgroupadd -r -g $gid $title",
- unless => "grep -q '^$title:' /etc/group"
- }
- }
- #
- # groupdel { $groupname : }
- #
- # Deletes a local group from the system, but only if the group is
- # present in /etc/group.
- #
- # This will delete the group even if the user is currently logged
- # in.
- #
- define groupdel {
- exec { "groupdel-$title":
- path => "/bin:/usr/bin:/sbin:/usr/sbin",
- command => "lgroupdel $title",
- onlyif => "grep -q '^$title:' /etc/group"
- }
- }
Add Comment
Please, Sign In to add comment