guests/rhel: Use FQDN for hostname

Refs: https://lukas.zapletalovi.com/2011/12/setting-hostname-properly-in-fedora-and.html
This commit is contained in:
Seth Vargo 2016-06-22 19:31:12 -07:00
parent cf91bcf029
commit 336cb3319c
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 3 additions and 3 deletions

View File

@ -8,10 +8,10 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false) if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0] basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, "") comm.sudo <<-EOH.gsub(/^ {14}/, "")
echo '#{basename}' > /etc/hostname echo '#{name}' > /etc/hostname
hostname -F /etc/hostname hostname -F /etc/hostname
hostnamectl set-hostname --static '#{basename}' hostnamectl set-hostname --static '#{name}'
hostnamectl set-hostname --transient '#{basename}' hostnamectl set-hostname --transient '#{name}'
# Remove comments and blank lines from /etc/hosts # Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts