plugins/guests/redhat/cap/change_host_name.rb in vagrant-unbundled-2.2.10.0 vs plugins/guests/redhat/cap/change_host_name.rb in vagrant-unbundled-2.2.14.0

- old
+ new

@@ -13,12 +13,16 @@ if !comm.test("hostname -f | grep '^#{name}$'", sudo: false) basename = name.split('.', 2)[0] comm.sudo <<-EOH.gsub(/^ {14}/, '') # Update sysconfig - sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network + if [ -f /etc/sysconfig/network ]; then + sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network + fi # Update DNS - sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{basename}\"/' /etc/sysconfig/network-scripts/ifcfg-* + find /etc/sysconfig/network-scripts -maxdepth 1 -type f -name 'ifcfg-*' | xargs -r sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{basename}\"/' + # Set the hostname - use hostnamectl if available + echo '#{name}' > /etc/hostname EOH if hostnamectl?(comm) comm.sudo("hostnamectl set-hostname --static '#{name}' ; " \ "hostnamectl set-hostname --transient '#{name}'")