From d9db9714d861081e65e5a34e9b8285c42fae230c Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sat, 15 Dec 2018 11:09:49 -0800 Subject: [PATCH] Handle systems where the main if is not eth0 a bit better ifcfg.j2 has a pretty awkward assumption that the interface connected to the infra network will be eth0 (or enc900) - it only includes the GATEWAY, DOMAIN and DNS1/DNS2 lines if the interface is one of those two. It seems we were trying quite hard to make eth0 always be "the interface", but now that's been broken in a few systems. enc900 was added as apparently that's what the main interface is called on some s390 boxes; on openqa-ppc64le-01 the if that's connected is eth2 (eth0 is present, but not connected), and on the new qa01 and qa02, it's em3 (according to smooge, we have to use 'predictable' interface names on those boxes as the old names really *do* get assigned to different interfaces on each boot). So since we now have several different cases where the 'eth0' assumption doesn't hold, let's build a slightly better system for handling it. This replaces ifcfg.j2's hard-coded list with a variable, and sets the default value of the variable to the two names ifcfg.j2 handled before: [ 'eth0', 'enc900' ]. This allows the systems where the main interface is *not* one of these to set the variable accordingly, and hopefully that'll give them correct ifcfg files. This *should* solve the problem of openqa-ppc64le-01.qa and qa01 and qa02 constantly dropping out of network connectivity any time they got rebooted or the network plays got run. Signed-off-by: Adam Williamson --- inventory/group_vars/all | 7 +++++++ inventory/host_vars/openqa-ppc64le-01.qa.fedoraproject.org | 2 ++ inventory/host_vars/qa01.qa.fedoraproject.org | 3 +++ inventory/host_vars/qa02.qa.fedoraproject.org | 3 +++ roles/base/templates/ifcfg.j2 | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/inventory/group_vars/all b/inventory/group_vars/all index 6d84dc62b1..4d6560e4bd 100644 --- a/inventory/group_vars/all +++ b/inventory/group_vars/all @@ -55,6 +55,13 @@ mem_size: 2048 num_cpus: 2 lvm_size: 20000 +# on MOST infra systems, the interface connected to the infra network +# is eth0. but not on quite ALL systems. e.g. on s390 boxes it's enc900, +# on openqa-ppc64le-01.qa it's eth2 for some reason, and on qa01.qa and +# qa02.qa it's em3. currently this only affects whether GATEWAY, DOMAIN +# and DNS1/DNS2 lines are put into ifcfg-(device). +ansible_ifcfg_infra_net_devices: [ 'eth0', 'enc900' ] + # Default netmask. Almost all our phx2 nets are /24's with the # exception of 10.5.124.128/25. Almost all of our non phx2 sites are # less than a /24. diff --git a/inventory/host_vars/openqa-ppc64le-01.qa.fedoraproject.org b/inventory/host_vars/openqa-ppc64le-01.qa.fedoraproject.org index bf3ce9d2db..1b545a4b07 100644 --- a/inventory/host_vars/openqa-ppc64le-01.qa.fedoraproject.org +++ b/inventory/host_vars/openqa-ppc64le-01.qa.fedoraproject.org @@ -1,5 +1,7 @@ --- freezes: false +# the if connected to the infra network on this box is eth2, not eth0 +ansible_ifcfg_infra_net_devices: [ 'eth2' ] gw: 10.5.131.254 dns: 10.5.126.21 eth2_ip: 10.5.131.73 diff --git a/inventory/host_vars/qa01.qa.fedoraproject.org b/inventory/host_vars/qa01.qa.fedoraproject.org index b9c991227d..856ad71e58 100644 --- a/inventory/host_vars/qa01.qa.fedoraproject.org +++ b/inventory/host_vars/qa01.qa.fedoraproject.org @@ -5,6 +5,9 @@ sudoers: "{{ private }}/files/sudo/qavirt-sudoers" nrpe_procs_warn: 1400 nrpe_procs_crit: 1600 + +# the if connected to the infra network on this box is em3, not eth0 +ansible_ifcfg_infra_net_devices: [ 'em3' ] em3_ip: 10.5.124.151 em3_nm: 255.255.255.0 gw: 10.5.124.254 diff --git a/inventory/host_vars/qa02.qa.fedoraproject.org b/inventory/host_vars/qa02.qa.fedoraproject.org index 9cc5b4fa0a..9122800412 100644 --- a/inventory/host_vars/qa02.qa.fedoraproject.org +++ b/inventory/host_vars/qa02.qa.fedoraproject.org @@ -5,6 +5,9 @@ sudoers: "{{ private }}/files/sudo/qavirt-sudoers" nrpe_procs_warn: 1400 nrpe_procs_crit: 1600 + +# the if connected to the infra network on this box is em3, not eth0 +ansible_ifcfg_infra_net_devices: [ 'em3' ] em3_ip: 10.5.124.152 em3_nm: 255.255.255.0 gw: 10.5.124.254 diff --git a/roles/base/templates/ifcfg.j2 b/roles/base/templates/ifcfg.j2 index 9656c35e4d..2f334be67b 100644 --- a/roles/base/templates/ifcfg.j2 +++ b/roles/base/templates/ifcfg.j2 @@ -6,7 +6,7 @@ SUBCHANNELS="0.0.0900,0.0.0901,0.0.0902" NETTYPE="qeth" OPTIONS="layer2=1 portno=0" {% endif %} -{% if item == "eth0" or item == "enc900" %} +{% if item in ansible_ifcfg_infra_net_devices %} GATEWAY="{{gw}}" DOMAIN="phx2.fedoraproject.org vpn.fedoraproject.org fedoraproject.org" DNS1="{{ dns1 }}"