harvester-installer
harvester-installer copied to clipboard
Add ability to set hostname via DHCPv4 client
Problem: We need to provide the option of allowing system hostnames to be set via DHCP.
Solution: This adds a boolean config option, os.dhclient_set_hostname, which maps to DHCLIENT_SET_HOSTNAME in /etc/sysconfig/network/dhcp.
When running the installer interactively, there's a new "Set via DHCP" drop down field on the hostname page. The default is "no".
If the user selects "yes", this will later be shown on the confirmation screen as "hostname: XXXX (will be set via DHCP)", to indicate that the provided hostname will be overridden by DHCP:
For automated installs, either set os.dhclient_set_hostname: true
in the config yaml, or pass harvester.os.dhclient_set_hostname=true
as a kernel command line argument.
In order for this setting to take effect, your DHCP server needs to be configured to send the host name option to the client. For more information see man dhcpd.conf
(look for "option host-name" and "use-host-decl-names on").
Note that even if os.dhclient_set_hostname is set to true, we still require the user to provide a hostname during installation, because that will be written to /etc/hostname and be used by the system briefly early in the boot process, before DHCP does its thing.
Related Issue: https://github.com/harvester/harvester/issues/1444
Test plan:
- Configure a DHCP server to set the host name option (TBD: add more details here, possibly including tweaks to ipxe-examples)
- Boot the installer, but leave "Set via DHCP" set to "no"
- Verify that whatever hostname the DHCP server wants to set, doesn't get set.
- Repeat the above, but set "Set via DHCP" to "yes"
- Verify that whatever hostname the DHCP server wants to set, does get set, both during installation (after network config is applied), and then subsequently once the system comes up for real.
What will happen if the dhcp server doesn't set the hostname for the IP? Will it fallback to manual hostname setting and give a warning or simply bypass?
What will happen if the dhcp server doesn't set the hostname for the IP? Will it fallback to manual hostname setting and give a warning or simply bypass?
It just falls back to the manual hostname setting. AFAICT there's no warnings anywhere if the DHCP server doesn't send a hostname. That would be up to wickedd and/or wickedd-dhcp4 to do, but from looking at the wicked code and experimenting with extra debugging information turned on, wicked doesn't seem to really care whether or not the DHCP server sends a hostname or not. If the server does send a hostname and DHCLIENT_SET_HOSTNAME is set to "yes", it will be used, but it won't complain at all if either of those things aren't true.
Closing in favour of #726