Hey lzap! Hope you’ve been well.
It being 81 bytes is odd, isn’t it? I thought so too…
That only happens when a host is already “known” to Foreman. However, isn’t the “script” which is downloaded (http://10.254.52.26/unattended/iPXE) generated from the “iPXE intermediate script” template?
If I pull up that template up in Foreman and “preview” it for this particular host, I get:
#!ipxe
# Intermediate iPXE script to report MAC address to Foreman
:net0
isset ${net0/mac} || goto no_nic
dhcp net0 || goto net1
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet0%2Fmac%7D || goto net1
:net1
isset ${net1/mac} || goto no_nic
dhcp net1 || goto net2
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet1%2Fmac%7D || goto net2
:net2
isset ${net2/mac} || goto no_nic
dhcp net2 || goto net3
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet2%2Fmac%7D || goto net3
:net3
isset ${net3/mac} || goto no_nic
dhcp net3 || goto net4
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet3%2Fmac%7D || goto net4
:net4
isset ${net4/mac} || goto no_nic
dhcp net4 || goto net5
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet4%2Fmac%7D || goto net5
:net5
isset ${net5/mac} || goto no_nic
dhcp net5 || goto net6
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet5%2Fmac%7D || goto net6
:net6
isset ${net6/mac} || goto no_nic
dhcp net6 || goto net7
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet6%2Fmac%7D || goto net7
:net7
isset ${net7/mac} || goto no_nic
dhcp net7 || goto net8
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet7%2Fmac%7D || goto net8
:net8
isset ${net8/mac} || goto no_nic
dhcp net8 || goto net9
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet8%2Fmac%7D || goto net9
:net9
isset ${net9/mac} || goto no_nic
dhcp net9 || goto net10
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet9%2Fmac%7D || goto net10
:net10
isset ${net10/mac} || goto no_nic
dhcp net10 || goto net11
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet10%2Fmac%7D || goto net11
:net11
isset ${net11/mac} || goto no_nic
dhcp net11 || goto net12
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet11%2Fmac%7D || goto net12
:net12
isset ${net12/mac} || goto no_nic
dhcp net12 || goto net13
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet12%2Fmac%7D || goto net13
:net13
isset ${net13/mac} || goto no_nic
dhcp net13 || goto net14
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet13%2Fmac%7D || goto net14
:net14
isset ${net14/mac} || goto no_nic
dhcp net14 || goto net15
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet14%2Fmac%7D || goto net15
:net15
isset ${net15/mac} || goto no_nic
dhcp net15 || goto net16
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet15%2Fmac%7D || goto net16
:net16
isset ${net16/mac} || goto no_nic
dhcp net16 || goto net17
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet16%2Fmac%7D || goto net17
:net17
isset ${net17/mac} || goto no_nic
dhcp net17 || goto net18
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet17%2Fmac%7D || goto net18
:net18
isset ${net18/mac} || goto no_nic
dhcp net18 || goto net19
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet18%2Fmac%7D || goto net19
:net19
isset ${net19/mac} || goto no_nic
dhcp net19 || goto net20
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet19%2Fmac%7D || goto net20
:net20
isset ${net20/mac} || goto no_nic
dhcp net20 || goto net21
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet20%2Fmac%7D || goto net21
:net21
isset ${net21/mac} || goto no_nic
dhcp net21 || goto net22
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet21%2Fmac%7D || goto net22
:net22
isset ${net22/mac} || goto no_nic
dhcp net22 || goto net23
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet22%2Fmac%7D || goto net23
:net23
isset ${net23/mac} || goto no_nic
dhcp net23 || goto net24
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet23%2Fmac%7D || goto net24
:net24
isset ${net24/mac} || goto no_nic
dhcp net24 || goto net25
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet24%2Fmac%7D || goto net25
:net25
isset ${net25/mac} || goto no_nic
dhcp net25 || goto net26
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet25%2Fmac%7D || goto net26
:net26
isset ${net26/mac} || goto no_nic
dhcp net26 || goto net27
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet26%2Fmac%7D || goto net27
:net27
isset ${net27/mac} || goto no_nic
dhcp net27 || goto net28
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet27%2Fmac%7D || goto net28
:net28
isset ${net28/mac} || goto no_nic
dhcp net28 || goto net29
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet28%2Fmac%7D || goto net29
:net29
isset ${net29/mac} || goto no_nic
dhcp net29 || goto net30
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet29%2Fmac%7D || goto net30
:net30
isset ${net30/mac} || goto no_nic
dhcp net30 || goto net31
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet30%2Fmac%7D || goto net31
:net31
isset ${net31/mac} || goto no_nic
dhcp net31 || goto net32
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet31%2Fmac%7D || goto net32
:net32
isset ${net32/mac} || goto no_nic
dhcp net32 || goto net33
chain http://foremanserver:8000/unattended/iPXE?mac=%24%7Bnet32%2Fmac%7D || goto net33
:net33
goto no_nic
exit 0
:no_nic
echo Failed to chainload from any network interface
sleep 30
exit 1
There is no way that is 80 bytes (its actually about 5000 bytes).
However if I curl
that script from the host once its booted up the OS and pass the bootstrap=1
HTTP parameter (like DHCP instructs iPXE to do), I do get a 80 byte script:
$ curl http://10.254.52.26/unattended/iPXE?bootstrap=1
#!ipxe
# Skips booting from network and continues booting from next device
exit
Which is awesome, its exactly what I need to happen. And if I take a step further and directly curl
the URL which is in the previewed iPXE template (by passing the MAC address as a HTTP paramater in the URL):
$ curl http://10.254.52.26:8000/unattended/iPXE?mac=40:f2:e9:d6:5c:1a
#!ipxe
# Skips booting from network and continues booting from next device
exit
I have no idea what is going on under the hood when you pass that bootstrap=1
parameter, but it seems to go straight to passing on the iPXE script of booting the hard disk. Its all black magic to me, which is exciting!
I continue to be impressed with how all of this operates and how it mostly “just works”. I thought setting up iPXE was going to be a real pain in the butt, but all it took was downloading the iPXE boot file, throwing it in my TFTP root and updating my dhcpd.conf
to hand it over to PXE clients. The whole discovery process over iPXE worked flawlessly after that. Very nice!