Merge pull request #2792 from smoyer/redhat_hostname_patch

guests/redhat: use FQDN for hostname
This commit is contained in:
Mitchell Hashimoto 2014-01-08 20:58:59 -08:00
commit 5e835f4201
2 changed files with 18 additions and 11 deletions

View File

@ -49,7 +49,7 @@ module VagrantPlugins
end end
def update_hostname def update_hostname
sudo "hostname #{short_hostname}" sudo "hostname #{fqdn}"
end end
# /etc/hosts should resemble: # /etc/hosts should resemble:

View File

@ -1,9 +1,5 @@
shared_examples 'a partial redhat-like host name change' do shared_examples 'a partial redhat-like host name change' do
shared_examples 'shared between newhostname styles' 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 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-*)) communicator.expect_command(%q(sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1"newhostname"/' /etc/sysconfig/network-scripts/ifcfg-*))
@ -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)) communicator.expect_command(%q(sed -i 's/\\(HOSTNAME=\\).*/\\1newhostname.newdomain.tld/' /etc/sysconfig/network))
described_class.change_host_name(machine, new_hostname) described_class.change_host_name(machine, new_hostname)
end 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 end
context 'when newhostname is simple' do 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)) communicator.expect_command(%q(sed -i 's/\\(HOSTNAME=\\).*/\\1newhostname/' /etc/sysconfig/network))
described_class.change_host_name(machine, new_hostname) described_class.change_host_name(machine, new_hostname)
end 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
end end