ceph_orch_apply: fix yaml error when multiple rgw deployed

ceph orch ls rgw --format=yaml returns multiple documents
when multiple rgw are installed, this was not handled
correctly.

Signed-off-by: Teoman ONAY <tonay@ibm.com>
(cherry picked from commit 823700bc1b)
pull/7604/head
Teoman ONAY 2024-08-21 17:33:19 +02:00
parent 3b5e0b2bbc
commit d0c8bfe66e
2 changed files with 7 additions and 2 deletions

View File

@ -943,7 +943,7 @@
hosts: hosts:
- {{ ansible_facts['nodename'] }} - {{ ansible_facts['nodename'] }}
{% if rgw_subnet is defined %} {% if rgw_subnet is defined %}
networks: "{{ rgw_subnet }}" networks: "{{ radosgw_address_block }}"
{% endif %} {% endif %}
spec: spec:
rgw_frontend_port: {{ radosgw_frontend_port }} rgw_frontend_port: {{ radosgw_frontend_port }}

View File

@ -82,7 +82,12 @@ def retrieve_current_spec(module: AnsibleModule, expected_spec: Dict) -> Dict:
""" retrieve current config of the service """ """ retrieve current config of the service """
service: str = expected_spec["service_type"] service: str = expected_spec["service_type"]
cmd = build_base_cmd_orch(module) cmd = build_base_cmd_orch(module)
cmd.extend(['ls', service, '--format=yaml']) cmd.extend(['ls', service])
if 'service_name' in expected_spec:
cmd.extend([expected_spec["service_name"]])
else:
cmd.extend([expected_spec["service_type"] + "." + expected_spec["service_id"]])
cmd.extend(['--format=yaml'])
out = module.run_command(cmd) out = module.run_command(cmd)
if isinstance(out, str): if isinstance(out, str):
# if there is no existing service, cephadm returns the string 'No services reported' # if there is no existing service, cephadm returns the string 'No services reported'