From 80006251f422a8d534ff9bafa0e0c45d9c98143c Mon Sep 17 00:00:00 2001 From: Joe Doss Date: Mon, 17 Sep 2018 13:30:55 -0500 Subject: [PATCH] Add in logic to restart NetworkManager if it is enabled. --- plugins/guests/redhat/cap/change_host_name.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb index 55fcdc4b4..8f3265003 100644 --- a/plugins/guests/redhat/cap/change_host_name.rb +++ b/plugins/guests/redhat/cap/change_host_name.rb @@ -29,7 +29,13 @@ module VagrantPlugins } # Restart network - service network restart + if (test -f /etc/init.d/network && /etc/init.d/network status &> /dev/null ); then + service network restart + elif (test -f /usr/lib/systemd/system/NetworkManager.service && systemctl is-enabled NetworkManager.service &> /dev/null ); then + systemctl restart NetworkManager.service + else + printf "Could not restart the network to set the new hostname!\n" + fi EOH end end