]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding includes/del-389ds-backend-repl-agmts.yaml and removing replication agreements...
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 12 Nov 2024 13:05:14 +0000 (14:05 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 12 Nov 2024 13:05:14 +0000 (14:05 +0100)
includes/del-389ds-backend-repl-agmts.yaml [new file with mode: 0644]
includes/set-389ds-backend-readonly.yaml
playbooks/disable-ldap-server.yaml

diff --git a/includes/del-389ds-backend-repl-agmts.yaml b/includes/del-389ds-backend-repl-agmts.yaml
new file mode 100644 (file)
index 0000000..7d167f4
--- /dev/null
@@ -0,0 +1,42 @@
+---
+
+- name: "Removing replication agreements on {{ ansible_nodename }}."
+  when: ldapserver_to_disable != ansible_nodename
+  block:
+
+    - name: "Removing replication agreements to {{ target }}."
+      when: ldapserver_to_disable == target
+      block:
+
+        - name: "Set fact agreement_name."
+          set_fact:
+            agreement_name: "{{ slapd_instance }} to {{ target }} agreement"
+
+        - name: "Show replication agreement name for suffix '{{ suffix }}'."
+          debug:
+            var: agreement_name
+            verbosity: 0
+
+        - name: "Removing replication agreement '{{ agreement_name }}' for suffix '{{ suffix }}'."
+          ansible.builtin.shell: "dsconf '{{ slapd_instance }}' repl-agmt delete --suffix '{{ suffix }}' '{{ agreement_name }}'"
+          ignore_errors: true
+
+- name: "Removing replication agreements on {{ ldapserver_to_disable }}."
+  when: ldapserver_to_disable == ansible_nodename
+  block:
+
+    - name: "Set fact agreement_name."
+      set_fact:
+        agreement_name: "{{ slapd_instance }} to {{ target }} agreement"
+
+    - name: "Show replication agreement name for suffix '{{ suffix }}'."
+      debug:
+        var: agreement_name
+        verbosity: 0
+
+    - name: "Removing replication agreement '{{ agreement_name }}' for suffix '{{ suffix }}'."
+      ansible.builtin.shell: "dsconf '{{ slapd_instance }}' repl-agmt delete --suffix '{{ suffix }}' '{{ agreement_name }}'"
+      ignore_errors: true
+
+
+# vim: filetype=yaml
index ef4d4baf67aa599a446dedd2e518a06f39f88f90..8fab773e9e37d06130a477c3b26406c434153d78 100644 (file)
@@ -1,13 +1,9 @@
 ---
 
-# - name: "Set fact backend_name."
-#   # no_log: true
-#   set_fact:
-#     backend_name: "{{ lookup('vars', ansible_loop_var) }}.value"
-
 - name: "Get current Readonly status of Backend '{{ backend.value }}' ..."
   ansible.builtin.shell: "dsconf '{{ slapd_instance }}' backend suffix get '{{ backend.value }}' | grep -i '^nsslapd-readonly:' | sed -e 's/^nsslapd-readonly:[        ]*//i'"
   check_mode: false
+  changed_when: false
   register: backend_get_ro_status
 
 - name: "Show current backend_get_ro_status"
index 3af53ffcf4d13d08663ca12f64990426c939b1db..62ab319d675219b67c53871d9e02b171790051b1 100644 (file)
@@ -50,6 +50,7 @@
       ansible.builtin.shell: date +%Y-%m-%d_%H-%M-%S
       register: tstamp
       check_mode: false
+      changed_when: false
       when: ldapserver_to_disable == ansible_nodename
 
     - name: "Show current timestamp"
     - name: "Retrieve all backends from '{{ ldapserver_to_disable }}'."
       ansible.builtin.shell: "dsconf '{{ slapd_instance }}' backend suffix list"
       register: backend_suffix_list
+      changed_when: false
       check_mode: false
-      when: ldapserver_to_disable == ansible_nodename
 
     - name: "Show current backend_suffix_list"
       debug:
         var: backend_suffix_list
         verbosity: 2
-      when: ldapserver_to_disable == ansible_nodename
 
     - name: "Set backend variable"
       no_log: true
       set_fact:
         suffix_names: "{{ backend_suffix_list.stdout_lines | map('regex_replace', '\\s+\\(.+\\)\\s*$', '') | list }}"
         backend_names: "{{ backend_suffix_list.stdout_lines | map('regex_replace', '^.*\\((.+)\\)\\s*$', '\\1') | list }}"
-      when: ldapserver_to_disable == ansible_nodename
 
     - name: "Set suffixes dict"
       no_log: true
       set_fact:
         suffixes: "{{ dict( suffix_names | zip(backend_names) ) }}"
-      when: ldapserver_to_disable == ansible_nodename
 
     - name: "Show current suffixes"
       debug:
         var: suffixes
         verbosity: 0
-      when: ldapserver_to_disable == ansible_nodename
 
     - name: "Setting all backends to readonly."
       when: ldapserver_to_disable == ansible_nodename
         loop_var: backend
       include_tasks: '../includes/set-389ds-backend-readonly.yaml'
 
+    - name: "Removing replication agreements"
+      include_tasks: '../includes/del-389ds-backend-repl-agmts.yaml'
+      vars:
+        suffix: "{{ item[0].key }}"
+        target: "{{ item[1] }}"
+      loop: "{{ suffixes | dict2items | product( ansible_play_batch ) | list }}"
+
+
+# vim: filetype=yaml
+
 # vim: filetype=yaml