#!ipxe set base http://${next-server}:8088 set ubuvmlinuz ${base}/images/ubuntu/vmlinuz set ubuinitrd ${base}/images/ubuntu/initrd set ubuiso ${base}/images/ubuntu/ubuntu-22.04.5-live-server-amd64.iso echo iPXE script reached successfully! echo MAC: ${mac} echo IP: ${ip} # MAC to hostname mapping (generated from CSV) echo Detecting hostname from MAC address... echo Debug: Detected MAC: ${mac} echo Debug: MAC length: ${#mac} echo Debug: First 4 chars: ${mac:0:4} # cptcor01 -> 40:a6:b7:27:b9:d0 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:b9:d0 && set hostname cptcor01 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:b9:d0 to cptcor01 (EthernetInterface0) && goto hostname_set || # cptcor02 -> 40:a6:b7:27:be:e0 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:be:e0 && set hostname cptcor02 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:be:e0 to cptcor02 (EthernetInterface0) && goto hostname_set || # cptcor03 -> 40:a6:b7:27:4c:4c (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:4c:4c && set hostname cptcor03 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:4c:4c to cptcor03 (EthernetInterface0) && goto hostname_set || # cptcor04 -> 40:a6:b7:34:2f:2c (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:34:2f:2c && set hostname cptcor04 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:34:2f:2c to cptcor04 (EthernetInterface0) && goto hostname_set || # cptcor05 -> 40:a6:b7:27:b2:b0 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:b2:b0 && set hostname cptcor05 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:b2:b0 to cptcor05 (EthernetInterface0) && goto hostname_set || # cptcor06 -> 40:a6:b7:30:d7:f8 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:30:d7:f8 && set hostname cptcor06 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:30:d7:f8 to cptcor06 (EthernetInterface0) && goto hostname_set || # cptcor07 -> 40:a6:b7:27:b0:ec (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:b0:ec && set hostname cptcor07 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:b0:ec to cptcor07 (EthernetInterface0) && goto hostname_set || # cptcor08 -> 40:a6:b7:34:41:fc (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:34:41:fc && set hostname cptcor08 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:34:41:fc to cptcor08 (EthernetInterface0) && goto hostname_set || # cptcor09 -> 40:a6:b7:34:4f:6c (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:34:4f:6c && set hostname cptcor09 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:34:4f:6c to cptcor09 (EthernetInterface0) && goto hostname_set || # cptcor10 -> 40:a6:b7:33:97:5c (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:33:97:5c && set hostname cptcor10 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:33:97:5c to cptcor10 (EthernetInterface0) && goto hostname_set || # cptcor11 -> 40:a6:b7:34:4e:84 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:34:4e:84 && set hostname cptcor11 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:34:4e:84 to cptcor11 (EthernetInterface0) && goto hostname_set || # cptcor12 -> 40:a6:b7:34:55:44 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:34:55:44 && set hostname cptcor12 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:34:55:44 to cptcor12 (EthernetInterface0) && goto hostname_set || # cptcor13 -> 40:a6:b7:33:8b:48 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:33:8b:48 && set hostname cptcor13 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:33:8b:48 to cptcor13 (EthernetInterface0) && goto hostname_set || # stocor01 -> 40:a6:b7:26:e1:30 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:26:e1:30 && set hostname stocor01 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:26:e1:30 to stocor01 (EthernetInterface0) && goto hostname_set || # stocor02 -> 40:a6:b7:27:4b:44 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:4b:44 && set hostname stocor02 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:4b:44 to stocor02 (EthernetInterface0) && goto hostname_set || # stocor03 -> 40:a6:b7:27:c2:48 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:c2:48 && set hostname stocor03 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:c2:48 to stocor03 (EthernetInterface0) && goto hostname_set || # stocor04 -> 40:a6:b7:27:b5:e0 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:b5:e0 && set hostname stocor04 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:b5:e0 to stocor04 (EthernetInterface0) && goto hostname_set || # stocor09 -> 40:a6:b7:27:55:88 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:55:88 && set hostname stocor09 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:55:88 to stocor09 (EthernetInterface0) && goto hostname_set || # stocor08 -> 40:a6:b7:28:2e:8c (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:28:2e:8c && set hostname stocor08 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:28:2e:8c to stocor08 (EthernetInterface0) && goto hostname_set || # stocor10 -> 40:a6:b7:27:4c:84 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:4c:84 && set hostname stocor10 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:4c:84 to stocor10 (EthernetInterface0) && goto hostname_set || # stocor06 -> 40:a6:b7:33:97:74 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:33:97:74 && set hostname stocor06 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:33:97:74 to stocor06 (EthernetInterface0) && goto hostname_set || # mstcor1 -> 40:a6:b7:27:41:f0 (interface: EthernetInterface0) iseq ${mac} 40:a6:b7:27:41:f0 && set hostname mstcor1 && set primary_interface EthernetInterface0 && echo Matched: 40:a6:b7:27:41:f0 to mstcor1 (EthernetInterface0) && goto hostname_set || # Unknown MAC fallback echo Debug: No MAC match found for: ${mac} set hostname unknown set primary_interface enp34s0f0 :hostname_set echo Final detected hostname: ${hostname} echo Primary interface: ${primary_interface} # Determine site based on hostname prefix (customize as needed) isset ${hostname} && goto detect_site || goto fallback_menu :detect_site echo Debug: Processing hostname: ${hostname} iseq ${hostname:0:3} cpt && set site cor && echo Site set to cor from cpt prefix && goto site_set || iseq ${hostname:0:3} cpu && set site cor && echo Site set to cor from cpu prefix && goto site_set || iseq ${hostname:0:3} sto && set site cor && echo Site set to cor from sto prefix && goto site_set || iseq ${hostname:0:3} mgt && set site cor && echo Site set to cor from mgt prefix && goto site_set || iseq ${hostname:0:3} mst && set site cor && echo Site set to cor from mst prefix && goto site_set || # Fallback default site set site cor echo Fallback: site set to cor :site_set # NoCloud expects /user-data and /meta-data under this base URL (note trailing slash) set nocloud_url ${base}/profiles/cor/${hostname}/ echo Final site: ${site} echo Autoinstall (NoCloud) URL: ${nocloud_url} sleep 2 goto menu :fallback_menu echo Unknown hostname, using manual menu set site unknown set primary_interface enp34s0f0 set nocloud_url ${base}/profiles/${site}/${hostname}/ sleep 2 goto menu :menu menu Policloud - Ubuntu 22.04 Install [${hostname:default(Unknown)}] [IF: ${primary_interface:default(auto)}] item --key l local Boot from local disk item --key a auto Auto-install Ubuntu 22.04 (site: ${site:default(unknown)}) item --key t test-autoinstall Test NoCloud URL choose --default auto --timeout 15000 selected || goto auto goto ${selected} :auto isset ${hostname} && isset ${site} && goto auto_install || goto fallback_install :auto_install echo Auto-installing ${hostname} from site ${site} echo Using interface: ${primary_interface} echo NoCloud URL: ${nocloud_url} # Pass NoCloud datasource URL (autoinstall reads user-data/meta-data here) kernel ${ubuvmlinuz} ip=dhcp url=${ubuiso} autoinstall ds=nocloud-net;s=${nocloud_url} hostname=${hostname} initrd ${ubuinitrd} boot :fallback_install echo No hostname/site detected. Please verify CSV/inventory. goto menu :test-autoinstall echo Testing NoCloud URL accessibility (should expose user-data/meta-data)... echo URL: ${nocloud_url} echo Press any key to return to menu read goto menu :local exit