During baremetal provisioning, we need to add a second IP to a second interface on a box. I’ve gotten this to work by first running the discovery build, then getting the host info, the ID of the second interface and assigning an IP by updating that interface with a subnet ID, which then grabs the IP all great like. Problem is for that subnet (set to DHCP for the IPAM), foreman can’t actually reach that subnet so I’m getting duplicated IP assignments. From reading various bits, I guess this can happen as the DHCP server has no way to ping an IP to ensure it’s not used.
I also, on host creation, don’t see any records showing up in the DHCP lease files. So I’m thinking I can just move to Internal DB or Random DB for the IPAM for this one subnet.
To get to my question, I’m wondering where in the database these IPs are stored, what table and format as taking a general look at things I couldn’t guess it.
Also how are these IP values updated, is it only on creation, or on puppet fact update as well?
How does setting to Random DB or Internal DB determine what the next IP to use should be?
If the database is lost will all the assigned IPs for this subnet also be lost, or can it be re-updated from puppet runs / facts that get loaded in as hosts re-run puppet?
Oh and how are the IP’s cleaned up from the database?
I suspect I could answer most of these if I could figure out where in the database these are stored and just run through the scenarios, but any help on this would be much appreciated.
I guess what I’m getting at, is for the most part our foreman DB is pretty ephemeral. After a puppet run and a few sync commands, we can recover any Foreman instance back to a known working state. This is because of the puppet run adding hosts back in. If the Internal DB for IPs doesn’t recover as easily, I need a strategy of backing that up and restoring it if/when the host that is running foreman dies so that we can prevent doubling up IP assignments on provision.
There was a suggestion from a community some time ago - if we added a new check: a DNS check. If there is an existing name present for that IP (PTR) the IP would be considered as used. If you like this feel free to contribute this, should be pretty easy to implement for smart proxy.
Foreman finds the next available IP address from the Subnet range by excluding all IP addresses from the Foreman database randomly. The primary source of data is the database, not DHCP reservations.
That I’m curious about. What part of the database is it looking at to exclude all IPs from? Is this a complicated query to look up all Nics in a particular subnet? I’m just looking for where in the database host x has ip y associated to it. (or where in a series of tables if that turns out to be the case)