DHCP renewal on Debian/Ubuntu after setting hostname

On Debian and Ubuntu guests, when the new hostname of the guest box is
set, the DHCP client (isc-dhcp-client) won't renew its DHCP lease with
the new hostname. Executing "ifdown -a; ifup -a" to reinitialize all auto
interfaces fixes this issue.

Furthermore, as vagrant will now actually wait until a DHCP lease is
acquired, it is guaranteed that the the correct domainname is set from
DHCP before calling other provisioners like puppet, that rely on it.
This fixes puppet/facter sometimes failing to find the fqdn fact on an
LXC guest when the DHCP server is responding too slow.
This commit is contained in:
Franz Pletz 2013-07-15 11:19:06 +02:00
parent 0dfc6455ae
commit 65f275a5a8
2 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,7 @@ module VagrantPlugins
comm.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
comm.sudo("hostname -F /etc/hostname")
comm.sudo("hostname --fqdn > /etc/mailname")
comm.sudo("ifdown -a; ifup -a")
end
end
end

View File

@ -14,6 +14,7 @@ module VagrantPlugins
comm.sudo("service hostname start")
end
comm.sudo("hostname --fqdn > /etc/mailname")
comm.sudo("ifdown -a; ifup -a")
end
end
end