From bffca06837e01ecbbb039c94a7059ed277e4b10e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Thu, 30 Dec 2021 15:08:08 +0100 Subject: [PATCH] ceph-handler: Fix check mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When running in check mode with one or more Ceph daemons that need to be restarted, the `tmpdirpath.path` variable that several handlers rely on is undefined, leading to fatal errors. This commit ensures the tasks that require `tmpdirpath.path` are skipped when it's undefined. Signed-off-by: Benoît Knecht --- roles/ceph-handler/handlers/main.yml | 2 +- roles/ceph-handler/tasks/handler_mdss.yml | 2 ++ roles/ceph-handler/tasks/handler_mgrs.yml | 2 ++ roles/ceph-handler/tasks/handler_mons.yml | 2 ++ roles/ceph-handler/tasks/handler_nfss.yml | 2 ++ roles/ceph-handler/tasks/handler_osds.yml | 4 +++- roles/ceph-handler/tasks/handler_rbdmirrors.yml | 2 ++ roles/ceph-handler/tasks/handler_rgws.yml | 2 ++ 8 files changed, 16 insertions(+), 2 deletions(-) diff --git a/roles/ceph-handler/handlers/main.yml b/roles/ceph-handler/handlers/main.yml index 463a27220..dd3ef2963 100644 --- a/roles/ceph-handler/handlers/main.yml +++ b/roles/ceph-handler/handlers/main.yml @@ -88,4 +88,4 @@ - "restart ceph rbdmirrors" - "restart ceph mgrs" register: tmpdirpath - when: tmpdirpath is defined + when: tmpdirpath.path is defined diff --git a/roles/ceph-handler/tasks/handler_mdss.yml b/roles/ceph-handler/tasks/handler_mdss.yml index d150c5d80..4043844f2 100644 --- a/roles/ceph-handler/tasks/handler_mdss.yml +++ b/roles/ceph-handler/tasks/handler_mdss.yml @@ -10,12 +10,14 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph mds daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_mds_daemon.sh when: - hostvars[item]['handler_mds_status'] | default(False) | bool - hostvars[item]['_mds_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[mds_group_name] }}" delegate_to: "{{ item }}" run_once: True diff --git a/roles/ceph-handler/tasks/handler_mgrs.yml b/roles/ceph-handler/tasks/handler_mgrs.yml index 67ea7f41b..35f1d40da 100644 --- a/roles/ceph-handler/tasks/handler_mgrs.yml +++ b/roles/ceph-handler/tasks/handler_mgrs.yml @@ -10,12 +10,14 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph mgr daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_mgr_daemon.sh when: - hostvars[item]['handler_mgr_status'] | default(False) | bool - hostvars[item]['_mgr_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[mgr_group_name] }}" delegate_to: "{{ item }}" run_once: True diff --git a/roles/ceph-handler/tasks/handler_mons.yml b/roles/ceph-handler/tasks/handler_mons.yml index 91521a23e..112eb13c8 100644 --- a/roles/ceph-handler/tasks/handler_mons.yml +++ b/roles/ceph-handler/tasks/handler_mons.yml @@ -13,6 +13,7 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph mon daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_mon_daemon.sh @@ -20,6 +21,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - hostvars[item]['handler_mon_status'] | default(False) | bool - hostvars[item]['_mon_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[mon_group_name] }}" delegate_to: "{{ item }}" run_once: True diff --git a/roles/ceph-handler/tasks/handler_nfss.yml b/roles/ceph-handler/tasks/handler_nfss.yml index 98cd5f6c1..65df7b756 100644 --- a/roles/ceph-handler/tasks/handler_nfss.yml +++ b/roles/ceph-handler/tasks/handler_nfss.yml @@ -10,12 +10,14 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph nfs daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_nfs_daemon.sh when: - hostvars[item]['handler_nfs_status'] | default(False) | bool - hostvars[item]['_nfs_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[nfs_group_name] }}" delegate_to: "{{ item }}" run_once: True diff --git a/roles/ceph-handler/tasks/handler_osds.yml b/roles/ceph-handler/tasks/handler_osds.yml index 204e09978..cc62deecc 100644 --- a/roles/ceph-handler/tasks/handler_osds.yml +++ b/roles/ceph-handler/tasks/handler_osds.yml @@ -37,6 +37,7 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: get pool list command: "{{ ceph_cmd }} --cluster {{ cluster }} osd pool ls detail -f json" @@ -88,6 +89,7 @@ - hostvars[item]['handler_osd_status'] | default(False) | bool - handler_health_osd_check | bool - hostvars[item]['_osd_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[osd_group_name] | intersect(ansible_play_batch) }}" delegate_to: "{{ item }}" run_once: True @@ -116,4 +118,4 @@ run_once: true delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false - when: (balancer_status.stdout | from_json)['active'] | bool \ No newline at end of file + when: (balancer_status.stdout | from_json)['active'] | bool diff --git a/roles/ceph-handler/tasks/handler_rbdmirrors.yml b/roles/ceph-handler/tasks/handler_rbdmirrors.yml index 1baff68e8..f09198155 100644 --- a/roles/ceph-handler/tasks/handler_rbdmirrors.yml +++ b/roles/ceph-handler/tasks/handler_rbdmirrors.yml @@ -10,12 +10,14 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph rbd mirror daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_rbd_mirror_daemon.sh when: - hostvars[item]['handler_rbd_mirror_status'] | default(False) | bool - hostvars[item]['_rbdmirror_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[rbdmirror_group_name] }}" delegate_to: "{{ item }}" run_once: True diff --git a/roles/ceph-handler/tasks/handler_rgws.yml b/roles/ceph-handler/tasks/handler_rgws.yml index bbcd7775d..4e11f3da3 100644 --- a/roles/ceph-handler/tasks/handler_rgws.yml +++ b/roles/ceph-handler/tasks/handler_rgws.yml @@ -10,12 +10,14 @@ owner: root group: root mode: 0750 + when: tmpdirpath.path is defined - name: restart ceph rgw daemon(s) command: /usr/bin/env bash {{ hostvars[item]['tmpdirpath']['path'] }}/restart_rgw_daemon.sh when: - hostvars[item]['handler_rgw_status'] | default(False) | bool - hostvars[item]['_rgw_handler_called'] | default(False) | bool + - hostvars[item].tmpdirpath.path is defined with_items: "{{ groups[rgw_group_name] }}" delegate_to: "{{ item }}" run_once: True -- 2.39.5