From 0c238741d34cdf7b04ad157b6b3320127ea13cef Mon Sep 17 00:00:00 2001 From: Nathan Mische Date: Thu, 17 Oct 2013 12:56:59 -0400 Subject: [PATCH] Fixing so localhost hosts file entry is not lost when updating hostname. Addresses Issue #2383. --- plugins/guests/ubuntu/cap/change_host_name.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/ubuntu/cap/change_host_name.rb b/plugins/guests/ubuntu/cap/change_host_name.rb index bd302ad6f..2213b41df 100644 --- a/plugins/guests/ubuntu/cap/change_host_name.rb +++ b/plugins/guests/ubuntu/cap/change_host_name.rb @@ -22,7 +22,7 @@ module VagrantPlugins # hosts should resemble: # 127.0.0.1 localhost host.fqdn.com host # 127.0.1.1 host.fqdn.com host - comm.sudo("sed -ri 's@^(([0-9]{1,3}\.){3}[0-9]{1,3})\\s+(localhost)\\b.*$@\\1\\t#{name} #{name.split('.')[0]} \\3@g' /etc/hosts") + comm.sudo("sed -ri 's@^(([0-9]{1,3}\.){3}[0-9]{1,3})\\s+(localhost)\\b.*$@\\1\\t\\3 #{name} #{name.split('.')[0]}@g' /etc/hosts") comm.sudo("sed -ri 's@^(([0-9]{1,3}\.){3}[0-9]{1,3})\\s+(#{old.split('.')[0]})\\b.*$@\\1\\t#{name} #{name.split('.')[0]}@g' /etc/hosts") if comm.test("[ `lsb_release -c -s` = hardy ]")