From 7993565baa9f6f1a1adc7c3471bef3d86a41fe3d Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 18 Dec 2024 14:59:47 +0100 Subject: [PATCH] Finishing Ansible role 389ds-init-replication --- roles/389ds-init-replication/tasks/main.yaml | 10 ++--- .../389ds-init-replication/tasks/suffix.yaml | 44 +++++++++++++++++-- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/roles/389ds-init-replication/tasks/main.yaml b/roles/389ds-init-replication/tasks/main.yaml index fafca09..b84b833 100644 --- a/roles/389ds-init-replication/tasks/main.yaml +++ b/roles/389ds-init-replication/tasks/main.yaml @@ -12,23 +12,21 @@ check_mode: false - name: "Show current get_backend_suffix_list" - debug: + ansible.builtin.debug: var: get_backend_suffix_list verbosity: 2 - name: "Set backend variable" - no_log: true - set_fact: + ansible.builtin.set_fact: suffix_names: "{{ get_backend_suffix_list.stdout_lines | map('regex_replace', '\\s+\\(.+\\)\\s*$', '') | list }}" backend_names: "{{ get_backend_suffix_list.stdout_lines | map('regex_replace', '^.*\\((.+)\\)\\s*$', '\\1') | list }}" - name: "Set suffixes dict" - no_log: true - set_fact: + ansible.builtin.set_fact: suffixes: "{{ dict( suffix_names | zip(backend_names) ) }}" - name: "Show current suffixes" - debug: + ansible.builtin.debug: var: suffixes verbosity: 0 diff --git a/roles/389ds-init-replication/tasks/suffix.yaml b/roles/389ds-init-replication/tasks/suffix.yaml index baaa036..444ad77 100644 --- a/roles/389ds-init-replication/tasks/suffix.yaml +++ b/roles/389ds-init-replication/tasks/suffix.yaml @@ -1,18 +1,54 @@ --- -- debug: +- ansible.builtin.debug: msg: "start init of replication agreement from {{ inventory_hostname | quote }} \ to {{ target_host | quote }} for suffix {{ suffix | quote }}." verbosity: 0 - name: "Set fact agreement_name." - set_fact: + ansible.builtin.set_fact: agreement_name: "{{ slapd_instance }} to {{ target_host }} agreement" -- name: "Show replication agreement name for suffix {{ suffix | quote }}." - debug: +- name: "Show replication agreement name for suffix." + ansible.builtin.debug: var: agreement_name + verbosity: 2 + +- name: "Defining the command for start init replication agreement." + ansible.builtin.set_fact: + cmd_init_repl_agmt: "dsconf {{ slapd_instance | quote }} repl-agmt init --suffix {{ suffix | quote }} {{ agreement_name | quote }}" + +- name: "Show command for start init replication agreement:" + ansible.builtin.debug: + var: cmd_init_repl_agmt + verbosity: 1 + +- name: "Start init replication agreement:" + ansible.builtin.shell: "{{ cmd_init_repl_agmt }}" + +- name: "Defining the command for checking status of init replication agreement." + ansible.builtin.set_fact: + cmd_check_init_repl_agmt: "dsconf {{ slapd_instance | quote }} repl-agmt init-status --suffix {{ suffix | quote }} {{ agreement_name | quote }}" + +- name: "Show command for checking status of init replication agreement:" + ansible.builtin.debug: + var: cmd_check_init_repl_agmt verbosity: 0 +- name: "Checking the status of init replication agreement." + ansible.builtin.shell: "{{ cmd_check_init_repl_agmt }}" + register: get_status_init_repl_agmt + changed_when: false + check_mode: false + +- name: "Show current get_status_init_repl_agmt" + ansible.builtin.debug: + var: get_status_init_repl_agmt + verbosity: 2 + +- name: "Current status of init replication agreement:" + ansible.builtin.debug: + var: get_status_init_repl_agmt.stdout + # vim: filetype=yaml -- 2.39.5