New servers provisioning currently need a Puppet commit to statically set the primary NIC's MAC/hostname/IP mapping in the DHCP config.
This takes time and is error prone. A better option would be to generate it from Netbox data.
The only data not present in Netbox is option pxelinux.pathprefix used when a host needs a different Debian version than the default one.
Physical hosts
Prerequisite is to configure DHCP option 82 (see T221388, and an example of dhcp config), this feature adds the switch interface and interface description to the DHCP request. At this point the switch port is already configured based on Netbox and enabled with Homer.
Then there are several options to configure DHCP. Feel free to add any other options or complete them.
(From a previous discussion with Riccardo)
Cron to generate the config on the install servers
Prerequisite is to add a custom field to the devices, to specify if they need a different than default option pxelinux.pathprefix.
Then have a script that runs regularly and fetch all servers with a planned status as well as a connected cable and generate the matching DHCP configuration.
Downsides are:
- need of an extra Netbox field
- regular querying of Netbox (slow) API
- have to wait for the cron to run before booting the host
Upsides:
- Probably the easiest to setup
- works for multiple hosts in parallel
Generate the config on Netbox hosts and cron to pull it
Slightly similar as above, but workaround the Netbox API limitation by having the config pushed to a git repo (or fetchable via https) on the Netbox hosts.
Cookbook
Pass the hostname(s) and (if not default) option pxelinux.pathprefix as command line arguments.
It will then generate the relevant DHCP config and push them to the relevant install server. Maybe even run the DHCP and display its logs?
Then maybe pause until the operator continues the script and cleanup the config once done.
Upsides:
- Less hard on the Netbox API
- No need for an extra Netbox field
- More control over what's generated
- Can do other checks on the way (maybe
Downside:
- More complex to setup?
- Yet another cookbook to run?
- Might cause race conditions if several persons provision several hosts in parallel?
DHCP Hooks
Prerequisite: upgrade to ISC-DHCP to ISC-KEA, as I can't find a similar feature for ISC-DHCP.
Kea has hooks that could potentially query Netbox in real time. The risk is that Netbox takes too much time to run and the hosts DHCP request times out.
VMs
As we can sync MAC addresses from Ganeti to Netbox, the easier might be to generate a similar config as we have now (so no need of option 82).
And the sre.ganeti.makevm cookbook could take care of updating the config with either one of the choice made above (either force the cron/fetch/etc or generate/push the config directly).