]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
common: fix py2 pool_list from_json when skipped
authorDimitri Savineau <dsavinea@redhat.com>
Tue, 20 Jul 2021 19:53:48 +0000 (15:53 -0400)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Wed, 21 Jul 2021 13:54:46 +0000 (09:54 -0400)
When using python 2 and the task with a loop is skipped then it generates
an error.

Unexpected templating type error occurred on
({{ (pool_list.stdout | from_json)['pools'] }}): expected string or buffer

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit cf6e33346e09e680d9b69cafdc24fdd8801cdbf4)

infrastructure-playbooks/rolling_update.yml
infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml
roles/ceph-handler/tasks/handler_osds.yml

index ce5075723114437974ee0c5568230488f4128b36..9ccfa81974421f0fd23539f6ce0d3b573ae404ac 100644 (file)
       set_fact:
         pools_pgautoscaler_mode: "{{ pools_pgautoscaler_mode | default([]) | union([{'name': item.pool_name, 'mode': item.pg_autoscale_mode}]) }}"
       run_once: true
-      with_items: "{{ (pool_list.stdout | from_json)['pools'] }}"
+      with_items: "{{ (pool_list.stdout | default('{}') | from_json)['pools'] }}"
 
     - name: disable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
index 3882526ec68007846c42c1dac4f8b71cbd03c8b3..667e95900f94fb252f09a57d42ed1b7a7cf72bcc 100644 (file)
       set_fact:
         pools_pgautoscaler_mode: "{{ pools_pgautoscaler_mode | default([]) | union([{'name': item.pool_name, 'mode': item.pg_autoscale_mode}]) }}"
       run_once: true
-      with_items: "{{ (pool_list.stdout | from_json)['pools'] }}"
+      with_items: "{{ (pool_list.stdout | default('{}') | from_json)['pools'] }}"
 
     - name: disable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"
index 8d0717e3d3ab99dd462dfee128d328e8c413241c..f16a063600b92e6b1b58fbbef970435bda71fad6 100644 (file)
@@ -27,7 +27,7 @@
       set_fact:
         pools_pgautoscaler_mode: "{{ pools_pgautoscaler_mode | default([]) | union([{'name': item.pool_name, 'mode': item.pg_autoscale_mode}]) }}"
       run_once: true
-      with_items: "{{ (pool_list.stdout | from_json)['pools'] }}"
+      with_items: "{{ (pool_list.stdout | default('{}') | from_json)['pools'] }}"
 
     - name: disable balancer
       command: "{{ ceph_cmd }} --cluster {{ cluster }} balancer off"