- name: "Show content of managing RootDN for config database file."
debug: msg={{ content_rootdn_config_file.stdout_lines }}
- - name: "Applying managing RootDN for config database file."
+ - name: "Applying managing RootDN for config database file."
shell: "ldapadd -Q -Y EXTERNAL -H ldapi:/// -f '{{ rootdn_config_file.path }}'"
rescue:
--- /dev/null
+---
+
+################################################################
+# Setting example databae to readonly
+
+
+- name: "Detecting the readonly state of the example database."
+ shell: "ldapsearch -Q -Y EXTERNAL -H ldapi:/// -LLL -s base -b '{{ example_database.dn }}' -o ldif-wrap=no olcReadonly | grep -i '^olcReadonly:' | sed -e 's/^olcReadonly:[ ]*//i' | tr '[:upper:]' '[:lower:]'"
+ changed_when: False
+ ignore_errors: True
+ no_log: True
+ register: example_database_ro
+
+- name: "Setting readonly state of example database to readonly."
+ block:
+
+ - name: "Initializing LDIF file for setting readonly state."
+ tempfile:
+ state: 'file'
+ prefix: 'set-example-db-ro.'
+ suffix: '.ldif'
+ register: set_ro_file
+
+ - set_fact:
+ changetype: 'add'
+ when: example_database_ro.rc != 0
+
+ - set_fact:
+ changetype: 'replace'
+ when: example_database_ro.rc == 0
+
+ - name: "Get content of setting database to readonly"
+ template:
+ src: "templates/set-ro-example-db.ldif.j2"
+ dest: "{{ set_ro_file.path }}"
+ owner: root
+ group: root
+ mode: 0644
+
+ - name: "Get content of setting database to readonly file"
+ shell: "cat '{{ set_ro_file.path }}'"
+ register: content_set_ro_file
+ changed_when: False
+ no_log: True
+
+ - name: "Show content of setting database to readonly file."
+ debug: msg={{ content_set_ro_file.stdout_lines }}
+
+ - name: "Applying setting database to readonly file."
+ shell: "ldapadd -Q -Y EXTERNAL -H ldapi:/// -f '{{ set_ro_file.path }}'"
+
+ rescue:
+ - name: "Failing base installation of OpenLDAP server because of some errors."
+ fail:
+ msg: "I caught an error"
+
+ always:
+
+ - name: "Removing setting database to readonly file ..."
+ file:
+ path: "{{ set_ro_file.path }}"
+ state: absent
+
+ when: (example_database_ro.rc != 0) or (example_database_ro.stdout != 'true')
+
+