diff --git a/changelogs/fragments/67576-os_coe_cluster-retrieve-id-uuid-correctly.yml b/changelogs/fragments/67576-os_coe_cluster-retrieve-id-uuid-correctly.yml new file mode 100644 index 00000000..fd3ce1ac --- /dev/null +++ b/changelogs/fragments/67576-os_coe_cluster-retrieve-id-uuid-correctly.yml @@ -0,0 +1,2 @@ +bugfixes: +- os_coe_cluster: Retrieve the correct id/uuid depending on whether it is a create/get request. diff --git a/plugins/modules/os_coe_cluster.py b/plugins/modules/os_coe_cluster.py index dbc847fc..18125403 100644 --- a/plugins/modules/os_coe_cluster.py +++ b/plugins/modules/os_coe_cluster.py @@ -187,7 +187,7 @@ cluster: - The time in UTC at which the cluster is updated type: str sample: '2018-08-16T10:39:25+00:00' - uuid: + id: description: - Unique UUID for this cluster type: str @@ -270,7 +270,13 @@ def main(): else: changed = False - module.exit_json(changed=changed, cluster=cluster, id=cluster['uuid']) + # NOTE (brtknr): At present, create_coe_cluster request returns + # cluster_id as `uuid` whereas get_coe_cluster request returns the + # same field as `id`. This behaviour may change in the future + # therefore try `id` first then `uuid`. + cluster_id = cluster.get('id', cluster.get('uuid')) + cluster['id'] = cluster['uuid'] = cluster_id + module.exit_json(changed=changed, cluster=cluster, id=cluster_id) elif state == 'absent': if not cluster: module.exit_json(changed=False)