From 6ab5112eb207cd2f87956f1c574d0b70236ef2e3 Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Thu, 9 Aug 2018 12:13:46 +0300 Subject: [PATCH] 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 --- extraconfig/pre_network/boot_param_tasks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extraconfig/pre_network/boot_param_tasks.yaml b/extraconfig/pre_network/boot_param_tasks.yaml index 0d202d1858..827319b80f 100644 --- a/extraconfig/pre_network/boot_param_tasks.yaml +++ b/extraconfig/pre_network/boot_param_tasks.yaml @@ -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