Fix deployment failure due to wrong check on network interface

When deployment interface has one or several dashes in its name
like br-xxx the corresponding ansible fact is ansible_br_xxx
(all underscores) not ansible_br-xxx (even though ansible_interfaces
list contains br-xxx). Deployment will therefore fail if provisioning
interface name matches this pattern but it should succeed.
This patch fixes this issue.

Change-Id: I55237efec922ef7764e488672046a0994bcdc9b2
This commit is contained in:
Olivier Bourdon 2018-03-27 17:59:34 +02:00
parent e29107b48e
commit 74517a8d67
1 changed files with 5 additions and 2 deletions

View File

@ -13,18 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: "Interface name fact"
set_fact:
provisioning_itf_name: "{{ ('ansible_' ~ network_interface) | regex_replace('-', '_') }}"
- name: "Fail if the network interface does not exist"
fail:
msg: >
The configured network interface {{ network_interface }} does
not exist
when: ('ansible_' ~ network_interface) not in hostvars[inventory_hostname]
when: provisioning_itf_name not in hostvars[inventory_hostname]
- name: "Fail if the network interface has no IP address assigned"
fail:
msg: >
The configured network interface {{ network_interface }} does
not have an IP address assigned
when: not hostvars[inventory_hostname]['ansible_' ~ network_interface].get('ipv4', {}).get('address')
when: not hostvars[inventory_hostname][provisioning_itf_name].get('ipv4', {}).get('address')
# DEPRECATED: enabled_drivers, pxe_drivers, and enable_pxe_drivers has
# been deprecated and will be removed in the Rocky release. Please consult
# enabled_hardware_types.