From 4bdcbc1088530a7b03cb1075142bf9e7bff63c13 Mon Sep 17 00:00:00 2001 From: Vlastimil Holer Date: Thu, 4 Apr 2019 14:08:31 +0200 Subject: [PATCH] B #3080: Packet provision of CentOS 7 on c2.medium fails --- .../ansible/roles/ddc/tasks/clean_netconfigs.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/share/oneprovision/ansible/roles/ddc/tasks/clean_netconfigs.yml b/share/oneprovision/ansible/roles/ddc/tasks/clean_netconfigs.yml index 4001a8d677f..053f03306c2 100644 --- a/share/oneprovision/ansible/roles/ddc/tasks/clean_netconfigs.yml +++ b/share/oneprovision/ansible/roles/ddc/tasks/clean_netconfigs.yml @@ -5,6 +5,7 @@ shell: | ip link >/dev/null || exit 1 + CHANGED='' for FILE in ifcfg-*; do # skip interfaces disabled "on boot" if grep -q -i '^ONBOOT=["'\'']no'; then @@ -17,9 +18,21 @@ # if interface does not exist, disable configuration if ! ip link show ${IFACE} >/dev/null 2>&1; then + CHANGED=yes mv ${FILE} disabled-${FILE} fi done + + # As a result of obsolete configuration, the network service + # could end up in the failed state. Restart of the networking + # might fail later, because only service start is triggered + # (without prior stop). We try to manually put the interfaces down, + # and restart the networking to fix the service state. + # https://github.com/OpenNebula/one/issues/3080 + if [ -n "${CHANGED}" ] && systemctl is-failed network.service >/dev/null 2>&1; then + ifdown ifcfg-* || : + systemctl restart network.service + fi args: executable: /bin/bash chdir: /etc/sysconfig/network-scripts