From: Frank Brehm Date: Mon, 2 Dec 2024 11:11:28 +0000 (+0100) Subject: Adding and using role 389ds-disable-replication X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=d7133aeaee2a2b7f1b8a116458e6586ab4232d33;p=pixelpark%2Fpp-admin-tools.git Adding and using role 389ds-disable-replication --- diff --git a/includes/disable-389ds-replication.yaml b/includes/disable-389ds-replication.yaml deleted file mode 100644 index 49fb7f5..0000000 --- a/includes/disable-389ds-replication.yaml +++ /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 diff --git a/playbooks/disable-ldap-server.yaml b/playbooks/disable-ldap-server.yaml index ea95f35..a7b2731 100644 --- a/playbooks/disable-ldap-server.yaml +++ b/playbooks/disable-ldap-server.yaml @@ -192,7 +192,8 @@ - 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 index 0000000..f6bf7e6 --- /dev/null +++ b/roles/389ds-disable-replication/tasks/main.yaml @@ -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