guests/debian: Set hostname to short value

Refs GH-7488
This commit is contained in:
Seth Vargo 2016-06-22 18:32:33 -07:00
parent 5a372a9942
commit 87d2b7fec8
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 2 additions and 2 deletions

View File

@ -9,11 +9,11 @@ module VagrantPlugins
def self.change_host_name(machine, name)
comm = machine.communicate
if !comm.test("hostname -f | grep -w '#{name}'")
if !comm.test("hostname -f | grep '^#{name}$'")
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, '')
# Set the hostname
echo '#{name}' > /etc/hostname
echo '#{basename}' > /etc/hostname
hostname -F /etc/hostname
# Remove comments and blank lines from /etc/hosts