guests/arch: Search for FQDN hostname

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

View File

@ -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

View File

@ -0,0 +1,8 @@
Connection=ethernet
Description='A basic IPv6 ethernet connection'
Interface=<%= options[:device] %>
IP6=static
Address=('<%= options[:ip]%>/<%= options[:netmask] %>')
<% if options[:gateway] %>
Gateway='<%= options[:gateway] %>'
<% end %>