- set_fact:
db_dn: "olcDatabase={{ database_name }},cn=config"
-# - name: "Acticvating SyncRepl consumers for database '{{ database_name }}' for providers ..."
-# include_tasks: "consumers_per_provider.yaml"
-# loop: "{{ groups['providers'] }}"
-# loop_control:
-# loop_var: provider_host
-
- name: "Get state of possibly applied SyncRepl consumers for database '{{ database_name }}'."
shell: "ldapsearch -Q -Y EXTERNAL -H ldapi:/// -LLL -s base -b '{{ db_dn }}' -o ldif-wrap olcSyncrepl | grep -i '^olcSyncrepl'"
changed_when: False
+++ /dev/null
----
-
-- name: "Acticvating SyncRepl consumers for database '{{ database_name }}' and provider {{ provider_host }} ..."
- block:
-
- - set_fact:
- rid: "{{ hostvars[provider_host].rid_token }}{{ rid_token }}{{ db_id_token }}"
-
- - set_fact:
- provider_uri: "ldaps://{{ hostvars[provider_host].ansible_fqdn }}"
-
- - name: "Get state of an possibly applied SyncRepl consumers for database '{{ database_name }}' and provider {{ provider_host }} ..."
- shell: "ldapsearch -Q -Y EXTERNAL -H ldapi:/// -LLL -s base -b '{{ db_dn }}' -o ldif-wrap olcSyncrepl | grep -i '^olcSyncrepl'| sed -e 's/^olcSyncrepl:[ ]*//i' | grep -i 'provider={{ provider_uri }}'"
- changed_when: False
- ignore_errors: True
- no_log: True
- register: get_syncrepl_entry
-
- - name: "Applying SyncRepl consumers for database '{{ database_name }}' and provider {{ provider_host }} ..."
- block:
-
- - name: "Initializing LDIF file for applying SyncRepl consumers"
- tempfile:
- state: 'file'
- prefix: 'syncrepl.'
- suffix: '.ldif'
- register: syncrepl_file
-
- - name: "Get content of applying SyncRepl consumers"
- template:
- src: "templates/syncrepl-add.ldif.j2"
- dest: "{{ syncrepl_file.path }}"
- owner: root
- group: root
- mode: 0644
-
- - name: "Get content of applying SyncRepl consumers file"
- shell: "cat '{{ syncrepl_file.path }}'"
- register: content_syncrepl_file
- changed_when: False
- no_log: True
-
- - name: "Show content of applying SyncRepl consumers file."
- debug: msg={{ content_syncrepl_file.stdout_lines }}
-
- - name: "Applying SyncRepl consumers file at the end ..."
- shell: "ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f '{{ syncrepl_file.path }}'"
-
- rescue:
- - name: "Failing base installation of OpenLDAP server because of some errors."
- fail:
- msg: "I caught an error"
-
- always:
-
- - name: "Removing applying SyncRepl consumers file ..."
- file:
- path: "{{ syncrepl_file.path }}"
- state: absent
-
- when: get_syncrepl_entry.rc != 0
-
- when: provider_host != ansible_fqdn
-