Guest User

Untitled

a guest
May 9th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. define authentication::ldap($server, $binddn, $bindpasswd, $adminuser = "", $adminpass = "", $domain = "", $workgroup = "") {
  2.  
  3. class linux {
  4. $packagelist = ["nss_ldap", "openldap", "authconfig", "samba-common"]
  5.  
  6. package { $packagelist:
  7. ensure => installed,
  8. }
  9.  
  10. #$servers = $server
  11.  
  12. file {"/etc/ldap.conf":
  13. ensure => present,
  14. owner => root,
  15. group => root,
  16. mode => 644,
  17. content => template("authentication/ldap.conf.erb"),
  18. }
  19.  
  20. @exec {"authconfig-ldap":
  21. command => "authconfig --useshadow --enablemd5 --enableldap --enableldapauth --ldapserver=$server --ldapbasedn=\"dc=lightningsource,dc=com\" --update",
  22. unless => "[ -n \"`grep passwd /etc/nsswitch.conf | grep ldap`\" ]",
  23. notify => File["/etc/ldap.conf"],
  24. require => Package["authconfig"],
  25. }
  26.  
  27. file {"/etc/samba/smb.conf":
  28. content => template("puppet://authentication/smb.conf.erb"),
  29. require => Package["samba-common"],
  30. }
  31.  
  32. exec {"join domain":
  33. command => "net ads join -U $adminuser%$adminpass",
  34. unless => "net ads status",
  35. require => Package["samba-common"],
  36. }
  37. }
  38.  
  39. class mac {
  40. exec {"restart com.apple.DirectoryServices":
  41. command => "launchctl stop com.apple.DirectoryServices && launchctl start com.apple.DirectoryServices",
  42. refreshonly => true,
  43. }
  44.  
  45. #Set Active Directory plugin to active
  46. exec {"activate AD plugin":
  47. command => "defaults write /Library/Preferences/DirectoryService/DirectoryService \"Active Directory\" Active",
  48. #test if the Active Directory service is set to be active
  49. unless => "test `defaults read /Library/Preferences/DirectoryService/DirectoryService | grep \"Active Directory\" | awk '{print $4}' | sed 's/;//'` == \"Active\"",
  50. notify => Exec["restart com.apple.DirectoryServices"],
  51. notify => Exec["join domain"],
  52. }
  53.  
  54. exec {"join domain":
  55. refreshonly => true,
  56. command => "dsconfigad -f -u $adminuser -p $adminpass -domain $domain",
  57. }
  58. }
  59.  
  60. case $operatingsystem {
  61. "CentOS": {
  62. include linux
  63.  
  64. Exec <| title == "authconfig-ldap" |>
  65. }
  66.  
  67. "Darwin": {
  68. include mac
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment