torian/puppet-ldap — pull request #16 by Spredzy (2013-07-24 23:24:45+00:00)
Title:  Ability to change ldap server cn=config using ldap tools

This PR gives the ability to the puppet user to change dynamically the cn=config DIT via ldapi. In order to do this several steps have been taken.

* Enable ldapi in EL based installation, it was already the case in Debian based installation. Also I moved the templates/default and templates/sysconfig folder to templates/etc/default and templates/etc/sysconfig respectively since this is how it is on the OS filesystem

* Added in params.pp ($cnconfig_default_attrs) default attributes already present at installation (at least on EL). I created it on each $::osfamily section in case Debian and Suse based installation provide different defaults.

* Added the puppetlabs/stdlib dependency so the is_empty() function can be called in server/master.pp

* Create the actual ldif template and loads it in using ldapmodify and ldapi

Notes :

* Should I also apply this part to server/slave.pp based on your judgement ? (I'd say yes, but I'd like to have confirmation)

```
if (!empty($cnconfig_attrs)) {

package { $ldap::params::package :
ensure => $ensure,
}

$cnconfig_default_attrs = $ldap::params::cnconfig_default_attrs

file {"${ldap::params::prefix}/slapd.d/cn=config-update.ldif" :
ensure => present,
path => "${ldap::params::prefix}/slapd.d/cn=config-update.ldif",
content => template('ldap/etc/openldap/slapd.d/cn=config-update.ldif.erb'),
require => [Service[$ldap::params::service], Package[$ldap::params::package]],
}

exec {"/usr/bin/ldapmodify -Y EXTERNAL -H ldapi:/// -f ${ldap::params::prefix}/slapd.d/cn=config-update.ldif && rm -f ${ldap::params::prefix}/slapd.d/cn=config-update.ldif":
require => [Service[$ldap::params::service], File["${ldap::params::prefix}/slapd.d/cn=config-update.ldif"]]
}

}
```