From be90f6b1da85b6dd9e52617f344004cf8253718e Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Thu, 27 Aug 2015 16:44:17 -0400 Subject: [PATCH] Fix Fedora /etc/hosts bug Update so that localhost entries don't get deleted when the hostname gets added to the 127.0.0.1 line. Closes #6202 --- plugins/guests/fedora/cap/change_host_name.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/guests/fedora/cap/change_host_name.rb b/plugins/guests/fedora/cap/change_host_name.rb index 2a93b9de6..f0c95eec6 100644 --- a/plugins/guests/fedora/cap/change_host_name.rb +++ b/plugins/guests/fedora/cap/change_host_name.rb @@ -48,7 +48,7 @@ module VagrantPlugins def update_etc_hosts ip_address = '([0-9]{1,3}\.){3}[0-9]{1,3}' search = "^(#{ip_address})\\s+#{Regexp.escape(current_hostname)}(\\s.*)?$" - replace = "\\1 #{fqdn} #{short_hostname}" + replace = "\\1 #{fqdn} #{short_hostname} \\3" expression = ['s', search, replace, 'g'].join('@') sudo("sed -ri '#{expression}' /etc/hosts") @@ -72,4 +72,4 @@ module VagrantPlugins end end end -end \ No newline at end of file +end