]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
update: set osd flags only once
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 20 Mar 2019 08:46:21 +0000 (09:46 +0100)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Mon, 25 Mar 2019 20:02:56 +0000 (16:02 -0400)
There is no need to set osd flags (noout, norebalance) each time we
upgrade a mon.

This commit moves up those tasks (before stopping the mon) so we don't need
to delegate them.

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

index 75861b348051188bd935ff604b42081999a1f961..15eee8f6e719042f768b2131b229684f00572443 100644 (file)
@@ -83,7 +83,8 @@
   become: True
   tasks:
     - name: set mon_host_count
-      set_fact: mon_host_count={{ groups[mon_group_name] | length }}
+      set_fact:
+        mon_host_count: "{{ groups[mon_group_name] | length }}"
 
     - name: fail when less than three monitors
       fail:
       when:
         - mon_host_count | int < 3
 
+    - name: select a running monitor
+      set_fact:
+        mon_host: "{{ groups[mon_group_name] | difference([inventory_hostname]) | last }}"
+
     - name: stop ceph mon - shortname
       systemd:
         name: ceph-mon@{{ ansible_hostname }}
         name: ceph-mgr
       when: groups.get(mgr_group_name, []) | length == 0
 
+    - name: set osd flags
+      command: ceph --cluster {{ cluster }} osd set {{ item }}
+      with_items:
+        - noout
+        - norebalance
+      delegate_to: "{{ mon_host }}"
+      when:
+        - inventory_hostname == groups[mon_group_name][0]
+        - not containerized_deployment
+
+    - name: set containerized osd flags
+      command: >
+        {{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }}
+      with_items:
+        - noout
+        - norebalance
+      delegate_to: "{{ mon_host }}"
+      when:
+        - inventory_hostname == groups[mon_group_name][0]
+        - containerized_deployment
+
     - name: start ceph mon
       systemd:
         name: ceph-mon@{{ monitor_name }}
       when:
         - containerized_deployment
 
-    - name: set mon_host_count
-      set_fact: mon_host_count={{ groups[mon_group_name] | length }}
-
-    - name: select a running monitor
-      set_fact:
-        mon_host: "{{ groups[mon_group_name] | difference([inventory_hostname]) | last }}"
-
     - name: non container | waiting for the monitor to join the quorum...
       command: ceph --cluster "{{ cluster }}" -s --format json
       register: ceph_health_raw
         - ['bootstrap-rbd', 'bootstrap-rbd-mirror']
         - "{{ groups[mon_group_name] | difference([mon_host]) }}" # so the key goes on all the nodes
 
-    - name: set osd flags
-      command: ceph --cluster {{ cluster }} osd set {{ item }}
-      with_items:
-        - noout
-        - norebalance
-      delegate_to: "{{ mon_host }}"
-      when: not containerized_deployment
-
-    - name: set containerized osd flags
-      command: >
-        {{ container_binary }} exec ceph-mon-{{ hostvars[mon_host]['ansible_hostname'] }} ceph --cluster {{ cluster }} osd set {{ item }}
-      with_items:
-        - noout
-        - norebalance
-      delegate_to: "{{ mon_host }}"
-      when: containerized_deployment
 
 
 - name: upgrade ceph mgr node