ceph-handler: Fix check mode
authorBenoît Knecht <bknecht@protonmail.ch>
Thu, 30 Dec 2021 14:08:08 +0000 (15:08 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 6 Jan 2022 09:46:55 +0000 (10:46 +0100)
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 <bknecht@protonmail.ch>
roles/ceph-handler/handlers/main.yml
roles/ceph-handler/tasks/handler_mdss.yml
roles/ceph-handler/tasks/handler_mgrs.yml
roles/ceph-handler/tasks/handler_mons.yml
roles/ceph-handler/tasks/handler_nfss.yml
roles/ceph-handler/tasks/handler_osds.yml
roles/ceph-handler/tasks/handler_rbdmirrors.yml
roles/ceph-handler/tasks/handler_rgws.yml

index 463a272200736e4591879f2eb5f796c0dd811fb2..dd3ef29639070d9a89a290de78d30b8541cc8d4c 100644 (file)
@@ -88,4 +88,4 @@
         - "restart ceph rbdmirrors"
         - "restart ceph mgrs"
       register: tmpdirpath
-      when: tmpdirpath is defined
+      when: tmpdirpath.path is defined
index d150c5d80dbaa8cf45b6dc964aaff83e29c72cf8..4043844f22a088993bc067f187c98f29d7f533d9 100644 (file)
     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
index 67ea7f41bb7015f0fb743a20c63923c57195a4c0..35f1d40da5cc1f9e0598c06a80fb746f1d1db70c 100644 (file)
     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
index 91521a23e3e55c8f46bce001a5db899463523106..112eb13c8d8814eba4bf7dcd7245c925cb904745 100644 (file)
@@ -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
index 98cd5f6c1b1e88dd1bf789908bf551be3d5c8d58..65df7b75665e3e7b00b8b73776c81b3a60d1a875 100644 (file)
     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
index 204e099785ee92931af2add4aa6922ec241f6568..cc62deecc0aef7bb2dc924c7a652c285ff7c82d5 100644 (file)
@@ -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
       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
index 1baff68e84888468ab4cb2114d380ebd2c40df06..f091981556dba1b785094934427ea41d39d917ba 100644 (file)
     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
index bbcd7775d82a1c2420a7dcc51071ae1e658ee692..4e11f3da327aeffc7e8868906cc92ca126aad5f3 100644 (file)
     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