"Switch-based Discovery" with Foreman


as my previous posts show, I’ve been learning and asking much these days about Foreman and Puppet concepts and, now that I’m more fluent with those and that I’ve read the documentation again, I can step a bit closer to my goal : I’d like to do with Foreman (and its discovery plugin) what I did with xCAT :

Note that I don’t want nor need to reinvent the wheel and maybe it has already been done :wink:

I was using xCAT to bootstrap HPC nodes (lots of them, around 400) installation which basically consisted of configuring the BMC and installing a minimal OS with root ssh key just to be able to further provision the node using Ansible (thus as soon as possible).

My plan is to do, if not the same, something similar in effect with Foreman, ideally using Ansible as well but that could be done outside Foreman if needed.

One strong constraint though is that I want hostnames aligned with physical topology of the machines.

  • my nodes are blades inside 2U chassis, each one having 4 of them inside
  • my nodes are named say server-xxx, x being a digit

I want the numbers to be in sequence inside a chassis (following the manufacturer blade ordering) and from bottom to top in the cabinet accross the chassis. For instance to top bottom chassis would hold server-400, server-401, server-402, server-403 in a specific order and the chassis above it would host server-404 to server 407 in the same order, …etc…

One way to do it is to write down MAC addresses and statically assign hostnames in DHCP (mac address <-> hostname mapping in dhcpd.conf). But it could be very cumbersome for a human to do.

xCAT provides what it calls Switched-based Discovery, which basically allows to do the same but writing down only the switch/port the server is connected to, which is easiest to do in a consistent manner for a human. As a matter of fact, we can easily have a switch/port <-> server physical layout delegated to some dedicated team or subcontractor.

Basically, a database table inside xCAT stores switch/port <-> hostname associations and the corresponding MAC address is discovered by a pxe booted discovery image using SNMP.

Obviously, the idea with Foreman would be to use the Discovery plugin and LLD facts, if any :
Does this make sense ? If so, would auto-provisionning rules be sufficient to play the role of that swith/port <-> servername table or would I have to write some kind of external hook/script/plugin to do just that
(and if so, could you point me in what direction I should look ?) ?

Thank you


Yes, discovery plugin is perfect fit, assuming that you already have the LLDP facts present you need to build your hostname from. Try to boot discovery on such host, can you identify facts which you can build hostname from?

Then you can either use discovery_fact setting to use the fact if it is only single one, or use discovery rules to construct arbitrary name out of one or more facts.

Thanks for your answer.
I’ll give it a try. In the meantime, I tried to split my setup on 3 hosts and encoutered other problems :wink: