From: Frank Brehm Date: Mon, 2 Dec 2024 10:55:52 +0000 (+0100) Subject: Adding and using role 389ds-del-repl-agmt X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=539d549ff5cc7e3b1f06b068dc35b9fb061291d6;p=pixelpark%2Fpp-admin-tools.git Adding and using role 389ds-del-repl-agmt --- diff --git a/includes/del-389ds-backend-repl-agmt.yaml b/includes/del-389ds-backend-repl-agmt.yaml deleted file mode 100644 index 1b353af..0000000 --- a/includes/del-389ds-backend-repl-agmt.yaml +++ /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 index b964d0d..0000000 --- a/includes/del-389ds-backend-repl-agmts-src.yaml +++ /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 index 711ca2b..0000000 --- a/includes/del-389ds-backend-repl-agmts-target.yaml +++ /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 diff --git a/playbooks/disable-ldap-server.yaml b/playbooks/disable-ldap-server.yaml index 5733306..ea95f35 100644 --- a/playbooks/disable-ldap-server.yaml +++ b/playbooks/disable-ldap-server.yaml @@ -58,12 +58,9 @@ 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: @@ -174,17 +171,21 @@ 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 index 0000000..1b353af --- /dev/null +++ b/roles/389ds-del-repl-agmt/tasks/del-repl-agmt.yaml @@ -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 index 0000000..942b531 --- /dev/null +++ b/roles/389ds-del-repl-agmt/tasks/main.yaml @@ -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