This was introduced in 1.4.1 with d26c147
.
This PR sets the active hostname back to the name specified in the Vagrantfile (fqdn) and updates the unit tests. Setting it to the short name causes loads of problems while configuring the system. I've had issues with sudoers hostname matching, Weblogic certificate generation and a few others. Even if I changed all of the Chef recipes, the fqdn is set in /etc/sysconfig/network so the active hostname will switch to the fqdn after a reboot.
This commit is contained in:
parent
010874ffad
commit
3964298504
|
@ -34,7 +34,7 @@ module VagrantPlugins
|
|||
def get_current_hostname
|
||||
hostname = ''
|
||||
block = lambda do |type, data|
|
||||
if type == :stdout
|
||||
if type == :stdout
|
||||
hostname += data.chomp
|
||||
end
|
||||
end
|
||||
|
@ -49,8 +49,8 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def update_hostname
|
||||
sudo "hostname #{short_hostname}"
|
||||
end
|
||||
sudo "hostname #{fqdn}"
|
||||
end
|
||||
|
||||
# /etc/hosts should resemble:
|
||||
# 127.0.0.1 host.fqdn.com host localhost ...
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
shared_examples 'a partial redhat-like host name change' do
|
||||
shared_examples 'shared between newhostname styles' do
|
||||
it 'updates hostname on the machine with the new short hostname' do
|
||||
communicator.expect_command(%q(hostname newhostname))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
|
||||
it 'sets dhcp_hostname with the provided short hostname' do
|
||||
communicator.expect_command(%q(sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1"newhostname"/' /etc/sysconfig/network-scripts/ifcfg-*))
|
||||
|
@ -12,7 +8,7 @@ shared_examples 'a partial redhat-like host name change' do
|
|||
|
||||
it 'restarts networking' do
|
||||
communicator.expect_command(%q(service network restart))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,6 +21,11 @@ shared_examples 'a partial redhat-like host name change' do
|
|||
communicator.expect_command(%q(sed -i 's/\\(HOSTNAME=\\).*/\\1newhostname.newdomain.tld/' /etc/sysconfig/network))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
|
||||
it 'updates hostname on the machine with the new hostname' do
|
||||
communicator.expect_command(%q(hostname newhostname.newdomain.tld))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when newhostname is simple' do
|
||||
|
@ -36,6 +37,12 @@ shared_examples 'a partial redhat-like host name change' do
|
|||
communicator.expect_command(%q(sed -i 's/\\(HOSTNAME=\\).*/\\1newhostname/' /etc/sysconfig/network))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
|
||||
it 'updates hostname on the machine with the new hostname' do
|
||||
communicator.expect_command(%q(hostname newhostname))
|
||||
described_class.change_host_name(machine, new_hostname)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,15 +73,15 @@ shared_examples 'mutating /etc/hosts helpers' do
|
|||
let(:expression) { sed_command.sub(%r{^sed -i '\(.*\)' /etc/hosts$}, "\1") }
|
||||
let(:search) { Regexp.new(expression.split('@')[1].gsub(/\\/,'')) }
|
||||
let(:replace) { expression.split('@')[2] }
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'inserting hostname in /etc/hosts' do
|
||||
include_examples 'mutating /etc/hosts helpers'
|
||||
|
||||
|
||||
context 'when target hostname is qualified' do
|
||||
let(:new_hostname) {'newhostname.newdomain.tld'}
|
||||
|
||||
it 'works with a basic file' do
|
||||
it 'works with a basic file' do
|
||||
original_etc_hosts = <<-ETC_HOSTS.gsub(/^ */, '')
|
||||
127.0.0.1 localhost.localdomain localhost
|
||||
::1 localhost6.localdomain6 localhost6
|
||||
|
|
Loading…
Reference in New Issue