From cf734e19b7251603020b10f027848a9df11b9e21 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 20 Jul 2021 15:53:48 -0400 Subject: [PATCH] common: fix py2 pool_list from_json when skipped 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 (cherry picked from commit cf6e33346e09e680d9b69cafdc24fdd8801cdbf4) --- infrastructure-playbooks/cephadm-adopt.yml | 2 +- infrastructure-playbooks/rolling_update.yml | 2 +- ...tch-from-non-containerized-to-containerized-ceph-daemons.yml | 2 +- roles/ceph-handler/tasks/handler_osds.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infrastructure-playbooks/cephadm-adopt.yml b/infrastructure-playbooks/cephadm-adopt.yml index c9cf6e822..db243843e 100644 --- a/infrastructure-playbooks/cephadm-adopt.yml +++ b/infrastructure-playbooks/cephadm-adopt.yml @@ -454,7 +454,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" diff --git a/infrastructure-playbooks/rolling_update.yml b/infrastructure-playbooks/rolling_update.yml index 630e0d2d2..1b11a51ce 100644 --- a/infrastructure-playbooks/rolling_update.yml +++ b/infrastructure-playbooks/rolling_update.yml @@ -427,7 +427,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" diff --git a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml index d59214736..e14f83a31 100644 --- a/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml +++ b/infrastructure-playbooks/switch-from-non-containerized-to-containerized-ceph-daemons.yml @@ -231,7 +231,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" diff --git a/roles/ceph-handler/tasks/handler_osds.yml b/roles/ceph-handler/tasks/handler_osds.yml index e1fb0ac92..7643f59f5 100644 --- a/roles/ceph-handler/tasks/handler_osds.yml +++ b/roles/ceph-handler/tasks/handler_osds.yml @@ -56,7 +56,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" -- 2.39.5