Mohammed Naser | 298f027 | 2024-07-29 18:43:25 -0400 | [diff] [blame] | 1 | # Copyright (c) 2022 VEXXHOST, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | - name: Gather information about a bare metal network |
| 16 | run_once: true |
| 17 | openstack.cloud.networks_info: |
| 18 | cloud: atmosphere |
| 19 | # Network settings |
| 20 | name: "{{ ironic_bare_metal_network_name }}" |
| 21 | register: ironic_bare_metal_networks_info |
| 22 | |
| 23 | - name: Assert that we match a single network only |
| 24 | ansible.builtin.assert: |
| 25 | that: |
Mohammed Naser | 8ccabb6 | 2025-02-05 13:20:09 -0500 | [diff] [blame] | 26 | - ironic_bare_metal_networks_info.networks | length == 1 |
| 27 | fail_msg: "Expected exactly one network, but found {{ ironic_bare_metal_networks_info.networks | length }}" |
Mohammed Naser | 298f027 | 2024-07-29 18:43:25 -0400 | [diff] [blame] | 28 | success_msg: "Successfully matched a single network" |
| 29 | run_once: true |
| 30 | |
| 31 | - name: Set fact with bare metal network information |
| 32 | ansible.builtin.set_fact: |
Mohammed Naser | 8ccabb6 | 2025-02-05 13:20:09 -0500 | [diff] [blame] | 33 | ironic_bare_metal_network: "{{ ironic_bare_metal_networks_info.networks[0] }}" |