# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: "Execute openstack.cloud.config to collect facts" openstack.cloud.config: 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 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: "{{ 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 # is utilized as the default. A user can still define the parameters # if so desired. - name: "Set openstack.cloud.config auth parameters if not already set." set_fact: auth: "{{ openstack_cloud.auth }}" auth_type: "{{ openstack_cloud.auth_type }}" when: - auth is undefined - openstack_cloud is defined no_log: yes - name: "Set the TLS certificate if present" set_fact: tls_certificate_path: "{{ openstack_cloud.cacert }}" when: - tls_certificate_path is undefined - openstack_cloud is defined - openstack_cloud.cacert is defined - name: "If in noauth mode and no clouds.yaml, unset authentication parameters." set_fact: auth_type: None auth: endpoint: "{{ ironic_url | default(ironic_api_url) }}" when: - auth is undefined - noauth_mode | bool