]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
handlers: refact osd handler
authorGuillaume Abrioux <gabrioux@redhat.com>
Thu, 3 Oct 2019 11:52:11 +0000 (13:52 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Tue, 15 Oct 2019 17:29:06 +0000 (13:29 -0400)
This commit merges the two restart tasks into a single one, this way
it's one task less to notify.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit 411bd07d54fc3f585296b68f2fd04484328399b5)

roles/ceph-handler/handlers/main.yml
roles/ceph-handler/tasks/main.yml

index 5ac3deeec8230c2514cb0406aae0a3a8ce3c7fce..f3d1ff2e297962bb40ed0dd908f595b80c3e9b53 100644 (file)
       listen: "restart ceph mons"
       when: mon_group_name in group_names
 
-    - name: restart ceph mon daemon(s) - non container
+    - name: restart ceph mon daemon(s)
       command: /usr/bin/env bash /tmp/restart_mon_daemon.sh
       listen: "restart ceph mons"
       when:
         # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - mon_group_name in group_names
-        - not containerized_deployment | bool
+        - handler_mon_status | bool
         - hostvars[item]['_mon_handler_called'] | default(False) | bool
-        - mon_socket_stat.rc == 0
-      with_items: "{{ groups[mon_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph mon daemon(s) - container
-      command: /usr/bin/env bash /tmp/restart_mon_daemon.sh
-      listen: "restart ceph mons"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - mon_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_mon_container_stat.get('rc') == 0
-        - hostvars[item]['_mon_handler_called'] | default(False) | bool
-        - ceph_mon_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[mon_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
       listen: "restart ceph osds"
       when: osd_group_name in group_names
 
-    - name: restart ceph osds daemon(s) - non container
+    - name: restart ceph osds daemon(s)
       command: /usr/bin/env bash /tmp/restart_osd_daemon.sh
       listen: "restart ceph osds"
       when:
         - osd_group_name in group_names
-        - not containerized_deployment | bool
-        # We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`)
-        # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
-        - osd_socket_stat.rc == 0
-        - ceph_current_status.fsid is defined
+        - handler_osd_status | bool
         - handler_health_osd_check | bool
         - hostvars[item]['_osd_handler_called'] | default(False) | bool
       with_items: "{{ groups[osd_group_name] | intersect(ansible_play_batch) }}"
       delegate_to: "{{ item }}"
       run_once: True
 
-    - name: restart ceph osds daemon(s) - container
-      command: /usr/bin/env bash /tmp/restart_osd_daemon.sh
-      listen: "restart ceph osds"
-      when:
-        # We do not want to run these checks on initial deployment (`socket_osd_container_stat.results[n].rc == 0`)
-        # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
-        - osd_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_osd_container_stat.get('rc') == 0
-        - ceph_osd_container_stat.get('stdout_lines', [])|length != 0
-        - handler_health_osd_check | bool
-        - hostvars[item]['_osd_handler_called'] | default(False)
-      with_items: "{{ groups[osd_group_name] | intersect(ansible_play_batch) }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
     - name: set _osd_handler_called after restart
       set_fact:
          _osd_handler_called: False
       listen: "restart ceph mdss"
       when: mds_group_name in group_names
 
-    - name: restart ceph mds daemon(s) - non container
+    - name: restart ceph mds daemon(s)
       command: /usr/bin/env bash /tmp/restart_mds_daemon.sh
       listen: "restart ceph mdss"
       when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - mds_group_name in group_names
-        - not containerized_deployment | bool
-        - hostvars[item]['_mds_handler_called'] | default(False) | bool
-        - mds_socket_stat.rc == 0
-      with_items: "{{ groups[mds_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph mds daemon(s) - container
-      command: /usr/bin/env bash /tmp/restart_mds_daemon.sh
-      listen: "restart ceph mdss"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - mds_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_mds_container_stat.get('rc') == 0
+        - handler_mds_status | bool
         - hostvars[item]['_mds_handler_called'] | default(False) | bool
-        - ceph_mds_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[mds_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
       listen: "restart ceph rgws"
       when: rgw_group_name in group_names
 
-    - name: restart ceph rgw daemon(s) - non container
-      command: /usr/bin/env bash /tmp/restart_rgw_daemon.sh
-      listen: "restart ceph rgws"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - rgw_group_name in group_names
-        - not containerized_deployment | bool
-        - hostvars[item]['_rgw_handler_called'] | default(False) | bool
-        - rgw_socket_stat.rc == 0
-      with_items: "{{ groups[rgw_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph rgw daemon(s) - container
+    - name: restart ceph rgw daemon(s)
       command: /usr/bin/env bash /tmp/restart_rgw_daemon.sh
       listen: "restart ceph rgws"
       when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - rgw_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_rgw_container_stat.get('rc') == 0
+        - handler_rgw_status | bool
         - hostvars[item]['_rgw_handler_called'] | default(False) | bool
-        - ceph_rgw_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[rgw_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
       listen: "restart ceph nfss"
       when: nfs_group_name in group_names
 
-    - name: restart ceph nfs daemon(s) - non container
+    - name: restart ceph nfs daemon(s)
       command: /usr/bin/env bash /tmp/restart_nfs_daemon.sh
       listen: "restart ceph nfss"
       when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - nfs_group_name in group_names
-        - not containerized_deployment | bool
+        - handler_nfs_status | bool
         - hostvars[item]['_nfs_handler_called'] | default(False) | bool
-        - nfs_socket_stat.rc == 0
-      with_items: "{{ groups[nfs_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph nfs daemon(s) - container
-      command: /usr/bin/env bash /tmp/restart_nfs_daemon.sh
-      listen: "restart ceph nfss"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - nfs_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_nfs_container_stat.get('rc') == 0
-        - hostvars[item]['_nfs_handler_called'] | default(False) | bool
-        - ceph_nfs_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[nfs_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
       listen: "restart ceph rbdmirrors"
       when: rbdmirror_group_name in group_names
 
-    - name: restart ceph rbd mirror daemon(s) - non container
+    - name: restart ceph rbd mirror daemon(s)
       command: /usr/bin/env bash /tmp/restart_rbd_mirror_daemon.sh
       listen: "restart ceph rbdmirrors"
       when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - rbdmirror_group_name in group_names
-        - not containerized_deployment | bool
+        - handler_rbd_mirror_status | bool
         - hostvars[item]['_rbdmirror_handler_called'] | default(False) | bool
-        - rbd_mirror_socket_stat.rc == 0
-      with_items: "{{ groups[rbdmirror_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph rbd mirror daemon(s) - container
-      command: /usr/bin/env bash /tmp/restart_rbd_mirror_daemon.sh
-      listen: "restart ceph rbdmirrors"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - rbdmirror_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_rbd_mirror_container_stat.get('rc') == 0
-        - hostvars[item]['_rbdmirror_handler_called'] | default(False) | bool
-        - ceph_rbd_mirror_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[rbdmirror_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
       listen: "restart ceph mgrs"
       when: mgr_group_name in group_names
 
-    - name: restart ceph mgr daemon(s) - non container
-      command: /usr/bin/env bash /tmp/restart_mgr_daemon.sh
-      listen: "restart ceph mgrs"
-      when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-        - mgr_group_name in group_names
-        - not containerized_deployment | bool
-        - hostvars[item]['_mgr_handler_called'] | default(False) | bool
-        - mgr_socket_stat.rc == 0
-      with_items: "{{ groups[mgr_group_name] }}"
-      delegate_to: "{{ item }}"
-      run_once: True
-
-    - name: restart ceph mgr daemon(s) - container
+    - name: restart ceph mgr daemon(s)
       command: /usr/bin/env bash /tmp/restart_mgr_daemon.sh
       listen: "restart ceph mgrs"
       when:
-        # We do not want to run these checks on initial deployment (`socket.rc == 0`)
         - mgr_group_name in group_names
-        - containerized_deployment | bool
-        - ceph_mgr_container_stat.get('rc') == 0
+        - handler_mgr_status | bool
         - hostvars[item]['_mgr_handler_called'] | default(False) | bool
-        - ceph_mgr_container_stat.get('stdout_lines', [])|length != 0
       with_items: "{{ groups[mgr_group_name] }}"
       delegate_to: "{{ item }}"
       run_once: True
index 270fb00d7da11a36d41ffb5514f606754fabe37e..6c6e036b82d6800bc3d20a5bc5b6abb4635fa08b 100644 (file)
@@ -5,35 +5,35 @@
 # We do not want to run these checks on initial deployment (`socket.rc == 0`)
 - name: set_fact handler_mon_status
   set_fact:
-    handler_mon_status: "{{ (mon_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_mon_container_stat.get('rc') == 0 and ceph_mon_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_mon_status: "{{ (mon_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_mon_container_stat.get('rc') == 0 and ceph_mon_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(mon_group_name, [])
 
 - name: set_fact handler_osd_status
   set_fact:
-    handler_osd_status: "{{ (osd_socket_stat.get('rc') == 0 and ceph_current_status.fsid is defined) if not containerized_deployment | bool else (ceph_osd_container_stat.get('rc') == 0 and ceph_osd_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_osd_status: "{{ (osd_socket_stat.get('rc') == 0 and ceph_current_status.fsid is defined) if not containerized_deployment else (ceph_osd_container_stat.get('rc') == 0 and ceph_osd_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(osd_group_name, [])
 
 - name: set_fact handler_mds_status
   set_fact:
-    handler_mds_status: "{{ (mds_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_mds_container_stat.get('rc') == 0 and ceph_mds_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_mds_status: "{{ (mds_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_mds_container_stat.get('rc') == 0 and ceph_mds_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(mds_group_name, [])
 
 - name: set_fact handler_rgw_status
   set_fact:
-    handler_rgw_status: "{{ (rgw_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_rgw_container_stat.get('rc') == 0 and ceph_rgw_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_rgw_status: "{{ (rgw_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_rgw_container_stat.get('rc') == 0 and ceph_rgw_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(rgw_group_name, [])
 
 - name: set_fact handler_nfs_status
   set_fact:
-    handler_nfs_status: "{{ (nfs_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_nfs_container_stat.get('rc') == 0 and ceph_nfs_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_nfs_status: "{{ (nfs_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_nfs_container_stat.get('rc') == 0 and ceph_nfs_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(nfs_group_name, [])
 
 - name: set_fact handler_rbd_status
   set_fact:
-    handler_rbd_mirror_status: "{{ (rbd_mirror_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_rbd_mirror_container_stat.get('rc') == 0 and ceph_rbd_mirror_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_rbd_mirror_status: "{{ (rbd_mirror_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_rbd_mirror_container_stat.get('rc') == 0 and ceph_rbd_mirror_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(rbdmirror_group_name, [])
 
 - name: set_fact handler_mgr_status
   set_fact:
-    handler_mgr_status: "{{ (mgr_socket_stat.get('rc') == 0) if not containerized_deployment | bool else (ceph_mgr_container_stat.get('rc') == 0 and ceph_mgr_container_stat.get('stdout_lines', []) | length != 0) }}"
+    handler_mgr_status: "{{ (mgr_socket_stat.get('rc') == 0) if not containerized_deployment else (ceph_mgr_container_stat.get('rc') == 0 and ceph_mgr_container_stat.get('stdout_lines', []) | length != 0) }}"
   when: inventory_hostname in groups.get(mgr_group_name, [])