]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
rolling_update: fail early if cluster state is not OK
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 10 Jun 2019 14:26:18 +0000 (16:26 +0200)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Tue, 18 Jun 2019 16:45:01 +0000 (12:45 -0400)
starting an upgrade if the cluster isn't HEALTH_OK isn't a good idea.
Let's check for the cluster status before trying to upgrade.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
infrastructure-playbooks/rolling_update.yml

index 3971a4dd58bdd2a36dbd2218d5d4dfc7d602e45b..6663e61de69874f2dbf8833b7ea9c3e7c5ec358d 100644 (file)
     - import_role:
         name: ceph-facts
 
+    - block:
+        - name: get ceph cluster status
+          command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} -s -f json"
+          register: check_cluster_status
+          delegate_to: "{{ mon_host }}"
+
+        - block:
+            - name: display ceph health detail
+              command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} health detail"
+              delegate_to: "{{ mon_host }}"
+
+            - name: fail if cluster isn't in an acceptable state
+              fail:
+                msg: "cluster is not in an acceptable state!"
+          when: not (check_cluster_status.stdout | from_json).health.status == 'HEALTH_OK'
+      when: inventory_hostname == groups[mon_group_name] | first
+
     - name: ensure /var/lib/ceph/bootstrap-rbd-mirror is present
       file:
         path: /var/lib/ceph/bootstrap-rbd-mirror