Fix interfaces in boot_param_tasks

Ansible stores all interfaces with _ in facts. It's very easy to check by
running 'ansible -i inv all -m setup'. This patch adds replace - with _ to find
interface properly in facts.

Change-Id: Id290143d8a41964806ca9c5be4d7103a3833cb37
Closes-Bug: #1786212
This commit is contained in:
Sergii Golovatiuk 2018-08-09 12:13:46 +03:00
parent 575c08eb4f
commit 6ab5112eb2
1 changed files with 2 additions and 2 deletions

View File

@ -72,10 +72,10 @@
when:
- item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
# Ensure the interface information is available in the facts
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') ] is defined
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ] is defined
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') ]['ipv4'] is undefined
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ]['ipv4'] is undefined
with_items:
- "{{ ifcfg_files.files }}"
become: true