]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding and using role 389ds-del-repl-agmt
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 2 Dec 2024 10:55:52 +0000 (11:55 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 2 Dec 2024 10:55:52 +0000 (11:55 +0100)
includes/del-389ds-backend-repl-agmt.yaml [deleted file]
includes/del-389ds-backend-repl-agmts-src.yaml [deleted file]
includes/del-389ds-backend-repl-agmts-target.yaml [deleted file]
playbooks/disable-ldap-server.yaml
roles/389ds-del-repl-agmt/tasks/del-repl-agmt.yaml [new file with mode: 0644]
roles/389ds-del-repl-agmt/tasks/main.yaml [new file with mode: 0644]

diff --git a/includes/del-389ds-backend-repl-agmt.yaml b/includes/del-389ds-backend-repl-agmt.yaml
deleted file mode 100644 (file)
index 1b353af..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
----
-
-- 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
diff --git a/includes/del-389ds-backend-repl-agmts-src.yaml b/includes/del-389ds-backend-repl-agmts-src.yaml
deleted file mode 100644 (file)
index b964d0d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
----
-
-- name: "Removing replication agreement to '{{ target }}' on suffix '{{ suffix }}'."
-  include_tasks: '../includes/del-389ds-backend-repl-agmt.yaml'
-  when: target == ldapserver_to_disable
-
-# vim: filetype=yaml
diff --git a/includes/del-389ds-backend-repl-agmts-target.yaml b/includes/del-389ds-backend-repl-agmts-target.yaml
deleted file mode 100644 (file)
index 711ca2b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
----
-
-#  name: "Removing replication agreements to '{{ target }}' on suffix '{{ suffix }}'."
-#  when: target != ansible_fqdn
-#  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 to '{{ target }}' on suffix '{{ suffix }}'."
-  when: target != ansible_fqdn
-  include_tasks: '../includes/del-389ds-backend-repl-agmt.yaml'
-
-# vim: filetype=yaml
index 5733306a3aca5299467d976b47eaedecd4a2c7dc..ea95f3592f75240b993c0dabb7514f9a179bbff6 100644 (file)
         backend: "{{ haproxy_backend_name }}"
         backend_server: "{{ ldapserver_to_disable }}"
 
-    # - name: "Fail for stop."
-    #   ansible.builtin.fail:
-    #     msg: "Hard stopping here ..."
-
 - name: "Disabling Replication on the given host."
   hosts: ldap_servers
+  gather_facts: false
 
   tasks:
 
         loop_var: backend
 
     - name: "Removing replication agreements on host to disable."
-      include_tasks: '../includes/del-389ds-backend-repl-agmts-target.yaml'
+      include_role:
+        name: 389ds-del-repl-agmt
       when: ldapserver_to_disable == inventory_hostname
       vars:
+        direction: 'from-disabled'
         suffix: "{{ item[0].key }}"
         target: "{{ item[1] }}"
       loop: "{{ suffixes | dict2items | product( ansible_play_batch ) | list }}"
 
     - name: "Removing replication agreements on hosts to keep."
-      include_tasks: '../includes/del-389ds-backend-repl-agmts-src.yaml'
+      include_role:
+        name: 389ds-del-repl-agmt
       when: ldapserver_to_disable != inventory_hostname
       vars:
+        direction: 'to-disabled'
         suffix: "{{ item[0].key }}"
         target: "{{ item[1] }}"
       loop: "{{ suffixes | dict2items | product( ansible_play_batch ) | list }}"
diff --git a/roles/389ds-del-repl-agmt/tasks/del-repl-agmt.yaml b/roles/389ds-del-repl-agmt/tasks/del-repl-agmt.yaml
new file mode 100644 (file)
index 0000000..1b353af
--- /dev/null
@@ -0,0 +1,17 @@
+---
+
+- 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
diff --git a/roles/389ds-del-repl-agmt/tasks/main.yaml b/roles/389ds-del-repl-agmt/tasks/main.yaml
new file mode 100644 (file)
index 0000000..942b531
--- /dev/null
@@ -0,0 +1,17 @@
+---
+
+- name: "Removing replication agreements."
+  debug:
+    var: direction
+    verbosity: 0
+
+- name: "Removing replication agreements to '{{ target }}' on suffix '{{ suffix }}'."
+  when: direction == 'from-disabled' and target != inventory_hostname
+  include_tasks: 'del-repl-agmt.yaml'
+
+- name: "Removing replication agreement to '{{ target }}' on suffix '{{ suffix }}'."
+  when: direction == 'to-disabled' and target == ldapserver_to_disable
+  include_tasks: 'del-repl-agmt.yaml'
+
+
+# vim: filetype=yaml