Skip to content

Instantly share code, notes, and snippets.

@anthonysomerset
Created September 29, 2022 07:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonysomerset/b83f5f8b732f4a4102c333d100337f90 to your computer and use it in GitHub Desktop.
Save anthonysomerset/b83f5f8b732f4a4102c333d100337f90 to your computer and use it in GitHub Desktop.
Preseed default iPXE - AUTOINSTALL
#!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
@swatkiev
Copy link

swatkiev commented Oct 3, 2022

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?

@anthonysomerset
Copy link
Author

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

@swatkiev
Copy link

swatkiev commented Oct 7, 2022

Thank you @anthonysomerset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment