From 31e815934040da66e4cb6d04339411a883aeb56f Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 29 Nov 2024 14:31:32 +0100 Subject: [PATCH] Asking for the LDAP server for disabling replication, if not given. --- playbooks/disable-ldap-server.yaml | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/playbooks/disable-ldap-server.yaml b/playbooks/disable-ldap-server.yaml index 1804e52..1e0a014 100644 --- a/playbooks/disable-ldap-server.yaml +++ b/playbooks/disable-ldap-server.yaml @@ -2,14 +2,23 @@ - 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 @@ -26,11 +35,21 @@ 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 @@ -41,11 +60,21 @@ 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 -- 2.39.5