Thanks for the explanation!
@lzap So to dig into the templates I used a known and a different, unknown VM:
The intermediate looks good on both:
#!ipxe
# Intermediate iPXE script to report MAC address to Foreman
:net0
isset ${net0/mac} || goto no_nic
dhcp net0 || goto net1
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net0/mac} || goto net1
:net1
isset ${net1/mac} || goto no_nic
dhcp net1 || goto net2
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net1/mac} || goto net2
:net2
isset ${net2/mac} || goto no_nic
dhcp net2 || goto net3
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net2/mac} || goto net3
:net3
isset ${net3/mac} || goto no_nic
dhcp net3 || goto net4
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net3/mac} || goto net4
:net4
isset ${net4/mac} || goto no_nic
dhcp net4 || goto net5
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net4/mac} || goto net5
:net5
isset ${net5/mac} || goto no_nic
dhcp net5 || goto net6
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net5/mac} || goto net6
:net6
isset ${net6/mac} || goto no_nic
dhcp net6 || goto net7
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net6/mac} || goto net7
:net7
isset ${net7/mac} || goto no_nic
dhcp net7 || goto net8
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net7/mac} || goto net8
:net8
isset ${net8/mac} || goto no_nic
dhcp net8 || goto net9
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net8/mac} || goto net9
:net9
isset ${net9/mac} || goto no_nic
dhcp net9 || goto net10
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net9/mac} || goto net10
:net10
isset ${net10/mac} || goto no_nic
dhcp net10 || goto net11
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net10/mac} || goto net11
:net11
isset ${net11/mac} || goto no_nic
dhcp net11 || goto net12
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net11/mac} || goto net12
:net12
isset ${net12/mac} || goto no_nic
dhcp net12 || goto net13
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net12/mac} || goto net13
:net13
isset ${net13/mac} || goto no_nic
dhcp net13 || goto net14
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net13/mac} || goto net14
:net14
isset ${net14/mac} || goto no_nic
dhcp net14 || goto net15
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net14/mac} || goto net15
:net15
isset ${net15/mac} || goto no_nic
dhcp net15 || goto net16
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net15/mac} || goto net16
:net16
isset ${net16/mac} || goto no_nic
dhcp net16 || goto net17
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net16/mac} || goto net17
:net17
isset ${net17/mac} || goto no_nic
dhcp net17 || goto net18
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net17/mac} || goto net18
:net18
isset ${net18/mac} || goto no_nic
dhcp net18 || goto net19
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net18/mac} || goto net19
:net19
isset ${net19/mac} || goto no_nic
dhcp net19 || goto net20
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net19/mac} || goto net20
:net20
isset ${net20/mac} || goto no_nic
dhcp net20 || goto net21
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net20/mac} || goto net21
:net21
isset ${net21/mac} || goto no_nic
dhcp net21 || goto net22
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net21/mac} || goto net22
:net22
isset ${net22/mac} || goto no_nic
dhcp net22 || goto net23
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net22/mac} || goto net23
:net23
isset ${net23/mac} || goto no_nic
dhcp net23 || goto net24
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net23/mac} || goto net24
:net24
isset ${net24/mac} || goto no_nic
dhcp net24 || goto net25
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net24/mac} || goto net25
:net25
isset ${net25/mac} || goto no_nic
dhcp net25 || goto net26
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net25/mac} || goto net26
:net26
isset ${net26/mac} || goto no_nic
dhcp net26 || goto net27
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net26/mac} || goto net27
:net27
isset ${net27/mac} || goto no_nic
dhcp net27 || goto net28
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net27/mac} || goto net28
:net28
isset ${net28/mac} || goto no_nic
dhcp net28 || goto net29
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net28/mac} || goto net29
:net29
isset ${net29/mac} || goto no_nic
dhcp net29 || goto net30
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net29/mac} || goto net30
:net30
isset ${net30/mac} || goto no_nic
dhcp net30 || goto net31
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net30/mac} || goto net31
:net31
isset ${net31/mac} || goto no_nic
dhcp net31 || goto net32
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net31/mac} || goto net32
:net32
isset ${net32/mac} || goto no_nic
dhcp net32 || goto net33
chain http://foreman.lbhr.htm.lan:8000/unattended/iPXE?mac=${net32/mac} || goto net33
:net33
goto no_nic
exit 0
:no_nic
echo Failed to chainload from any network interface
sleep 30
exit 1
So far, so good.
For the unkown VM, when I call the URL mentioned in the template (but I set the MAC myself) it looks like this:
#!ipxe
echo Opening global default menu in 5 seconds...
sleep 5
set menu-default discovery
set menu-timeout 5000
set port 8448
:start
menu iPXE global boot menu
item --key l local Local boot (next entry)
item shell Drop into iPXE shell
item reboot Reboot system
item
item --key d discovery Discovery from ${next-server}:8000 (httpboot module)
item discovery_custom Discovery from ${next-server}:${port} (httpboot module)
choose --timeout ${menu-timeout} --default ${menu-default} selected || goto cancel
set menu-timeout 0
goto ${selected}
:cancel
echo Menu canceled, dropping to shell
:shell
echo Use the command 'exit' to return to menu
shell
set menu-timeout 0
goto start
:failed
echo Boot failed, dropping to shell
goto shell
:reboot
reboot
:local
exit 1
:discovery
dhcp
kernel http://${next-server}:8000/httpboot/boot/fdi-image/vmlinuz0 initrd=initrd0.img rootflags=loop root=live:/fdi.iso rootfstype=auto ro rd.live.image acpi=force rd.luks=0 rd.md=0 rd.dm=0 rd.lvm=0 rd.bootif=0 rd.neednet=0 nomodeset nokaslr proxy.type=foreman BOOTIF=01-${net0/mac} fdi.countdown=10
initrd http://${next-server}:8000/httpboot/boot/fdi-image/initrd0.img
imgstat
sleep 2
boot || goto failed
goto start
:discovery_custom
dhcp
kernel http://${next-server}:${port}/httpboot/boot/fdi-image/vmlinuz0 initrd=initrd0.img rootflags=loop root=live:/fdi.iso rootfstype=auto ro rd.live.image acpi=force rd.luks=0 rd.md=0 rd.dm=0 rd.lvm=0 rd.bootif=0 rd.neednet=0 nomodeset nokaslr proxy.type=foreman BOOTIF=01-${net0/mac} fdi.countdown=10
initrd http://${next-server}:${port}/httpboot/boot/fdi-image/initrd0.img
imgstat
sleep 2
boot || goto failed
And for the known VM like this:
#!ipxe
# Skips booting from network and continues booting from next device
exit 1
This is the corresponding /var/log/foreman-proxy/proxy.log
for the unknown VM:
2021-05-08T05:21:47 5138cea0 [I] Started GET /unattended/iPXE bootstrap=1
2021-05-08T05:21:47 5138cea0 [D] Template: request for unattended/iPXE using {"bootstrap"=>"1", "url"=>"http://foreman.lbhr.htm.lan:8000"} at foreman.lbhr.htm.lan
2021-05-08T05:21:47 5138cea0 [D] Retrieving a template from https://foreman.lbhr.htm.lan//unattended/iPXE?bootstrap=1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000
2021-05-08T05:21:47 5138cea0 [D] HTTP headers: {"USER_AGENT"=>"curl/7.64.0", "ACCEPT"=>"*/*", "X-Forwarded-For"=>"192.168.255.11, foreman.lbhr.htm.lan"}
2021-05-08T05:21:48 5138cea0 [I] Finished GET /unattended/iPXE with 200 (82.77 ms)
2021-05-08T05:22:20 [D] Starting allocated ip addresses cleanup pass...
2021-05-08T05:23:20 [D] Starting allocated ip addresses cleanup pass...
2021-05-08T05:24:20 [D] Starting allocated ip addresses cleanup pass...
2021-05-08T05:24:22 e772d329 [I] Started GET /unattended/iPXE mac=52:d6:61:a8:05:b1
2021-05-08T05:24:22 e772d329 [D] Template: request for unattended/iPXE using {"mac"=>"52:d6:61:a8:05:b1", "url"=>"http://foreman.lbhr.htm.lan:8000"} at foreman.lbhr.htm.lan
2021-05-08T05:24:22 e772d329 [D] Retrieving a template from https://foreman.lbhr.htm.lan//unattended/iPXE?mac=52%3Ad6%3A61%3Aa8%3A05%3Ab1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000
2021-05-08T05:24:22 e772d329 [D] HTTP headers: {"USER_AGENT"=>"curl/7.64.0", "ACCEPT"=>"*/*", "X-Forwarded-For"=>"192.168.255.11, foreman.lbhr.htm.lan"}
2021-05-08T05:24:22 e772d329 [I] Finished GET /unattended/iPXE with 200 (69.94 ms)
And this is /var/log/foreman/production.log
for the unknown VM:
2021-05-08T05:21:48 [I|app|c2d043f0] Started GET "/unattended/iPXE?bootstrap=1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000" for 192.168.255.15 at 2021-05-08 05:21:48 -0400
2021-05-08T05:21:48 [I|app|c2d043f0] Processing by UnattendedController#host_template as TEXT
2021-05-08T05:21:48 [I|app|c2d043f0] Parameters: {"bootstrap"=>"1", "url"=>"http://foreman.lbhr.htm.lan:8000", "kind"=>"iPXE", "unattended"=>{}}
2021-05-08T05:21:48 [W|app|c2d043f0] Could not find a provider for foreman.lbhr.htm.lan. Providers returned {"Katello::ManagedContentMediumProvider"=>["Kickstart repository was not set for host 'foreman.lbhr.htm.lan'", "Content source was not set for host 'foreman.lbhr.htm.lan'"], "MediumProviders::Default"=>["CentOS 8.2.2004 medium was not set for host 'foreman.lbhr.htm.lan'", "Invalid medium '' for 'CentOS 8.2.2004'"]}
2021-05-08T05:21:48 [I|app|c2d043f0] Rendering text template
2021-05-08T05:21:48 [I|app|c2d043f0] Rendered text template (Duration: 0.0ms | Allocations: 3)
2021-05-08T05:21:48 [I|app|c2d043f0] Completed 200 OK in 51ms (Views: 0.5ms | ActiveRecord: 7.3ms | Allocations: 33580)
2021-05-08T05:24:22 [I|app|442d7285] Started GET "/unattended/iPXE?mac=52%3Ad6%3A61%3Aa8%3A05%3Ab1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000" for 192.168.255.15 at 2021-05-08 05:24:22 -0400
2021-05-08T05:24:22 [I|app|442d7285] Processing by UnattendedController#host_template as TEXT
2021-05-08T05:24:22 [I|app|442d7285] Parameters: {"mac"=>"52:d6:61:a8:05:b1", "url"=>"http://foreman.lbhr.htm.lan:8000", "kind"=>"iPXE", "unattended"=>{}}
2021-05-08T05:24:22 [I|app|442d7285] Rendering text template
2021-05-08T05:24:22 [I|app|442d7285] Rendered text template (Duration: 0.0ms | Allocations: 3)
2021-05-08T05:24:22 [I|app|442d7285] Completed 200 OK in 40ms (Views: 0.7ms | ActiveRecord: 18.0ms | Allocations: 11504)
This is the corresponding /var/log/foreman-proxy/proxy.log
for the known VM:
2021-05-08T05:30:44 300144df [I] Started GET /unattended/iPXE bootstrap=1
2021-05-08T05:30:44 300144df [D] Template: request for unattended/iPXE using {"bootstrap"=>"1", "url"=>"http://foreman.lbhr.htm.lan:8000"} at foreman.lbhr.htm.lan
2021-05-08T05:30:44 300144df [D] Retrieving a template from https://foreman.lbhr.htm.lan//unattended/iPXE?bootstrap=1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000
2021-05-08T05:30:44 300144df [D] HTTP headers: {"USER_AGENT"=>"curl/7.29.0", "ACCEPT"=>"*/*", "X-Forwarded-For"=>"192.168.255.152, foreman.lbhr.htm.lan"}
2021-05-08T05:30:44 300144df [I] Finished GET /unattended/iPXE with 200 (80.43 ms)
2021-05-08T05:30:59 eecfe533 [I] Started GET /unattended/iPXE mac=82:96:86:cf:26:71
2021-05-08T05:30:59 eecfe533 [D] Template: request for unattended/iPXE using {"mac"=>"82:96:86:cf:26:71", "url"=>"http://foreman.lbhr.htm.lan:8000"} at foreman.lbhr.htm.lan
2021-05-08T05:30:59 eecfe533 [D] Retrieving a template from https://foreman.lbhr.htm.lan//unattended/iPXE?mac=82%3A96%3A86%3Acf%3A26%3A71&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000
2021-05-08T05:30:59 eecfe533 [D] HTTP headers: {"USER_AGENT"=>"curl/7.29.0", "ACCEPT"=>"*/*", "X-Forwarded-For"=>"192.168.255.152, foreman.lbhr.htm.lan"}
2021-05-08T05:30:59 eecfe533 [I] Finished GET /unattended/iPXE with 200 (129.11 ms)
And this is /var/log/foreman/production.log
for the known VM:
2021-05-08T05:30:44 [I|app|e7103b1c] Started GET "/unattended/iPXE?bootstrap=1&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000" for 192.168.255.15 at 2021-05-08 05:30:44 -0400
2021-05-08T05:30:44 [I|app|e7103b1c] Processing by UnattendedController#host_template as TEXT
2021-05-08T05:30:44 [I|app|e7103b1c] Parameters: {"bootstrap"=>"1", "url"=>"http://foreman.lbhr.htm.lan:8000", "kind"=>"iPXE", "unattended"=>{}}
2021-05-08T05:30:44 [W|app|e7103b1c] Could not find a provider for foreman.lbhr.htm.lan. Providers returned {"Katello::ManagedContentMediumProvider"=>["Kickstart repository was not set for host 'foreman.lbhr.htm.lan'", "Content source was not set for host 'foreman.lbhr.htm.lan'"], "MediumProviders::Default"=>["CentOS 8.2.2004 medium was not set for host 'foreman.lbhr.htm.lan'", "Invalid medium '' for 'CentOS 8.2.2004'"]}
2021-05-08T05:30:44 [I|app|e7103b1c] Rendering text template
2021-05-08T05:30:44 [I|app|e7103b1c] Rendered text template (Duration: 0.0ms | Allocations: 3)
2021-05-08T05:30:44 [I|app|e7103b1c] Completed 200 OK in 48ms (Views: 0.5ms | ActiveRecord: 6.7ms | Allocations: 33546)
2021-05-08T05:30:59 [I|app|9228e5d3] Started GET "/unattended/iPXE?mac=82%3A96%3A86%3Acf%3A26%3A71&url=http%3A%2F%2Fforeman.lbhr.htm.lan%3A8000" for 192.168.255.15 at 2021-05-08 05:30:59 -0400
2021-05-08T05:30:59 [I|app|9228e5d3] Processing by UnattendedController#host_template as TEXT
2021-05-08T05:30:59 [I|app|9228e5d3] Parameters: {"mac"=>"82:96:86:cf:26:71", "url"=>"http://foreman.lbhr.htm.lan:8000", "kind"=>"iPXE", "unattended"=>{}}
2021-05-08T05:30:59 [I|app|9228e5d3] Rendering text template
2021-05-08T05:30:59 [I|app|9228e5d3] Rendered text template (Duration: 0.0ms | Allocations: 2)
2021-05-08T05:30:59 [I|app|9228e5d3] Completed 200 OK in 96ms (Views: 0.5ms | ActiveRecord: 28.8ms | Allocations: 25589)