Ubuntu 22.04 UEFI booting not working

Problem:
I’m trying to pxe boot some Dell servers with UEFI boot mode and can’t seem to get it to work. I can do BIOS boot with on these servers with PXE Loader: PXELinux and set the DHCP server bootp file to pxelinux.0 and that works fine.

But… when I switch to use the PXE Loader: Grub2 UEFI, on the dhcp server set the boot file to grub2/grubx64.efi, the server starts to boot, and then it tries to reach out to get the ubuntu.iso from the foreman server, and then it gives the error “network unreachable”.

What are the steps needed to get foreman to provision Ubuntu 22.04 on a UEFI enabled server. I can’t seem to find any documentation on this. For some reason I think I need to use Grub2 UEFI setting as that is what seems to be what people say to use for UEFI?

Expected outcome:
Provision Dell server when in UEFI boot mode.

Foreman and Proxy versions:
3.5.1

Distribution and version:
AlmaLinux 8.7

Hey! @wrender

Can you elaborate your BIOS boot setup a bit further:

I am not really familiar with DHCP bootp configurations. But, AFAIK it is a mechanism for your host (the DELL server) to find a DHCP server in your network which provides the host with the necessary boot files (initrd/kernel). In this setup, does the Foreman still act as such DHCP server? Then, your deployment should not really differ from an “normal” Ubuntu deployment, right?

You write that your PXELinux/BIOS deployment works fine - did you also deploy Ubuntu 22.04 with PXELinux/BIOS or just older verions? In case you deploy 22.04 successfully already, do you also see your host (DELL server) trying to download the image from your Foreman?

Last but not least: What templates are you using?
Is it the following for your UEFI deployment? Link

Looking forward to hear from you!

Hi.

From this I assume that GRUB2 can be successfully loaded from TFTP server and it can fetch its configuration from TFTP server?

Your configuration should look similar to this:

menuentry 'Preseed default PXEGrub2 Autoinstall' {                                 
  linuxefi boot/ubuntu-22-04-local-open-f2S3cv7iz6MN-vmlinuz ... url=http://foreman.test:80/pub/installation_media/ubuntu/22.04-x86_64.iso ... autoinstall "ds=nocloud-net;s=http://foreman.test:8000/userdata/" ip=dhcp  ...
  initrdefi boot/ubuntu-22-04-local-open-f2S3cv7iz6MN-initrd                       
} 

The ip=dhcp is mandatory here because this allows configuration of network required to download the Ubuntu ISO from the pub/ directory.

If this fails (network unreachable) then you maybe have some misconfiguration in your network configuration provided via DHCP (gateway? DNS?).

After failed download of Ubuntu ISO you can press any key and you should end up in a shell. Check:

(initramfs) ip a
(initramfs) ip r
(initramfs) cat /etc/resolv.conf

Thanks. I ended up getting this working. I think the problem was I was just using a wrong combination of templates for Ubuntu.

Could you post here what you found to be the correct combination of templates? Thanks man!

Finish Template - Preseed default finish
Host initial configuration template - Linux host_init_config default
PXEGrub2 template - Preseed default PXEGrub2 AutoInstall
PXELinux template - Preseed default PXELinux AutoInstall
User data template - Ubuntu Preseed AutoInstall cloud-init user data

Is this something you created? “Ubuntu Preseed AutoInstall cloud-init user data”

Sorry, My mistake. That is my modified one. It’s just called “Preseed Autoinstall cloud-init user data”. The one here: foreman/app/views/unattended/provisioning_templates/user_data/preseed_autoinstall_cloud_init.erb at develop · theforeman/foreman · GitHub

The one at the link above should work out of the box.

Okay, wasn’t sure but that is what I have set already.

cloud-init does not work, ALWAYS kicks me to the standard Ubuntu setup screen. i.e., Select Language, Networking, User info, etc. - Not sure what is not working. I walk through all of that and at the end have to cancel the build to prevent the server from booting back up into a provisioning state each time it is rebooted. SOMETHING is not working, what that is, I am not sure yet. Have not spent a ton of time on it recently. Open to suggestions from anyone. Thanks.

If it’s kicking you to the standard Ubuntu setup screen, that normally means something is not being provided by the autoinstall file. It can be a real pain to troubleshoot.

Have you tried click on the host, then clicking “Details”, and then clicking the template there to show what is being rendered from the template for that host? I normally go through that when this happens, and see what might be missing. If you are PXE booting, also make sure you have set the IP address, and mac address, and interface name on the interfaces on the host.

Also, did you setup the media this specific way and link it to your Operating System?
Provisioning Hosts

Setting up Operating System for Ubuntu:
https://docs.theforeman.org/3.6/Provisioning_Hosts/index-katello.html#Creating_an_Operating_System_for_Ubuntu_provisioning

1 Like

Yeah, I went through all of this and have it setup as such but still, same result on my end. I did look over the provisioning template and it would seem no matter the one I use (default or customized), it makes no difference.

Can you paste the contents of your PXELinux file for that particular host?

For the host you are trying to boot what’s it’s IP address? Does it match what is set in foreman under the network interface for that host?

Using the default preseed version.

<%#
kind: PXELinux
name: Preseed default PXELinux Autoinstall
model: ProvisioningTemplate
oses:
- ubuntu
test_on:
- ubuntu_autoinst4dhcp
-%>
#
# This file was deployed via '<%= template_name %>' template
#
# Supported host/hostgroup parameters:
#
# blacklist = module1, module2
#   Blacklisted kernel modules
#
# lang = en_US
#   System locale
#
<%
  image_path = @preseed_path.sub(/\/?$/, '.iso')
  options = []
  if host_param('blacklist')
    options << host_param('blacklist').split(',').collect{|x| "#{x.strip}.blacklist=yes"}.join(' ')
  end
  options << 'root=/dev/ram0'
  options << 'ramdisk_size=1500000'
  options << 'fsck.mode=skip'
  options << "url=http://#{@preseed_server}#{image_path}"
  options << 'cloud-config-url=/dev/null'
  options << "ds=nocloud-net;s=http://#{foreman_request_addr}/userdata/"
  options << 'autoinstall'
  options = options.join(' ')
-%>
#
# WARNING
#
# Foreman will not download the kernel/initramdisk to PXE automatically. Please follow
# the official Ubuntu documentation and extract the files from the LiveCD (DVD) manually
# and optionally update the KERNEL and INITRD lines in this template.
#
DEFAULT linux cloud-init autoinstall
LABEL linux cloud-init autoinstall
    KERNEL <%= @kernel %>
    INITRD <%= @initrd %>
    APPEND <%= options %> <%= snippet('preseed_kernel_options_autoinstall').strip %>

<%= snippet_if_exists(template_name + " custom menu") %>

I tried borh BIOS and EFI methods to see if that made a difference, it did not. Still drops me into interactive mode and does not run cloud-init.

One thing you could try, is boot a live server OS on the IP address you have set for that host that is not autoinstalling.

Then try curling the AutoInstall location on the foreman server.

Like curl http://{foreman_request_addr}/userdata/

Funny I was JUST doing this and then saw this post lol. I ran it from the installer by going to the Help menu and dropping to a shell. With the / at the end of usedata = 404, without, nothing.

In the log:

 ActionController::RoutingError (No route matches [GET] "/userdata"):

Read some other posts having the same issues but I checked over those issues and don’t see my setup having those issues. When I create a new host this is now what I am seeing in logs:

2023-07-14T22:38:42 [I|app|4297c96d] Started GET "/userdata/meta-data" for <provision-ip> at 2023-07-14 22:38:42 -0400
2023-07-14T22:38:42 [I|app|4297c96d] Processing by UserdataController#metadata as TEXT
2023-07-14T22:38:42 [E|app|4297c96d] Could not find host for request <provision-ip>
2023-07-14T22:38:42 [I|app|4297c96d]   Rendered text template (Duration: 0.1ms | Allocations: 3)
2023-07-14T22:38:42 [I|app|4297c96d] Filter chain halted as :find_host rendered or redirected
2023-07-14T22:38:42 [I|app|4297c96d] Completed 404 Not Found in 65ms (Views: 7.2ms | ActiveRecord: 19.2ms | Allocations: 2783)
... (repeats about 10x the fails)

This looks like it explains why it’s not autoinstalling.

On the host you are creating in foreman do you have a provision IP assigned on the network interface for the host?

It gets assigned via DHCP and does show up once the VM has booted. The and what I see in the Foreman interface as well as the IP on the VM itself all match.

Strange. Seems like a but with your install? What version are you running or foreman?