From 4d7f15164c8207a9ed1fb04c4e9a021e0cb0c5e6 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Fri, 22 Dec 2017 02:15:04 +0100 Subject: [PATCH] Allow interfaces to be marked as explicitly disabled Signed-off-by: Patrick Uiterwijk --- inventory/group_vars/all | 2 ++ roles/base/templates/ifcfg.j2 | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/inventory/group_vars/all b/inventory/group_vars/all index 016585fe28..f01b94ef63 100644 --- a/inventory/group_vars/all +++ b/inventory/group_vars/all @@ -60,6 +60,8 @@ br0_nm: 255.255.255.0 br1_nm: 255.255.255.0 # Default to managing the network, we want to not do this on select hosts (like cloud nodes) ansible_ifcfg_blacklist: false +# List of interfaces to explicitly disable +ansible_ifcfg_disabled: [] # # The default virt-install works for rhel7 or fedora with 1 nic # diff --git a/roles/base/templates/ifcfg.j2 b/roles/base/templates/ifcfg.j2 index 22102185d7..9036b8c497 100644 --- a/roles/base/templates/ifcfg.j2 +++ b/roles/base/templates/ifcfg.j2 @@ -13,8 +13,12 @@ DNS1="{{ dns1 }}" DNS2="{{ dns2 }}" {% endif %} HWADDR="{{ hostvars[inventory_hostname]['ansible_' + item]['macaddress']|upper }}" +{% if item in ansible_ifcfg_disabled %} +ONBOOT="no" +{% else %} IPADDR="{{ hostvars[inventory_hostname][item + '_ip'] }}" NETMASK="{{ hostvars[inventory_hostname][item + '_nm'] }}" +{% endif %} ONBOOT="yes" TYPE="Ethernet" DEVICE="{{item}}"