source: trunk/puppet/modules/puppet-openldap/manifests/classes/server-slave.pp @ 657

Last change on this file since 657 was 656, checked in by sebas@…, 15 years ago

debug de la receta slave-ldap

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