From 997ab864cd841d76d5c28948309f618da5cfa4ac Mon Sep 17 00:00:00 2001 From: Jose Luis Franco Arza Date: Mon, 23 Sep 2019 10:10:49 +0200 Subject: [PATCH] Handle when ceph_osds is a dictionary or a list. The ceph_osds variable is obtained from the ceph configuration and it seems it can be a dictionary formed by the osds directories as keys, example {'/dev/vdc': {}, '/dev/vdb': {}, '/dev/vdf': {}, '/dev/vde': {}, '/dev/vdd': {}} . For that reason, we need to differentiate when the variable is a list or a dictionary, as otherwise the loop variable won't be able to iterate over the values. Change-Id: Ib7aded0ff3668079dbe43cc3fbfa6a7e067cec83 Closes-Bug: #1844974 (cherry picked from commit 75290252d7bd22540a10a47ba6f5477d85c5a542) (cherry picked from commit b70b3e0a2b5596dc51fc4d5a342ae424af93d27f) --- tasks/common/convert_ceph_params.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasks/common/convert_ceph_params.yaml b/tasks/common/convert_ceph_params.yaml index 7b3db1df..34ad39a9 100644 --- a/tasks/common/convert_ceph_params.yaml +++ b/tasks/common/convert_ceph_params.yaml @@ -42,8 +42,11 @@ register: ceph_puppet - name: set ceph_osds fact + vars: + ceph_yaml: "{{ (ceph_puppet.stdout | from_yaml).parameter_defaults }}" + ceph_osds_var: "{{ ceph_yaml.ExtraConfig['ceph::profile::params::osds']}}" set_fact: - ceph_osds: "{{ (ceph_puppet.stdout | from_yaml).parameter_defaults.ExtraConfig['ceph::profile::params::osds'] | default([]) }}" + ceph_osds: "{{ (ceph_osds_var.keys()|list if ceph_osds_var | type_debug == 'dict' else ceph_osds_var) | default([]) }}" - name: set ceph_osds_pg fact set_fact: