1 | # copyright <sebas @ koumbit.org> |
---|
2 | # copyright <josx @ interorganic.com.ar > |
---|
3 | # Licence: GPL |
---|
4 | |
---|
5 | |
---|
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", |
---|
27 | notify => Exec_ldap_files["/etc/ldap/schema"], |
---|
28 | before => Exec_ldap_files["/etc/ldap/schema"], |
---|
29 | require => Package["slapd", "ldap-utils"]; |
---|
30 | "/var/backups/ldap": |
---|
31 | ensure => directory, |
---|
32 | owner => root, |
---|
33 | group => root, |
---|
34 | mode => 750; |
---|
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, |
---|
47 | group => root; |
---|
48 | } |
---|
49 | |
---|
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 | |
---|
61 | # file { "${archivo}/$name" : ensure => present } |
---|
62 | exec { "ejecuta$name": |
---|
63 | command => "$ldap_add $archivo/$name", |
---|
64 | unless => $unless, |
---|
65 | returns => [0,80], |
---|
66 | notify => Exec["ejecutaConsumerInit"], |
---|
67 | before => [ Exec["ejecutaConsumerInit"] ], |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | exec_ldap_files { "/etc/ldap/schema": |
---|
72 | archivos => [ "cosine.ldif", "inetorgperson.ldif", "rfc2307bis.ldif", "evolutionperson.ldif", "mozillaabpersonalpha.ldif" ], |
---|
73 | } |
---|
74 | |
---|
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", |
---|
80 | unless => "$test -e $slapd_path/cn=config/cn=module{0}.ldif", |
---|
81 | returns => [0,80], |
---|
82 | notify => Exec["ejecutaConsumerSync"], |
---|
83 | before => [ Exec["ejecutaConsumerSync"] ], |
---|
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 | } |
---|
90 | |
---|
91 | } |
---|
92 | |
---|
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": |
---|
127 | content => template("openldap/slapd.conf_slave.erb"), |
---|
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 | } |
---|
142 | |
---|
143 | exec{"slap_conf_update": |
---|
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", |
---|
145 | refreshonly => true, |
---|
146 | subscribe => File["/etc/ldap/slapd.conf"], |
---|
147 | require => [Package[slapd], File["/etc/ldap/slapd.conf"]], |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | file { |
---|
152 | "/etc/ldap/schema": |
---|
153 | ensure => directory, |
---|
154 | mode => 644, |
---|
155 | owner => root, |
---|
156 | group => root, |
---|
157 | source => "puppet:///openldap/etc/ldap/schema/", |
---|
158 | recurse => "true", |
---|
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 | } |
---|