From 4b55e123025b22edce5fadbe6902fc4d34331c21 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 8 Feb 2018 18:16:53 -0500 Subject: [PATCH] cobbler: Only write network config for our routable NIC Signed-off-by: David Galloway --- roles/cobbler/templates/snippets/cephlab_rc_local | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/roles/cobbler/templates/snippets/cephlab_rc_local b/roles/cobbler/templates/snippets/cephlab_rc_local index a08b9619..e9d0c8df 100644 --- a/roles/cobbler/templates/snippets/cephlab_rc_local +++ b/roles/cobbler/templates/snippets/cephlab_rc_local @@ -37,15 +37,21 @@ if [ ! -f /.cephlab_net_configured ]; then # Don't bail if NIC fails to come up set +e ifup $nic - if [ $? -ne 0 ]; then - # If the NIC failed to DHCP, delete its ifcfg script. Must be static or tagged - rm -f /etc/sysconfig/network-scripts/ifcfg-$nic +#end raw + if ! timeout 1s ping -I $nic -nq -c1 $http_server 2>&1 >/dev/null; then +#raw + # If we can't ping our Cobbler host, remove the DHCP config for this NIC. + # It must either be on a non-routable network or has no reachable DHCP server. ifdown $nic + rm -f /etc/sysconfig/network-scripts/ifcfg-$nic + sed -i "/$nic/d" /etc/network/interfaces fi - # Go back to bailing if anything above fails on the next NIC + # Go back to bailing if anything fails bringing the next NIC up set -e # Write our lockfile so this only gets run on firstboot touch /.cephlab_net_configured + # Break out of the loop once we've found our routable NIC + break else # Take the NIC back down if it's not connected ifconfig $nic down -- 2.47.3