]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
infra: use dedicated variables for balancer status
authorDimitri Savineau <dsavinea@redhat.com>
Tue, 3 Aug 2021 15:58:49 +0000 (11:58 -0400)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Wed, 4 Aug 2021 15:43:53 +0000 (11:43 -0400)
The balancer status is registered during the cephadm-adopt, rolling_update
and swith2container playbooks. But it is also used in the ceph-handler role
which is included in those playbooks too.
Even if the ceph-handler tasks are skipped for rolling_update and
switch2container, the balancer_status variable is erased with the skip task
result.

play1:
  register: balancer_status
play2:
  register: balancer_status <-- skipped
play3:
  when: (balancer_status.stdout | from_json)['active'] | bool

This leads to issue like:

The conditional check '(balancer_status.stdout | from_json)['active'] | bool'
failed. The error was: Unexpected templating type error occurred on
({% if (balancer_status.stdout | from_json)['active'] | bool %} True
{% else %} False {% endif %}): expected string or buffer.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1982054
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 386661699bcfe05a220de6d58b9d50baa7eb6dc1)

infrastructure-playbooks/cephadm-adopt.yml
infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml

index de3c3ca484d1ebf0df02bc7cbde5e7554c1aadb0..24ac4cb0e992866fe25fbcda3201be9569b6c2d1 100644 (file)
 
     - name: get balancer module status
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
-      register: balancer_status
+      register: balancer_status_adopt
       run_once: true
       delegate_to: "{{ groups[mon_group_name][0] }}"
       changed_when: false
       run_once: true
       delegate_to: "{{ groups[mon_group_name][0] }}"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_adopt.stdout | from_json)['active'] | bool
 
     - name: disable pg autoscale on pools
       ceph_pool:
       run_once: true
       delegate_to: "{{ groups[mon_group_name][0] }}"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_adopt.stdout | from_json)['active'] | bool
 
 - name: redeploy mds daemons
   hosts: "{{ mds_group_name|default('mdss') }}"
index ad9011a816a2f7ecb2ec0c6a3bde517dbbeff847..6315fbd054c1f3e16883ccf1fad3bf40677414a2 100644 (file)
 
     - name: get balancer module status
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
-      register: balancer_status
+      register: balancer_status_update
       changed_when: false
       check_mode: false
 
     - name: disable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_update.stdout | from_json)['active'] | bool
 
     - name: disable pg autoscale on pools
       ceph_pool:
     - name: re-enable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_update.stdout | from_json)['active'] | bool
 
 - name: upgrade ceph mdss cluster, deactivate all rank > 0
   hosts: "{{ mon_group_name | default('mons') }}[0]"
index 2b4b289e395eb25ed5cc94d82e8aa35bd2013c9b..e43647216e51895e07e69f59139fd4e822d04cea 100644 (file)
 
     - name: get balancer module status
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer status -f json"
-      register: balancer_status
+      register: balancer_status_switch
       changed_when: false
       check_mode: false
 
     - name: disable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_switch.stdout | from_json)['active'] | bool
 
     - name: disable pg autoscale on pools
       ceph_pool:
     - name: re-enable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer on"
       changed_when: false
-      when: (balancer_status.stdout | from_json)['active'] | bool
+      when: (balancer_status_switch.stdout | from_json)['active'] | bool
 
 
 - name: switching from non-containerized to containerized ceph mds