Short:
I am looking for a way to PXE boot Ubuntu 20.04, and use new autoinstall for a completely unattended installation. But I would like for user-data
YAML to be modified server-side based on MAC of a client
What I found
- I have boot kernel option of
nocloud-net;s=http://...
but I don't see a way to send a custom string as part of URL (or change URL altogether based on local MAC) - I see
early-commands
which says thatautoinstall
will be refreshed after those are run, but I did not produce any valid way to use it to inject modified data to new autoinstall; eg. dowget http://myurl/$MAC
then grep that file and modify autoinstall that's already running - Using
late-commands
is option of last resort, where I could indeed dowget http://myurl/$MAC && .. && ...
to eg. set static IP/GW/netmask, but it seems more error prone - Edit: seems I could have another way, but also requires manual handling outside my expected web management, and that is to serve different pxelinux.cfg to each client and change the URL in there, but that's served through TFTP so no server-side scripting (unless there's a workaround?) Edit#2: This could work, point TFTP and HTTP servers to same folder(s), and tell PHP to generate custom files under /pxelinux.cfg/AA-BB-CC-DD-EE-01 ... -02 ... -03 .. etc for each MAC inside my database, and check/regenerate the files whenever an entry in DB is saved. Keeps idea of single management point at least. But I will leave question in case someone knows better solution (see above options)
Ultimate goal
I'd like to have a "master" PXE server, which is home to HTTPS server, and web management, where I could have a table of all devices (eg. in MySQL), and all settings related to each device. Then when we deploy new clients (mostly just some dumb kiosks and stuff), I'd pick their MACs, enable PXE boot, label them, and ship them to remote location. That MAC & location would be entered in MySQL via web management, together with stuff like static IP, GW, DNS, homepage of a browser, screen rotations, etc. Once they arrive and someone connects them, they would boot to unattended PXE install, go through it, in process they'd pull configs from web server (eg. user-data
would actually be processed by PHP, and would inject required config as needed), and it would - well... just work. It could apply to live
images as well, just in a different ways.
I am mostly stuck with the autoinstall
and nocloud-net
boot, it seems great at first, where I could serve a custom unattended file to each client, except for a fact I won't be able to recognize one client from the other. Fetching http://myserver/user-data?AA-BB-CC-DD-EE-FF
doesn't seem to be in the specs, just picking it by IP wouldn't work as those would be random DHCP, unfortunately fixing that with DHCP reservations is a nightmare as we're talking about 100+ locations each with their own local DHCP, etc.
I'm running out of ideas, so hopefully someone can chime in. Any idea to get me going (appart from late-commands
) would be great! It doesn't have to be MAC, can be UIID, or some other hardware ID (serial, etc), but it should be unique and easy to fetch. And MAC is usually a sticker on an outside of a box.
Oh, and if you wonder why I'm so against late-commands
... well.. thing is I'm not against it, just that dynamically modifying unattended file would be so much more flexible. I could set hostname, IP, username, password, disk size, and all that right from the start. Way cleaner than booting with some defaults, then try to go through all places with bash scripts trying to fix it (specially the disks/partitions). After all, that's why we have autoinstall
scripts in the first place, not to re-do it all after first boot.