| # Copyright (c) 2022 VEXXHOST, Inc. |
| # |
| # 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: Gather information about a bare metal network |
| run_once: true |
| openstack.cloud.networks_info: |
| cloud: atmosphere |
| # Network settings |
| name: "{{ ironic_bare_metal_network_name }}" |
| register: ironic_bare_metal_networks_info |
| |
| - name: Assert that we match a single network only |
| ansible.builtin.assert: |
| that: |
| - ironic_bare_metal_networks_info.networks | length == 1 |
| fail_msg: "Expected exactly one network, but found {{ ironic_bare_metal_networks_info.networks | length }}" |
| success_msg: "Successfully matched a single network" |
| run_once: true |
| |
| - name: Set fact with bare metal network information |
| ansible.builtin.set_fact: |
| ironic_bare_metal_network: "{{ ironic_bare_metal_networks_info.networks[0] }}" |