[655] | 1 | # copyright <sebas @ koumbit.org> |
---|
| 2 | # copyright <josx @ interorganic.com.ar > |
---|
| 3 | # Licence: GPL |
---|
| 4 | |
---|
| 5 | |
---|
[651] | 6 | class openldap::server::slave::dev { |
---|
| 7 | |
---|
| 8 | package { [ |
---|
| 9 | "slapd", |
---|
| 10 | "ldap-utils" |
---|
| 11 | ]: ensure => installed |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | service { "slapd": |
---|
| 15 | ensure => running, |
---|
| 16 | subscribe => [ Package["slapd"] ], |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | file { |
---|
| 20 | "/etc/ldap/schema": |
---|
| 21 | ensure => directory, |
---|
| 22 | mode => 644, |
---|
| 23 | owner => root, |
---|
| 24 | group => root, |
---|
| 25 | source => "puppet:///openldap/etc/ldap/schema/", |
---|
| 26 | recurse => "true", |
---|
[726] | 27 | notify => Exec_ldap_files["/etc/ldap/schema"], |
---|
[656] | 28 | before => Exec_ldap_files["/etc/ldap/schema"], |
---|
[726] | 29 | require => Package["slapd", "ldap-utils"]; |
---|
[651] | 30 | "/var/backups/ldap": |
---|
| 31 | ensure => directory, |
---|
| 32 | owner => root, |
---|
| 33 | group => root, |
---|
[656] | 34 | mode => 750; |
---|
[651] | 35 | } |
---|
| 36 | |
---|
| 37 | file { |
---|
| 38 | "/etc/ldap/consumer-init.ldif": |
---|
| 39 | content => template("openldap/consumer-init.ldif.erb"), |
---|
| 40 | mode => 0600, |
---|
| 41 | owner => root, |
---|
| 42 | group => root; |
---|
| 43 | "/etc/ldap/consumer-sync.ldif": |
---|
| 44 | content => template("openldap/consumer-sync.ldif.erb"), |
---|
| 45 | mode => 0600, |
---|
| 46 | owner => root, |
---|
[656] | 47 | group => root; |
---|
[651] | 48 | } |
---|
[655] | 49 | |
---|
[665] | 50 | |
---|
| 51 | define exec_ldap_files($archivos) { |
---|
| 52 | exec_ldap_file { $archivos: archivo => $name } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | define exec_ldap_file($archivo) { |
---|
| 56 | $test = "/usr/bin/test" |
---|
| 57 | $ldap_add = "/usr/bin/ldapadd -Y EXTERNAL -H ldapi:/// -f" |
---|
| 58 | $slapd_path = "/etc/ldap/slapd.d" |
---|
| 59 | $unless = "$test -e $slapd_path/cn=config/cn=schema/cn={*}$name" |
---|
| 60 | |
---|
[726] | 61 | # file { "${archivo}/$name" : ensure => present } |
---|
[665] | 62 | exec { "ejecuta$name": |
---|
| 63 | command => "$ldap_add $archivo/$name", |
---|
| 64 | unless => $unless, |
---|
| 65 | returns => [0,80], |
---|
[726] | 66 | notify => Exec["ejecutaConsumerInit"], |
---|
| 67 | before => [ Exec["ejecutaConsumerInit"] ], |
---|
[665] | 68 | } |
---|
| 69 | } |
---|
| 70 | |
---|
[656] | 71 | exec_ldap_files { "/etc/ldap/schema": |
---|
[664] | 72 | archivos => [ "cosine.ldif", "inetorgperson.ldif", "rfc2307bis.ldif", "evolutionperson.ldif", "mozillaabpersonalpha.ldif" ], |
---|
[655] | 73 | } |
---|
| 74 | |
---|
[664] | 75 | $test = "/usr/bin/test" |
---|
| 76 | $ldap_add = "/usr/bin/ldapadd -Y EXTERNAL -H ldapi:/// -f" |
---|
| 77 | $slapd_path = "/etc/ldap/slapd.d" |
---|
| 78 | exec { "ejecutaConsumerInit": |
---|
| 79 | command => "$ldap_add /etc/ldap/consumer-init.ldif", |
---|
[726] | 80 | unless => "$test -e $slapd_path/cn=config/cn=module{0}.ldif", |
---|
[664] | 81 | returns => [0,80], |
---|
[726] | 82 | notify => Exec["ejecutaConsumerSync"], |
---|
| 83 | before => [ Exec["ejecutaConsumerSync"] ], |
---|
[664] | 84 | } |
---|
| 85 | exec { "ejecutaConsumerSync": |
---|
| 86 | command => "$ldap_add /etc/ldap/consumer-sync.ldif", |
---|
| 87 | unless => "/bin/grep -q 'olcModuleLoad: {1}syncprov' $slapd_path/cn=config/cn=module{0}.ldif", |
---|
| 88 | returns => [0,80], |
---|
| 89 | } |
---|
[655] | 90 | |
---|
[651] | 91 | } |
---|
| 92 | |
---|
[446] | 93 | class openldap::server::slave { |
---|
| 94 | |
---|
| 95 | debug ("configuring openldap::server::slave with dn '$ldap_base'") |
---|
| 96 | |
---|
| 97 | package {"slapd": |
---|
| 98 | ensure => installed, |
---|
| 99 | responsefile => "/var/cache/debconf/slapd.preseed", |
---|
| 100 | require => File["/var/cache/debconf/slapd.preseed"], |
---|
| 101 | } |
---|
| 102 | # if defined(Package["ldap-utils"]) { } else { |
---|
| 103 | # package {"ldap-utils": ensure => present, } |
---|
| 104 | # } |
---|
| 105 | |
---|
| 106 | service {"slapd": |
---|
| 107 | ensure => running, |
---|
| 108 | require => Package[slapd], |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | # if ($ldap_ssl_only) { |
---|
| 112 | # $line = 'SLAPD_SERVICES="ldaps:///"' |
---|
| 113 | # } else { |
---|
| 114 | $line = 'SLAPD_SERVICES="ldap:/// ldaps:/// ldapi:///"' |
---|
| 115 | # } |
---|
| 116 | line {"listen_locally": |
---|
| 117 | # line => 'SLAPD_SERVICES="ldap:/// ldaps:/// ldapi:///"', |
---|
| 118 | line => $line, |
---|
| 119 | file => "/etc/default/slapd", |
---|
| 120 | ensure => present, |
---|
| 121 | require => Package[slapd], |
---|
| 122 | notify => Service[slapd], |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | file { |
---|
| 126 | "/etc/ldap/slapd.conf": |
---|
[449] | 127 | content => template("openldap/slapd.conf_slave.erb"), |
---|
[446] | 128 | mode => 0600, |
---|
| 129 | owner => root, |
---|
| 130 | group => root; |
---|
| 131 | "/var/cache/debconf/slapd.preseed": |
---|
| 132 | content => template("openldap/slapd.preseed.erb"), |
---|
| 133 | mode => 0600, |
---|
| 134 | owner => root, |
---|
| 135 | group => root; |
---|
| 136 | "/var/backups/ldap": |
---|
| 137 | ensure => directory, |
---|
| 138 | owner => root, |
---|
| 139 | group => root, |
---|
| 140 | mode => 750; |
---|
| 141 | } |
---|
[501] | 142 | |
---|
| 143 | exec{"slap_conf_update": |
---|
[503] | 144 | command => "/etc/init.d/slapd stop && /bin/rm -r /etc/ldap/slapd.d/ && /bin/mkdir /etc/ldap/slapd.d && /usr/sbin/slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d/ && /bin/chown -R openldap:openldap /etc/ldap/slapd.d/ && /bin/chmod -R o-rwx /etc/ldap/slapd.d/ && /etc/init.d/slapd start", |
---|
[501] | 145 | refreshonly => true, |
---|
| 146 | subscribe => File["/etc/ldap/slapd.conf"], |
---|
[502] | 147 | require => [Package[slapd], File["/etc/ldap/slapd.conf"]], |
---|
[501] | 148 | } |
---|
| 149 | |
---|
[446] | 150 | |
---|
| 151 | file { |
---|
| 152 | "/etc/ldap/schema": |
---|
| 153 | ensure => directory, |
---|
[506] | 154 | mode => 644, |
---|
[446] | 155 | owner => root, |
---|
| 156 | group => root, |
---|
[506] | 157 | source => "puppet:///openldap/etc/ldap/schema/", |
---|
| 158 | recurse => "true", |
---|
[446] | 159 | require => Package[slapd]; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | cron {"ldap-backup": |
---|
| 163 | command => "/usr/local/sbin/ldap-backup.sh", |
---|
| 164 | user => "root", |
---|
| 165 | hour => 2, |
---|
| 166 | minute => 0, |
---|
| 167 | require => File["/var/backups/ldap"], |
---|
| 168 | } |
---|
| 169 | } |
---|