Associate ipxe menu item to host
-
Is it possible to associate an iPXE menu item to a host like you can associate an image to a host?
Scenario:
I have multiple machines that all need the same image but I am not using static captured images I am using ipxe menus to boot an iso and run an automated installer from ubuntu, so there is zero interaction. Currently the only interaction is plugging in the machine and booting it to fog, selecting the menu item and letting it go.
I’d love to be able to associate mac addresses to a certain option so once it hits the fog menu it selects it and then runs in the installer. Does anyone have any idea how to make this a possibility?
Thanks!
-
@londonfog Fog doesn’t do this out of the box. I think you might need a bit of a deeper discussion on what you really need.
- Can you say any machine that pxe boots into the fog iPXE menu will have the ubuntu auto installer run?
- Will all of these machines be registered within fog?
- How many select machines will you want to auto boot into the installer?
- Does anyone in your company have programming (specifically php) skills?
- How motivated are you to go down a DIY path?
-
- No not every machine - Only the machines we have registered in FOG that we associate this “image”(ipxe menu item) to. Just like you can do currently with Associating an image to a host
- Yes, all will be registered in FOG. Would like to do this with an API call.
- There will be many, yesterday there were 20 done.
- Yes, although I haven’t personally used php in years myself and other people on my team can do this. I started looking at the source code last night, but not too deep yet.
- Motivated enough to make it work so we don’t have to adopt something else, since this primarily works for our other needs.
-
@londonfog OK lets start out with how FOG works.
- Your computer pxe boots and downloads and runs iPXE that is either undionly.kpxe or ipxe.efi depending on the target computer’s firmware.
- Within that ipxe boot loader it has a script that finds the FOG server and then calls a file called default.ipxe. This file is in the /tftpboot directory on the FOG server.
- Inside default.ipxe there is a chain call to boot.php which builds the iPXE menu.
I’ll stop here because that is the relevant bits.
Now with a windows computer using a web browser you can view the FOG iPXE menu by calling this URL
http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00
That will display the text program that builds the FOG iPXE menu. If you can read programs this should be 100% understandable.Now when you register target computers with FOG, the FOG UI will add the host definition into the MySQL database on the fog server. The database in question is
fog
, with the table ofhosts
. If you log into the mysql client program on the FOG server you can issue these commandsuse fog; select * from hosts;
To get a listing of hosts registered on the FOG server.
Now when you register FOG manually at the end of the registration it asks about some additional fields, Other1, Other2, and my be primary user. These are extra fields that FOG doesn’t touch or use during the imaging process. So for your custom code you could look (via sql query) at the other1 field, if that field has a specific value then you know you need to autoboot into the ubuntu auto installer.
OK NOW bringing it all together.
- Create your own PHP web page (lets call it autoboot.php) that queries the
fog
database for the supplied mac address (this is supplied by ipxe). If the other1 field equals ‘yes’ then you will chain to the ubuntu installer code. If isn’t a match it called the FOG standard boot.php with its required parameters. - Now update default.ipxe on the fog server to call autoboot.php (your code) first. Then in turn autoboot.php will either create the ipxe script to call the ubuntu installer code or the standard boot.php
To say it another way, you will write a php program that will intercept the call to fog’s boot.php to run your code.