From 54ba38e35ea67c1c342b008be675103e120982d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 1 Sep 2020 11:24:59 +0200 Subject: [PATCH] Fix Ansible check mode for site.yml.sample playbook MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make sure the `site.yml.sample` playbook can be run in check mode by skipping tasks that try to read the output of commands that have been skipped. Signed-off-by: Benoît Knecht --- roles/ceph-crash/tasks/main.yml | 3 ++- roles/ceph-mgr/tasks/common.yml | 1 + roles/ceph-mgr/tasks/mgr_modules.yml | 1 + roles/ceph-mon/tasks/ceph_keys.yml | 1 + roles/ceph-osd/tasks/common.yml | 1 + roles/ceph-osd/tasks/main.yml | 1 + roles/ceph-rgw/tasks/common.yml | 1 + site.yml.sample | 4 +++- 8 files changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/ceph-crash/tasks/main.yml b/roles/ceph-crash/tasks/main.yml index 242332675..eb693c15f 100644 --- a/roles/ceph-crash/tasks/main.yml +++ b/roles/ceph-crash/tasks/main.yml @@ -46,6 +46,7 @@ with_items: "{{ list_target_node }}" delegate_to: "{{ item }}" run_once: True + when: _crash_keys is not skipped - name: start ceph-crash daemon when: containerized_deployment | bool @@ -67,4 +68,4 @@ state: started enabled: yes masked: no - daemon_reload: yes \ No newline at end of file + daemon_reload: yes diff --git a/roles/ceph-mgr/tasks/common.yml b/roles/ceph-mgr/tasks/common.yml index 79bcd43e6..2abccc7e1 100644 --- a/roles/ceph-mgr/tasks/common.yml +++ b/roles/ceph-mgr/tasks/common.yml @@ -72,6 +72,7 @@ with_items: "{{ _mgr_keys.results }}" when: - cephx | bool + - item is not skipped - item.item.copy_key | bool - name: set mgr key permissions diff --git a/roles/ceph-mgr/tasks/mgr_modules.yml b/roles/ceph-mgr/tasks/mgr_modules.yml index 85ed88b04..18cac848a 100644 --- a/roles/ceph-mgr/tasks/mgr_modules.yml +++ b/roles/ceph-mgr/tasks/mgr_modules.yml @@ -14,6 +14,7 @@ until: - mgr_dump.rc == 0 - (mgr_dump.stdout | from_json).available | bool + when: not ansible_check_mode - name: get enabled modules from ceph-mgr command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls" diff --git a/roles/ceph-mon/tasks/ceph_keys.yml b/roles/ceph-mon/tasks/ceph_keys.yml index ee14cb3eb..7f67b4558 100644 --- a/roles/ceph-mon/tasks/ceph_keys.yml +++ b/roles/ceph-mon/tasks/ceph_keys.yml @@ -14,6 +14,7 @@ retries: "{{ handler_health_mon_check_retries }}" delay: "{{ handler_health_mon_check_delay }}" changed_when: false + when: not ansible_check_mode - name: fetch ceph initial keys ceph_key: diff --git a/roles/ceph-osd/tasks/common.yml b/roles/ceph-osd/tasks/common.yml index e1c156c4f..5a87748cd 100644 --- a/roles/ceph-osd/tasks/common.yml +++ b/roles/ceph-osd/tasks/common.yml @@ -33,4 +33,5 @@ with_items: "{{ _osd_keys.results }}" when: - cephx | bool + - item is not skipped - item.item.copy_key | bool diff --git a/roles/ceph-osd/tasks/main.yml b/roles/ceph-osd/tasks/main.yml index 492696dc1..309e35488 100644 --- a/roles/ceph-osd/tasks/main.yml +++ b/roles/ceph-osd/tasks/main.yml @@ -86,6 +86,7 @@ - (wait_for_all_osds_up.stdout | from_json)["osdmap"]["num_osds"] | int > 0 - (wait_for_all_osds_up.stdout | from_json)["osdmap"]["num_osds"] == (wait_for_all_osds_up.stdout | from_json)["osdmap"]["num_up_osds"] when: + - not ansible_check_mode - inventory_hostname == ansible_play_hosts_all | last - name: include crush_rules.yml diff --git a/roles/ceph-rgw/tasks/common.yml b/roles/ceph-rgw/tasks/common.yml index f4764294e..04ba17e89 100644 --- a/roles/ceph-rgw/tasks/common.yml +++ b/roles/ceph-rgw/tasks/common.yml @@ -30,6 +30,7 @@ with_items: "{{ _rgw_keys.results }}" when: - cephx | bool + - item is not skipped - item.item.copy_key | bool - name: copy SSL certificate & key data to certificate path diff --git a/site.yml.sample b/site.yml.sample index ab243ffdd..0c65034a2 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -488,4 +488,6 @@ msg: "{{ ceph_status.stdout_lines }}" delegate_to: "{{ groups[mon_group_name][0] }}" run_once: true - when: not ceph_status.failed + when: + - ceph_status is not skipped + - ceph_status is successful -- 2.39.5