PXE discovery hostname from DHCP

I’m using Foreman without DHCP, as I have no control over my organization’s DHCP server. There is a custom interface to the DHCP system which allows me to select a target PXEboot server for a specific host when registering the host. When registering a host with this system, I also specify the hostname, so before doing anything with Foreman the organization’s DHCP server is already able to set up the correct hostname (as well as PXEboot server to boot from).

I would like any hostname used by Foreman to be in sync with what the DHCP server provides anyway.

By default, when discovering a host Foreman seems to assign a hostname with the pattern “macADDRESS”. I am able to change this pattern, but I can’t seem to find a fact exposed by the Discovery image that would allow me to set the newly discovered host’s hostname in Foreman to the hostname that the DHCP server would assign to it anyway.

Expected outcome:
When creating a discovery rule, I’d expect some fact provided by the Discovery image’s facter that allows me to set the newly discovered host’s hostname to the hostname that the DHCP server assigns to it.

Foreman and Proxy versions:
1.21 / 1.21

FDI exposes all info exposed by NetworkManager: https://github.com/theforeman/foreman-discovery-image/blob/master/root/usr/share/fdi/facts/discovery-facts.rb#L172-L202

You should see nmprimary_dhcp4_option_domain_name for example. On top of that FDI exposes nmprimary_dhcp4_option_fqdn which should be full FQDN of the host.

If you don’t see those login to your discovered host and create a custom fact, I will gladly put it into the next release if it’s generic enough.

Found it! Many thanks!

1 Like