guests/atomic: Search for FQDN hostname

This commit is contained in:
Seth Vargo 2016-06-22 18:31:44 -07:00
parent 10b12ce393
commit bbcddb6499
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 10 additions and 10 deletions

View File

@ -5,10 +5,10 @@ module VagrantPlugins
def self.change_host_name(machine, name)
comm = machine.communicate
if !comm.test("hostname | grep -w '#{name}'")
if !comm.test("hostname -f | grep '^#{name}$'")
basename = name.split(".", 2)[0]
comm.sudo <<-EOH
hostnamectl set-hostname '#{name}'
comm.sudo <<-EOH.gsub(/^ {14}/, "")
hostnamectl set-hostname '#{basename}'
# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts