From ef2758125b4ce15f507f823b88093dc86d3342bd Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 25 Nov 2014 17:46:29 +0100 Subject: [PATCH] icingaweb2_dev: populate openldap --- .../icingaweb2_dev/files/openldap}/db.ldif | 0 .../icingaweb2_dev/files/openldap}/dit.ldif | 0 .../icingaweb2_dev/files/openldap}/users.ldif | 0 .../profiles/icingaweb2_dev/manifests/init.pp | 26 +++++++++++++++++++ 4 files changed, 26 insertions(+) rename .vagrant-puppet/{modules/openldap/files => profiles/icingaweb2_dev/files/openldap}/db.ldif (100%) rename .vagrant-puppet/{modules/openldap/files => profiles/icingaweb2_dev/files/openldap}/dit.ldif (100%) rename .vagrant-puppet/{modules/openldap/files => profiles/icingaweb2_dev/files/openldap}/users.ldif (100%) diff --git a/.vagrant-puppet/modules/openldap/files/db.ldif b/.vagrant-puppet/profiles/icingaweb2_dev/files/openldap/db.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/db.ldif rename to .vagrant-puppet/profiles/icingaweb2_dev/files/openldap/db.ldif diff --git a/.vagrant-puppet/modules/openldap/files/dit.ldif b/.vagrant-puppet/profiles/icingaweb2_dev/files/openldap/dit.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/dit.ldif rename to .vagrant-puppet/profiles/icingaweb2_dev/files/openldap/dit.ldif diff --git a/.vagrant-puppet/modules/openldap/files/users.ldif b/.vagrant-puppet/profiles/icingaweb2_dev/files/openldap/users.ldif similarity index 100% rename from .vagrant-puppet/modules/openldap/files/users.ldif rename to .vagrant-puppet/profiles/icingaweb2_dev/files/openldap/users.ldif diff --git a/.vagrant-puppet/profiles/icingaweb2_dev/manifests/init.pp b/.vagrant-puppet/profiles/icingaweb2_dev/manifests/init.pp index c65568993..1d9435c56 100644 --- a/.vagrant-puppet/profiles/icingaweb2_dev/manifests/init.pp +++ b/.vagrant-puppet/profiles/icingaweb2_dev/manifests/init.pp @@ -4,6 +4,7 @@ class icingaweb2_dev { include icingaweb2 include icingacli include icinga_packages + include openldap class { 'zend_framework': notify => Service['apache'], @@ -94,4 +95,29 @@ class icingaweb2_dev { unless => 'grep -Fxqe "-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables', command => '/sbin/iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT && /sbin/iptables-save > /etc/sysconfig/iptables' } + + define openldap_file { + file { "openldap/${name}.ldif": + path => "/usr/share/openldap-servers/${name}.ldif", + source => "puppet:///modules/icingaweb2_dev/openldap/${name}.ldif", + require => Class['openldap'], + } + } + + openldap_file { [ 'db', 'dit', 'users' ]: } + + exec { 'populate-openldap': + # TODO: Split the command and use unless instead of trying to populate openldap everytime + command => 'sudo ldapadd -c -Y EXTERNAL -H ldapi:/// -f /usr/share/openldap-servers/db.ldif || true && \ + sudo ldapadd -c -D cn=admin,dc=icinga,dc=org -x -w admin -f /usr/share/openldap-servers/dit.ldif || true && \ + sudo ldapadd -c -D cn=admin,dc=icinga,dc=org -x -w admin -f /usr/share/openldap-servers/users.ldif || true', + require => [ + Service['slapd'], + File[[ + 'openldap/db.ldif', + 'openldap/dit.ldif', + 'openldap/users.ldif' + ]] + ], + } }