From 540749ef93d9a29fa354bbb5474302a43ee2050c Mon Sep 17 00:00:00 2001 From: Jakob Meng Date: Mon, 7 Nov 2022 10:10:51 +0100 Subject: [PATCH] Adapt role bifrost-cloud-config to Ansible OpenStack Col. >=2.0.0 Change-Id: I9938e45fe39841f109ab4b4d102bf802d9b938ab --- .../roles/bifrost-cloud-config/tasks/main.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/playbooks/roles/bifrost-cloud-config/tasks/main.yml b/playbooks/roles/bifrost-cloud-config/tasks/main.yml index 1973c7745..121ee7ab4 100644 --- a/playbooks/roles/bifrost-cloud-config/tasks/main.yml +++ b/playbooks/roles/bifrost-cloud-config/tasks/main.yml @@ -16,14 +16,20 @@ no_log: yes # NOTE(dtantsur): Allow missing clouds.yaml only in no-auth mode ignore_errors: "{{ noauth_mode | bool }}" + register: config -- name: "Set openstack_cloud if possible" +- name: "Set openstack_cloud if possible on Ansible OpenStack collection <2.0.0" + when: config.ansible_facts.openstack.clouds | default([]) | length > 0 set_fact: # TODO(dtantsur): support looking up by cloud_name - openstack_cloud: "{{ openstack.clouds[0] }}" - when: - - openstack is defined - - openstack.clouds | length > 0 + openstack_cloud: "{{ config.ansible_facts.openstack.clouds[0] }}" + no_log: yes + +- name: "Set openstack_cloud if possible on Ansible OpenStack collection >=2.0.0" + when: config.clouds | default([]) | length > 0 + set_fact: + # TODO(dtantsur): support looking up by cloud_name + openstack_cloud: "{{ config.clouds[0].config }}" no_log: yes # NOTE(TheJulia): The first record returned by openstack.cloud.config