changed_when: False
register: main_database_rdn
+- set_fact:
+ main_database_name: "{{ main_database_rdn.stdout | regex_replace('olcDatabase=', '', ignorecase=1) }}"
+
- name: "Failing because main database for suffix '{{ lapd_suffix }}' not found."
fail:
msg: "Failed to detect main database for suffix '{{ lapd_suffix }}'."
when: main_database_rdn.rc != 0
- include: 'overlays0-memberof.yaml'
+
- include: 'config_root_account.yaml'
+- include: 'providers.yaml'
+ when: "'providers' in group_names"
+
--- /dev/null
+---
+
+################################################################
+# Acticvating provider overlay
+
+- name: "Detecting, whether the provider overlay is applied on database '{{ item }}'."
+ shell: "ldapsearch -Q -Y EXTERNAL -H ldapi:/// -LLL -s sub -b 'olcDatabase={{ item }},cn=config' -o ldif-wrap=no 'objectClass=olcSyncProvConfig' olcOverlay | grep -i '^olcOverlay:' | sed -e 's/^olcOverlay:[ ]*//i'"
+ changed_when: False
+ ignore_errors: True
+ register: provider_overlay
+
+- name: "Acticvating provider overlay for database '{{ item }}'."
+ block:
+
+ - name: "Initializing LDIF file for adding provider overlay"
+ tempfile:
+ state: 'file'
+ prefix: 'overlay.provider.'
+ suffix: '.ldif'
+ register: provider_overlay_file
+
+ - name: "Get content of adding provider overlay to database '{{ item }}'."
+ template:
+ src: "templates/overlay-provider.ldif.j2"
+ dest: "{{ provider_overlay_file.path }}"
+ owner: root
+ group: root
+ mode: 0644
+
+ - name: "Get file content of adding provider overlay to database '{{ item }}'."
+ shell: "cat '{{ provider_overlay_file.path }}'"
+ register: provider_overlay_file_content
+ changed_when: False
+ no_log: True
+
+ - name: "Show content of file adding provider overlay to database '{{ item }}'."
+ debug: msg={{ provider_overlay_file_content.stdout_lines }}
+
+ - name: "Applying provider overlay to database '{{ item }}'."
+ shell: "ldapadd -Q -Y EXTERNAL -H ldapi:/// -f '{{ provider_overlay_file.path }}'"
+
+ rescue:
+ - name: "Failing base installation of OpenLDAP server because of some errors."
+ fail:
+ msg: "I caught an error"
+
+ always:
+
+ - name: "Removing file fo adding provider overlay to database '{{ item }}' ..."
+ file:
+ path: "{{ provider_overlay_file.path }}"
+ state: absent
+
+ when: provider_overlay.stdout == ''
+