]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Asking for the LDAP server for disabling replication, if not given.
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 Nov 2024 13:31:32 +0000 (14:31 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 29 Nov 2024 13:31:32 +0000 (14:31 +0100)
playbooks/disable-ldap-server.yaml

index 1804e52be2f531130cd9fe943eedd3445b191184..1e0a0145f70b14d93bc20bdb58162cf6690e44dd 100644 (file)
@@ -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
 
         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