From bbcddb64990b037b7a3c8c18d3f65d3b2071679c Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Wed, 22 Jun 2016 18:31:44 -0700 Subject: [PATCH] guests/atomic: Search for FQDN hostname --- plugins/guests/atomic/cap/change_host_name.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/guests/atomic/cap/change_host_name.rb b/plugins/guests/atomic/cap/change_host_name.rb index 70e936321..9f4b7c44f 100644 --- a/plugins/guests/atomic/cap/change_host_name.rb +++ b/plugins/guests/atomic/cap/change_host_name.rb @@ -5,19 +5,19 @@ 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 + # Remove comments and blank lines from /etc/hosts + sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts -# Prepend ourselves to /etc/hosts -grep -w '#{name}' /etc/hosts || { - sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts -} -EOH + # Prepend ourselves to /etc/hosts + grep -w '#{name}' /etc/hosts || { + sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts + } + EOH end end end