msg: "The given host {{ ldapserver_to_enable | quote }} is not a valid LDAP server."
when: found_ldapserver == false
+ - ansible.builtin.set_fact:
+ possible_source_hosts: []
+ source_host_for_init: ~
+
+ - name: 'Actions, if ldapserver_to_enable was set.'
+ when: ldapserver_to_enable is not empty
+ block:
+
+ - ansible.builtin.set_fact:
+ possible_source_hosts: "{{ possible_source_hosts + [item] }}"
+ when: "item != ldapserver_to_enable"
+ ignore_errors: true
+ with_inventory_hostnames:
+ - ldap_servers
+
+ - ansible.builtin.set_fact:
+ source_host_for_init: "{{ possible_source_hosts | ansible.builtin.random }}"
+
- name: "Initial checks for the HAProxy."
hosts: haproxy_servers
gather_facts: false
ansible.builtin.set_fact:
ldapserver_to_enable: "{{ hostvars.localhost.ldapserver_to_enable }}"
+ - ansible.builtin.set_fact:
+ source_host_for_init: ~
+
+ - name: "Get the source LDAP server to init replication."
+ ansible.builtin.set_fact:
+ source_host_for_init: "{{ hostvars.localhost.source_host_for_init }}"
+ when: hostvars.localhost.source_host_for_init is not empty
+
- name: "The LDAP server to enable replication:"
debug:
var: ldapserver_to_enable
include_role:
name: '389ds-ensure-repl-agmt'
+ - name: "Source host for init replication:"
+ debug:
+ var: source_host_for_init
+ verbosity: 2
+
+ - name: 'Init of the replica.'
+ include_role:
+ name: '389ds-init-replication'
+ when: ldapserver_to_enable is not empty and inventory_hostname == source_host_for_init
+ vars:
+ target_host: "{{ ldapserver_to_enable }}"
+
# vim: filetype=yaml
--- /dev/null
+---
+
+# Performing an initial sending of replica from source host (inventory_host) to a target host on all suffixes.
+
+- debug:
+ msg: "Do an initial sending of replica from source host ({{ inventory_hostname }}) to the target host {{ target_host | quote }} on all suffixes."
+
+- name: "Retrieve all backends."
+ ansible.builtin.shell: "dsconf {{ slapd_instance | quote }} backend suffix list"
+ register: get_backend_suffix_list
+ changed_when: false
+ check_mode: false
+
+- name: "Show current get_backend_suffix_list"
+ debug:
+ var: get_backend_suffix_list
+ verbosity: 2
+
+- name: "Set backend variable"
+ no_log: true
+ set_fact:
+ suffix_names: "{{ get_backend_suffix_list.stdout_lines | map('regex_replace', '\\s+\\(.+\\)\\s*$', '') | list }}"
+ backend_names: "{{ get_backend_suffix_list.stdout_lines | map('regex_replace', '^.*\\((.+)\\)\\s*$', '\\1') | list }}"
+
+- name: "Set suffixes dict"
+ no_log: true
+ set_fact:
+ suffixes: "{{ dict( suffix_names | zip(backend_names) ) }}"
+
+- name: "Show current suffixes"
+ debug:
+ var: suffixes
+ verbosity: 0
+
+- name: "Perform init of a replication agreement on all suffixes."
+ include_tasks: suffix.yaml
+ vars:
+ backend_name: "{{ backend.name }}"
+ suffix: "{{ backend.suffix }}"
+ loop: "{{ suffixes | dict2items(key_name='suffix', value_name='name') }}"
+ loop_control:
+ loop_var: backend
+
+# vim: filetype=yaml
--- /dev/null
+---
+
+- debug:
+ msg: "start init of replication agreement from {{ inventory_hostname | quote }} \
+ to {{ target_host | quote }} for suffix {{ suffix | quote }}."
+ verbosity: 0
+
+- name: "Set fact agreement_name."
+ set_fact:
+ agreement_name: "{{ slapd_instance }} to {{ target_host }} agreement"
+
+- name: "Show replication agreement name for suffix {{ suffix | quote }}."
+ debug:
+ var: agreement_name
+ verbosity: 0
+
+
+# vim: filetype=yaml