Foreman dhcpd.conf multiple networks

Problem:
dhcpd.cong gets over-written whenever foreman-installer is run.

Foreman and Proxy versions:
3.6 /4.8

We ran foreman-installer with the foreman-proxy-dhcp flags to add the main network details in. The problem is we have 3 network blocks to add in, so we added the 2 extra network subnet details into dhcpd.conf which gets overwritten by foreman-installer each time.
Can we add all network details using foreman-installer or will it only accept one?
We also have the network details saved in subnets on foreman - but I presume this does not get looked at when dhcpd.conf is populated…

At work we manage our own dhcp server because of this exact reason.

hmm, i’d be a little concerned if Foreman can’t ‘handle’ multiple networks.

I may try and re-run the installer command but with all 3 networks (and dchp ranges) in and see how it responds.

If it fails, then we will just have to add manually to dhcpd.conf, restart, then remember to add again if we ever run foreman-installer :smile:

In my environment my Foreman server is on the 192.168.30.x/24 network. In order to provision servers from other subnets I put the subnets in /etc/foreman-installer/custom-hiera.yaml and created the subnets with the “hammer subnet create” command.

For the custom-hiera.yaml configuration, do not include the subnet specified with the --foreman-proxy-dhcp-network and -foreman-proxy-dhcp-subnets options of the foreman-installer command.

Example custom-hiera.yaml (spacing is important in this file),

/bin/cat << EOF >>  /etc/foreman-installer/custom-hiera.yaml
dhcp::pools:
 nfs.lan:
   network: 192.168.10.0
   mask: 255.255.255.0
   range: 192.168.10.2 192.168.10.254

 vmware.lan
   network: 192.168.11.0
   mask: 255.255.255.0
   gateway: 192.168.11.1
   range: 192.168.11.2 192.168.11.254
EOF

For the “hammer subnet create command”, include the subnet specified with the --foreman-proxy-dhcp-network and -foreman-proxy-dhcp-subnets options of the foreman-installer command.

Example hammer subnet create commands,

hammer subnet create \
  --name 192.168.10.0
  --boot-mode Static \
  --description nfs \
  --dh cp-id 1 \
  --domains local.net \
  --ipam None \
  --locations Texas \
  --mask 255.255.255.0 \
  --mtu 9000 \
  --network 192.168.10.0 \
  --organizations MyOrg \
  --tftp-id 1

hammer subnet create \
  --name 192.168.11.0
  --boot-mode Static \
  --description vmware \
  --dh cp-id 1 \
  --dns-primary 192.168.1.1 \
  --dns-secondary 192.168.1.2 \
  --domains local.net \
  --gateway 192.168.11.1 \
  --ipam None \
  --locations Texas \
  --mask 255.255.255.0 \
  --mtu 1500 \
  --network 192.168.11.0 \
  --network-type IPv4 \
  --organizations MyOrg \
  --tftp-id 1

I don’t remember if I had to run the foreman-installer command again or restart dhcpd for the changes to take affect.

oh very nice - i’ll give it a shot! havent had chance to try and add 3 networks/subnets using the installer, so may try that as well and report back

ok, can confirm that adding more than 1 dhcp details in foreman-installer does break things, seems to only accept one.

as for the above approach - I’ve saved our dhcp details in the custom-hiera, and didnt need to create the subnets as they already exist in Foreman. When I re-run foreman-installer it does not overwrite the exisiting dhcpd.conf file containing our extra networks - which is good! However, its populated with the comments from before I changed the custom-hiera, so I’m thinking that just having data in the custom file is enough for it to not overwrite?

I will keep the snapshot we have and run a test build next week, to make sure all is OK still