exiting 1 if anything breaks doesn't do us any favors. What ends up happening is it seems like the system was reimaged but users can't log in because ansible never gets run. Only admins can log in as the cm user to investigate and even then, since we're outputting to the SOL console, one has to be watching the SOL console for errors when a system is reprovisioned with Cobbler.
If the system fails to get its networking set up, then the ansible tasks won't be able to run anyway. If ansible fails, there's still the `|| true` at the end so, again, no purpose in having `set -e` anywhere in this script.
Signed-off-by: David Galloway <dgallowa@redhat.com>
# Redirect rc.local output to our console so it's in teuthology console logs
exec 2> /dev/ttyS1
exec 1>&2
-set -ex
+set -x
{% if rclocal_nameserver is defined %}
if [ ! -f /.cephlab_net_configured ]; then
else
echo -e "DEVICE=$nic\nBOOTPROTO=dhcp\nONBOOT=yes" > /etc/sysconfig/network-scripts/ifcfg-$nic
fi
- # Don't bail if NIC fails to go down or come up
- set +e
# Bounce the NIC so it gets a DHCP address
ifdown $nic
ifup $nic
ifdown $nic
rm -f /etc/sysconfig/network-scripts/ifcfg-$nic
sed -i "/$nic/d" /etc/network/interfaces
- # Go back to bailing if anything fails bringing the next NIC up
- set -e
else
# We found our routable NIC!
# Write our lockfile so this only gets run on firstboot
done
fi
-# Don't error out if the `ip` command returns rc 1
-set +e
-
attempts=0
myips=""
until [ "$myips" != "" ] || [ $attempts -ge 10 ]; do
sleep 1
done
-set -e
-
if [ -n "$myips" ]; then
for ip in $myips; do
if timeout 1s ping -I $ip -nq -c1 {{ rclocal_nameserver }} 2>&1 >/dev/null; then