--- /dev/null
+---
+- name: "Validate the LDAP server to enable replication"
+ hosts: localhost
+ gather_facts: false
+ vars_prompt:
+ - name: ldap_server
+ prompt: "On wich LDAP server should replication be enabled"
+ private: false
+
+ tasks:
+
+ - name: "Setting fact ldapserver_to_enable."
+ ansible.builtin.set_fact:
+ ldapserver_to_enable: "{{ ldap_server }}"
+ cacheable: true
+
+ - name: "Setting status variable found_ldapserver."
+ ansible.builtin.set_fact:
+ found_ldapserver: false
+
+ - name: "Searching for LDAP server '{{ ldapserver_to_enable }}' ..."
+ ansible.builtin.set_fact:
+ found_ldapserver: true
+ when: "item == ldapserver_to_enable"
+ ignore_errors: true
+ with_inventory_hostnames:
+ - ldap_servers
+
+ - name: "Fail for non LDAP server."
+ ansible.builtin.fail:
+ msg: "The given host '{{ ldapserver_to_enable }}' is not a valid LDAP server."
+ when: found_ldapserver == false
+
+- name: "Enabling Replication on a particular LDAP server."
+ hosts: ldap_servers
+ # gather_facts: false
+
+ tasks:
+
+ - name: "Get the LDAP server to enable replication:"
+ ansible.builtin.set_fact:
+ ldapserver_to_enable: "{{ hostvars.localhost.ldapserver_to_enable }}"
+
+ - name: "The LDAP server to enable replication:"
+ debug:
+ var: ldapserver_to_enable
+ verbosity: 0
+
+ - name: "Get timestamp from the system"
+ ansible.builtin.shell: date +%Y-%m-%d_%H-%M-%S
+ register: tstamp
+ check_mode: false
+ changed_when: false
+
+ - name: "Show current timestamp"
+ debug:
+ var: tstamp
+ verbosity: 3
+
+ - name: "Set date variables"
+ set_fact:
+ cur_date: "{{ tstamp.stdout[0:10] | default('2024-11-11') }}"
+ cur_time: "{{ tstamp.stdout[11:] | default('16-33-23') }}"
+ cur_timestamp: "{{ tstamp.stdout[0:10] }}_{{ tstamp.stdout[11:] | default('2024-11-11_16-33-23') }}"
+
+ - name: "Show current date"
+ debug:
+ msg: "Current timestamp: '{{ cur_timestamp }}'."
+ verbosity: 0
+
+# vim: filetype=yaml