Created
September 29, 2022 07:28
-
-
Save anthonysomerset/b83f5f8b732f4a4102c333d100337f90 to your computer and use it in GitHub Desktop.
Preseed default iPXE - AUTOINSTALL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!gpxe | |
<%# | |
kind: iPXE | |
name: Preseed default iPXE - AUTOINSTALL | |
model: ProvisioningTemplate | |
oses: | |
- Ubuntu | |
test_on: | |
- ubuntu4dhcp | |
description: | | |
The template to render iPXE installation script for preseed based distributions | |
The output is deployed on the host's subnet TFTP proxy. | |
See https://ipxe.org/scripting for more details | |
-%> | |
<% | |
iface = @host.provision_interface | |
subnet4 = iface.subnet | |
subnet6 = iface.subnet6 | |
ip = iface.ip | |
mask = subnet4.mask | |
gw = subnet4.gateway | |
dns = subnet4.dns_servers.first | |
if subnet4 && !subnet4.dhcp_boot_mode? | |
ipconfig = "ip=#{ip}::#{gw}:#{mask}::::#{dns}" | |
elsif subnet6 && !subnet6.dhcp_boot_mode? | |
ipconfig = "ip=#{ip}::#{gw}:#{mask}::::#{dns}" | |
else | |
ipconfig = 'ip=dhcp' | |
end | |
image_path = @preseed_path.sub(/\/?$/, '.iso') | |
-%> | |
echo Trying to ping Gateway: ${netX/gateway} | |
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available. | |
echo Trying to ping DNS: ${netX/dns} | |
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available. | |
<% boot_files_uris = @host.operatingsystem.boot_files_uri(medium_provider) -%> | |
<% kernel = boot_files_uris[0] -%> | |
<% initrd = boot_files_uris[1] -%> | |
kernel <%= kernel %> initrd=initrd.img <%= ipconfig %> url=http://<%= @preseed_server %><%= image_path %> autoinstall ds=nocloud-net;s=http://<%= foreman_request_addr %>/userdata/ root=/dev/ram0 ramdisk_size=1500000 fsck.mode=skip rw auto | |
initrd <%= initrd %> | |
imgstat | |
sleep 2 | |
boot |
this is specifically an iPXE template to trigger the autoinstall process for ubuntu 20.04 and later machines
this would be used if you use an iPXE based environment or more specifically if you use foreman_bootdisk with vmware compute resources
i would recommend upgrading to a much more current foreman release (current stable is 3.4.0) and there will be far less workarounds required to support ubuntu 22 installs and also refer to https://community.theforeman.org/t/autoinstalling-ubuntu-server-20-04-3-from-the-live-iso/27050/64?page=2 and https://docs.theforeman.org/nightly/Provisioning_Hosts/index-katello.html#Creating_an_Installation_Medium_for_Ubuntu_22_04_provisioning
Thank you @anthonysomerset
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Anthony!
Could you be so kind to tell me, can I use this template to install Ubuntu 22.04 by Foreman v 2.0 (install on CentOS 7), or it's very old version of Foreman and I must update Foreman before try this template?