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

diff --git a/includes/disable-389ds-replication.yaml b/includes/disable-389ds-replication.yaml
deleted file mode 100644 (file)
index 49fb7f5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
----
-
-- name: "Get a list of all replicated Suffixes."
-  ansible.builtin.shell: "dsconf '{{ slapd_instance }}' replication list"
-  check_mode: false
-  changed_when: false
-  register: list_of_replicated_suffixes
-
-- name: "Show current list_of_replicated_suffixes"
-  debug:
-    var: list_of_replicated_suffixes
-    verbosity: 2
-
-- name: "Set fact suffix_is_replicated."
-  no_log: true
-  set_fact:
-    suffix_is_replicated: false
-
-- name: "Searching for suffix '{{ suffix }}' in the list of replicated suffixes."
-  set_fact:
-    suffix_is_replicated: true
-  when: ( this_line | regex_replace('^\\s*') | regex_replace('\\s*$') ) == suffix
-  loop: "{{ list_of_replicated_suffixes.stdout_lines }}"
-  loop_control:
-    loop_var: this_line
-
-- name: "Set fact list_of_replicated_suffixes."
-  no_log: true
-  set_fact:
-    list_of_replicated_suffixes: ~
-
-- name: "The suffix '{{ suffix }}' is replicated:"
-  debug:
-    var: suffix_is_replicated
-
-
-# vim: filetype=yaml
index ea95f3592f75240b993c0dabb7514f9a179bbff6..a7b2731933b5e21e69efc269cf46e2567e7f476d 100644 (file)
 
     - name: "Disabling replication on all suffixes."
       when: ldapserver_to_disable == inventory_hostname
-      include_tasks: '../includes/disable-389ds-replication.yaml'
+      include_role:
+        name: 389ds-disable-replication
       vars:
         suffix: "{{ item.key }}"
       loop: "{{ suffixes | dict2items | list }}"
diff --git a/roles/389ds-disable-replication/tasks/main.yaml b/roles/389ds-disable-replication/tasks/main.yaml
new file mode 100644 (file)
index 0000000..f6bf7e6
--- /dev/null
@@ -0,0 +1,41 @@
+---
+
+- name: "Get a list of all replicated Suffixes."
+  ansible.builtin.shell: "dsconf '{{ slapd_instance }}' replication list"
+  check_mode: false
+  changed_when: false
+  register: list_of_replicated_suffixes
+
+- name: "Show current list_of_replicated_suffixes"
+  debug:
+    var: list_of_replicated_suffixes
+    verbosity: 2
+
+- name: "Set fact suffix_is_replicated."
+  no_log: true
+  set_fact:
+    suffix_is_replicated: false
+
+- name: "Searching for suffix '{{ suffix }}' in the list of replicated suffixes."
+  set_fact:
+    suffix_is_replicated: true
+  when: ( this_line | regex_replace('^\\s*') | regex_replace('\\s*$') ) == suffix
+  loop: "{{ list_of_replicated_suffixes.stdout_lines }}"
+  loop_control:
+    loop_var: this_line
+
+- name: "Set fact list_of_replicated_suffixes."
+  no_log: true
+  set_fact:
+    list_of_replicated_suffixes: ~
+
+- name: "The suffix '{{ suffix }}' is replicated:"
+  debug:
+    var: suffix_is_replicated
+    verbosity: 0
+
+- name: "Finally remove replication from suffix '{{ suffix }}'."
+  ansible.builtin.shell: "dsconf '{{ slapd_instance }}' disable --suffix '{{ suffix }}'"
+  when: suffix_is_replicated == true
+
+# vim: filetype=yaml