Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define authentication::ldap($server, $binddn, $bindpasswd, $adminuser = "", $adminpass = "", $domain = "", $workgroup = "") {
- class linux {
- $packagelist = ["nss_ldap", "openldap", "authconfig", "samba-common"]
- package { $packagelist:
- ensure => installed,
- }
- #$servers = $server
- file {"/etc/ldap.conf":
- ensure => present,
- owner => root,
- group => root,
- mode => 644,
- content => template("authentication/ldap.conf.erb"),
- }
- @exec {"authconfig-ldap":
- command => "authconfig --useshadow --enablemd5 --enableldap --enableldapauth --ldapserver=$server --ldapbasedn=\"dc=lightningsource,dc=com\" --update",
- unless => "[ -n \"`grep passwd /etc/nsswitch.conf | grep ldap`\" ]",
- notify => File["/etc/ldap.conf"],
- require => Package["authconfig"],
- }
- file {"/etc/samba/smb.conf":
- content => template("puppet://authentication/smb.conf.erb"),
- require => Package["samba-common"],
- }
- exec {"join domain":
- command => "net ads join -U $adminuser%$adminpass",
- unless => "net ads status",
- require => Package["samba-common"],
- }
- }
- class mac {
- exec {"restart com.apple.DirectoryServices":
- command => "launchctl stop com.apple.DirectoryServices && launchctl start com.apple.DirectoryServices",
- refreshonly => true,
- }
- #Set Active Directory plugin to active
- exec {"activate AD plugin":
- command => "defaults write /Library/Preferences/DirectoryService/DirectoryService \"Active Directory\" Active",
- #test if the Active Directory service is set to be active
- unless => "test `defaults read /Library/Preferences/DirectoryService/DirectoryService | grep \"Active Directory\" | awk '{print $4}' | sed 's/;//'` == \"Active\"",
- notify => Exec["restart com.apple.DirectoryServices"],
- notify => Exec["join domain"],
- }
- exec {"join domain":
- refreshonly => true,
- command => "dsconfigad -f -u $adminuser -p $adminpass -domain $domain",
- }
- }
- case $operatingsystem {
- "CentOS": {
- include linux
- Exec <| title == "authconfig-ldap" |>
- }
- "Darwin": {
- include mac
- }
- }
- }
Add Comment
Please, Sign In to add comment