Guest User

Untitled

a guest
Jul 20th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1.  
  2. #
  3. # useradd { $username : ... }
  4. #
  5. # Adds a local user to the system, but only if the username is not
  6. # already present in /etc/passwd.
  7. #
  8. # This will always create the user's home directory if it does not
  9. # exist.
  10. #
  11.  
  12. define useradd($uid,$gid,$home,$shell="/bin/bash",$password="*") {
  13. exec { "useradd-$title":
  14. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  15. command => "luseradd -r -u $uid -g $gid -d $home -s $shell -p '$password' -M $title",
  16. unless => "grep -q '^$title:' /etc/passwd",
  17. require => Groupadd["$title"];
  18. }
  19. }
  20.  
  21.  
  22. #
  23. # userdel { $username : }
  24. #
  25. # Deletes a local user from the system, but only if the username is
  26. # present in /etc/passwd.
  27. #
  28. # This will delete the account even if the user is currently logged
  29. # in.
  30. #
  31.  
  32. define userdel {
  33. exec { "userdel-$title":
  34. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  35. command => "luserdel -f $title",
  36. onlyif => "grep -q '^$title:' /etc/passwd"
  37. }
  38. }
  39.  
  40.  
  41.  
  42. #
  43. # groupadd { $groupname : ... }
  44. #
  45. # Adds a local group to the system, but only if the groupname is not
  46. # already present in /etc/group.
  47. #
  48. # This will always create the user's home directory if it does not
  49. # exist.
  50. #
  51.  
  52. define groupadd($gid) {
  53. exec { "groupadd-$title":
  54. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  55. command => "lgroupadd -r -g $gid $title",
  56. unless => "grep -q '^$title:' /etc/group"
  57. }
  58. }
  59.  
  60.  
  61. #
  62. # groupdel { $groupname : }
  63. #
  64. # Deletes a local group from the system, but only if the group is
  65. # present in /etc/group.
  66. #
  67. # This will delete the group even if the user is currently logged
  68. # in.
  69. #
  70.  
  71. define groupdel {
  72. exec { "groupdel-$title":
  73. path => "/bin:/usr/bin:/sbin:/usr/sbin",
  74. command => "lgroupdel $title",
  75. onlyif => "grep -q '^$title:' /etc/group"
  76. }
  77. }
Add Comment
Please, Sign In to add comment