I am trying to add a new host using foreman and the proxmox-plugin.
Now I am getting:
Create DHCP Settings for frank-soroka.test.zone task failed with the following error: ERF12-6899 [ProxyAPI::ProxyException]: Unable to set DHCP entry ([RestClient::Conflict]: 409 Conflict) for proxy https://foreman.test.zone:8443/dhcp
If I check out the logs, I can see
2021-04-12T19:27:40 3fa2988a [W] Error details for Record 45.133.11.0/45.133.11.147 already exists: <Proxy::DHCP::Collision>: Record 123.123.123.0/123.123.123.147 already exists
/usr/share/foreman-proxy/modules/dhcp_common/server.rb:157:in `add_record'
/usr/share/foreman-proxy/modules/dhcp_common/isc/omapi_provider.rb:29:in `add_record'
# READ: This file was written the foreman-installer and not by the Foreman
# application. Any updates to subnets in the Foreman database are not
# automatically reflected in this configuration and vice versa. Configuration
# updates like DNS servers or adding/removing subnets must be done both in
# Foreman application and in this configuration preferably via
# foreman-installer. Use custom-hiera.yaml for multiple subnets.
omapi-port 7911;
default-lease-time 43200;
max-lease-time 86400;
not authoritative;
ddns-update-style none;
option domain-name "test.zone";
option domain-name-servers 8.8.8.8;
option ntp-servers none;
allow booting;
allow bootp;
option fqdn.no-client-update on; # set the "O" and "S" flag bits
option fqdn.rcode2 255;
option pxegrub code 150 = text ;
# required for UEFI HTTP boot
if substring(option vendor-class-identifier, 0, 10) = "HTTPClient" {
option vendor-class-identifier "HTTPClient";
}
option architecture code 93 = unsigned integer 16;
if exists user-class and option user-class = "iPXE" {
filename "http://fm1.test.zone/unattended/iPXE";
} elsif option architecture = 00:06 {
filename "grub2/shim.efi";
} elsif option architecture = 00:07 {
filename "grub2/shim.efi";
} elsif option architecture = 00:09 {
filename "grub2/shim.efi";
} else {
filename "pxelinux.0";
}
log-facility local7;
include "/etc/dhcp/dhcpd.hosts";
# test.zone
subnet 123.123.123.0 netmask 255.255.255.224 {
pool
{
range 123.123.123.137 123.123.123.158;
}
option subnet-mask 255.255.255.224;
option routers 123.123.123.129;
}
I don’t know which installer-option was setting up this lines:
subnet 123.123.123.0 netmask 255.255.255.224 {
pool
{
range 123.123.123.137 123.123.123.158;
}
option subnet-mask 255.255.255.224;
option routers 123.123.123.129;
}
but if I change them to
subnet 123.123.123.128 netmask 255.255.255.224 {
pool
{
range 123.123.123.137 123.123.123.158;
}
option subnet-mask 255.255.255.224;
option routers 123.123.123.129;
}
These are the “dhcp” options. The installer is only capable of creating configuration of single subnet per proxy, however there is a way to define more than one via Hiera YAML configuration files. It is in the docs.
Although I don’t have the link to the documentation, this is a snippet of how I setup additional dhcp pools. I am running Foreman 3.4 with Katello 4.6.
# The foreman-installer options allow only for a single DHCP subnet or DNS domain.
# One way to define more than one subnet is by using a custom configuration file.
# For every additional subnet or domain, create an entry in /etc/foreman-installer/custom-hiera.yaml file:
#
cp /etc/foreman-installer/custom-hiera.yaml /etc/foreman-installer/custom-hiera.yaml.$(date +%s)
# Do not include 192.168.0.0/24 because it was specified with the foreman-installer command as the initial network.
cat << EOF >> /etc/foreman-installer/custom-hiera.yaml
dhcp::pools:
eth1.lan:
network: 192.168.1.0
mask: 255.255.255.0
gateway: 192.168.1.1
range: 192.168.1.2 192.168.1.254
storage.lan:
network: 192.168.10.0
mask: 255.255.254.0
gateway: 192.168.10.1
range: 192.168.10.2 192.168.11.254
physical.lan:
network: 192.168.31.0
mask: 255.255.255.0
gateway: 192.168.31.1
range: 192.168..31.2 192.168.31.254
EOF
# You must add information for each of your subnets to Foreman server because Foreman configures interfaces for new hosts.
# Infrastructure > Subnets
#
hammer subnet create \
--name 192.168.0.0 \
--boot-mode Static \
--description Primary \
--dhcp-id 1 \
--dns-primary 192.168.0.12 \
--dns-secondary 192.168.1.12 \
--domains local.net \
--from 192.168.0.2 \
--gateway 192.168.0.1 \
--ipam DHCP \
--locations location1 \
--mask 255.255.255.0 \
--mtu 1500 \
--network 192.168.0.0 \
--network-type IPv4 \
--organizations Customer \
--tftp-id 1 \
--to 192.168.0.254
hammer subnet create \
--name 192.168.1.0 \
--boot-mode Static \
--description Secondary \
--dhcp-id 1 \
--domains local.net \
--from 192.168.1.2 \
--ipam DHCP \
--locations location1 \
--mask 255.255.255.0 \
--mtu 1500 \
--network 192.168.1.0 \
--organizations Customer \
--tftp-id 1 \
--to 192.168.1.254
hammer subnet create \
--name 192.168.10.0 \
--boot-mode Static \
--description Storage \
--dhcp-id 1 \
--domains local.net \
--from 192.168.10.2 \
--ipam DHCP \
--locations location1 \
--mask 255.255.254.0 \
--mtu 9000 \
--network 192.168.10.0 \
--organizations Customer \
--tftp-id 1 \
--to 192.168.11.254
hammer subnet create \
--name 192.168.31.0 \
--boot-mode Static \
--description Virtual \
--dhcp-id 1 \
--dns-primary 192.168.0.12 \
--dns-secondary 192.168.1.12 \
--domains local.net \
--from 192.168.31.2 \
--ipam DHCP \
--locations location1 \
--mask 255.255.255.0 \
--mtu 1500 \
--network 192.168.31.0 \
--organizations Customer \
--tftp-id 1 \
--to 192.168.31.254
In addition, when creating a host with “hammer host create”, there is a bug where you need to restart dhcp for the dhcp file to be updated properly (and another bug where the build flag needs to be set again, and another bug where the tftpboot initrd and vmlinuz get out of whack). For completeness, here are the commands I use to build a host.