- name: "Validate the LDAP server to take off replication"
hosts: localhost
gather_facts: false
+ vars_prompt:
+ - name: ldap_server
+ prompt: "On wich LDAP server should replication be disabled"
+ private: false
tasks:
- - name: Print a message
+ - name: "Setting fact ldapserver_to_disable."
+ ansible.builtin.set_fact:
+ ldapserver_to_disable: "{{ ldap_server }}"
+ cacheable: true
+
+ - name: "Print a message"
ansible.builtin.debug:
msg: "Replication should be disabled on the server '{{ ldapserver_to_disable }}'."
- - name: Setting status variable
+ - name: "Setting status variable"
ansible.builtin.set_fact:
found_ldapserver: false
msg: "The given host '{{ ldapserver_to_disable }}' is not a valid LDAP server."
when: found_ldapserver == false
-- name: "Disable host '{{ ldapserver_to_disable }}' as a HAProxy backend server."
+- name: "Disable the given host as a HAProxy backend server."
hosts: haproxy_servers
tasks:
+ - name: "Get the LDAP server to disable replication:"
+ ansible.builtin.set_fact:
+ ldapserver_to_disable: "{{ hostvars.localhost.ldapserver_to_disable }}"
+ cacheable: true
+
+ - name: "The LDAP server to disable replication:"
+ debug:
+ var: ldapserver_to_disable
+ verbosity: 0
+
- name: "Setting backend server {{ haproxy_backend_name }}/{{ ldapserver_to_disable }} into maintenance."
community.general.haproxy:
state: drain
wait_interval: 2
wait_retries: 60
-- name: "Disabling Replication to '{{ ldapserver_to_disable }}'."
+- name: "Disabling Replication on the given host."
hosts: ldap_servers
tasks:
+ - name: "Get the LDAP server to disable replication:"
+ ansible.builtin.set_fact:
+ ldapserver_to_disable: "{{ hostvars.localhost.ldapserver_to_disable }}"
+ cacheable: true
+
+ - name: "The LDAP server to disable replication:"
+ debug:
+ var: ldapserver_to_disable
+ verbosity: 0
+
- name: Get timestamp from the system
ansible.builtin.shell: date +%Y-%m-%d_%H-%M-%S
register: tstamp