Skip to content

Commit

Permalink
Fixing so localhost hosts file entry is not lost when updating hostna…
Browse files Browse the repository at this point in the history
…me. Addresses Issue hashicorp#2383.
  • Loading branch information
nmische committed Oct 17, 2013
1 parent 57e9532 commit 0c23874
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/guests/ubuntu/cap/change_host_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.change_host_name(machine, name)
# 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 ]")
Expand Down

0 comments on commit 0c23874

Please sign in to comment.