Hostname facts (discovery_hostname)

I’m running Foreman 2.5 with Katello 4.1 on CentOS-8. I am attempting to set a fact to create the hostname with the discovery image, but “Administer → Discovered → Hostname facts” only seems to be able to read top-level facts. I would like to use the “serial_number” from a Dell laptop which is located in “dmi → product → serial_number”, but every syntax I have attempted to use results in “Invalid facts: hash does not contain a valid value for any of the facts in the discovery_hostname setting: …”

If I input “dmi” into the Hostname facts field, it will render the full dmi object as a singular string, so I know the system can read those facts. How can I specify a nested property?

If dmi::product::serial_number does not work I am afraid you found a bug. PR is welcome!

Thank you, lzap. I tried your suggestion and it does, in fact, appear to be a bug. Ruby is one of my weaknesses, so I’ll hold off on the pull request.

What you can do is accept that discovery nodes will have MAC-address naming but then create a discovery rule which can use ERB in hostname, then you can access facts and do your thing for provisioned hosts:

https://docs.theforeman.org/nightly/Provisioning_Guide/index-foreman-el.html#creating-discovery-rules