Turn network interfaces down before restart

Turning network interfaces down to make sure SSH session was dropped
  on host side.
  More info [here](https://www.packer.io/docs/provisioners/shell.html#handling-reboots)
This commit is contained in:
Martin Dimitrov 2019-07-30 19:56:04 +03:00
parent ce539e2e6d
commit 81bb3a703c

View file

@ -99,4 +99,8 @@ echo '==> Adding workaround for shutdown race condition'
echo '==> Installation complete!'
/usr/bin/sleep 3
/usr/bin/umount ${TARGET_DIR}
# Turning network interfaces down to make sure SSH session was dropped on host.
# More info at: https://www.packer.io/docs/provisioners/shell.html, section - Handling reboots
echo '==> Turning down network interfaces and rebooting'
for i in $(/usr/bin/netstat -i | /usr/bin/tail +3 | /usr/bin/awk '{print $1}'); do /usr/bin/ip link set ${i} down; done
/usr/bin/systemctl reboot