Guest User

Untitled

a guest
Jul 9th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #
  2. # useradd { $username : ... }
  3. #
  4. # Adds a local user to the system, but only if the username is not
  5. # already present in /etc/passwd.
  6. #
  7. # This will always create the user's home directory if it does not
  8. # exist.
  9. #
  10.  
  11. define useradd($uid,$gid,$home,$shell="/bin/bash",$password="*",$comment="") {
  12. exec { "useradd-$title":
  13. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  14. command => "useradd -u $uid -g $gid -d $home -s $shell -p $password -c $comment -m $title",
  15. unless => "grep -q '^$title:' /etc/passwd"
  16. }
  17. }
  18.  
  19.  
  20. #
  21. # userdel { $username : }
  22. #
  23. # Deletes a local user from the system, but only if the username is
  24. # present in /etc/passwd.
  25. #
  26. # This will delete the account even if the user is currently logged
  27. # in.
  28. #
  29.  
  30. define userdel {
  31. exec { "userdel-$title":
  32. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  33. command => "userdel -f $title",
  34. onlyif => "grep -q '^$title:' /etc/passwd"
  35. }
  36. }
Add Comment
Please, Sign In to add comment