Autoinstalling ubuntu-server 20.04.3 from the live-iso

i am confirming that the install docs could be cleaned up here - there is no need to extract the complete iso contents to your foreman instance or smart proxy - just these 2 files + having the ISO on same storage, for example this is my internal repo/mirror server:

[11:30:31] (ssh) (SUDO) root@mirror:ubuntu # ls -lah *
-rw-r--r-- 1 root root 1.4G Oct  3 08:18 20.04-x86_64.iso
-rw-r--r-- 1 root root 1.4G Oct  3 08:20 22.04-x86_64.iso

20.04-x86_64:
total 12K
drwxr-xr-x 3 root root 4.0K Oct  3 06:59 .
drwxr-xr-x 4 root root 4.0K Oct  3 08:20 ..
drwxr-xr-x 2 root root 4.0K Oct  3 08:15 casper

22.04-x86_64:
total 12K
drwxr-xr-x 3 root root 4.0K Oct  3 08:28 .
drwxr-xr-x 4 root root 4.0K Oct  3 08:20 ..
drwxr-xr-x 2 root root 4.0K Oct  3 08:29 casper

This saves nearly 3GB of space and if only Ubuntu would make them available at consistent locations of the mirror file system…

I also used the variables within the Install Media definition to allow me to use the same install media for 22.04 and 20.04

http://<mirrorURL>/ubuntu/$version-x86_64/

@bastian-src ,

I just tried this method.
Instead of linking the user-data file as a provisioning-template for which I copied the content of the file in the pub-directory, I linked it to a userdata-template
So now there is no provisioning template configured for host, but instead the userdata template.

But it does not provision my host!

How can I check if http://my.foreman.com/userdata/ has been correctly created?
Or what am I missing or doing wrong?

This is my PXEGrub2 file:

menuentry “Install Ubuntu Server jammy” {
set gfxpayload=keep
linux ubuntu/jammy/vmlinuz nomodeset ip=dhcp url=http://< ip forman server >:80/pub/installation_media/ISO/ubuntu-22.04-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://< ip forman server >:80/userdata/ root=/dev/ram0 ramdisk_size=1500000 fsck.mode=skip
initrd ubuntu/jammy/initrd

1 Like

Hey @langesmalle! Nice to hear from you again!

Your template configuration sounds alright - when assigning the user-data template you end up with 3 templates for your host: Finish, Boot (PXE/Grub), and the user data template. The finish template might be optional for your setup.

When calling the userdata API endpoint, it takes the request IP to determine the template it has to return. This means, calling the API from a “random” machine is just going to result in a “Not Found” because no template can be associated.
Still, you can check whether the template is rendered correctly in your Foreman UI at the hosts page:
image

If you want to check whether the template is requested correctly during provisioning, just have a look at your log file in /var/log/foreman/production.log. It should print Started GET "/userdata/user-data" for <host ip> shortly after the deployment started. If this message is not printed, your host does not reach this stage and might have an error running the boot files.

From what you are saying, it sounds like your host fails at this first boot stage. And, I think the problem might be in your template. We found out, during the Grub2 setup, that it needs quotes around the “;”. Moreover, I would suggest adding the cloud-config-url=/dev/null part as I just mentioned here. So, your template would look like the following:

menuentry “Install Ubuntu Server jammy” {
set gfxpayload=keep
linux ubuntu/jammy/vmlinuz nomodeset ip=dhcp url=http://< ip forman server >:80/pub/installation_media/ISO/ubuntu-22.04-live-server-amd64.iso autoinstall "ds=nocloud-net;s=http://< ip forman server >:80/userdata/" root=/dev/ram0 ramdisk_size=1500000 fsck.mode=skip cloud-config-url=/dev/null
initrd ubuntu/jammy/initrd

Let me know if this helps or if you find any other hint in your error logs!

Follow-up:

We are currently working on providing an official GRUB2 template which works with Ubuntu Autoinstall: Community Ticket.

i’ve found a bit of a peculiar error here

one cannot use the same Operating System Entry to provision an Image Based or Boot Disk Based (and possibly also network based) installation

the auto install template has partition based config which causes the template to fail to render due to no partition data present which is quite correct considering you cannot specify the partition layout with an image based install anyway. I’ve worked around this by leaving my default Ubuntu 20.04 OS entry for bootdisk, then created a cloned entry with an appropriate name to include image and selected the plain userdata template - this works but i do need to maintain 2 entries - not sure how this could be improved

Hey Foreman Community!

Im still having issues getting Ubuntu 20.04 or 22.04 to PXE install. So Im wondering if Im missing something.

Foreman (non ketello): 3.4.0
OS Hosting Foreman: AlmaLinux 8.6
Single server setup

Here’s what I did based on the docs written so far by various people.

## SSH to Foreman Server
ssh user@foremanserver

## Elevate to root
sudo su -

## make temp folder
mkdir prep_ubuntu_autoinstall

## Change Dir to prep folder
cd prep_ubuntu_autoinstall

## Download Ubuntu ISO - In my case Desktop Version
wget https://releases.ubuntu.com/20.04.5/ubuntu-20.04.5-desktop-amd64.iso

## Mount ISO image
mount ubuntu-20.04.5-desktop-amd64.iso /mnt

## Make folder for extracted contents of ISO file
mkdir -p /var/www/html/pub/installation_media/ubuntu/20.04-x86_64/

## Copy entire ISO file to the 'ubuntu' folder
cp ubuntu-20.04.5-desktop-amd64.iso /var/www/html/pub/installation_media/ubuntu/20.04-x86_64.iso

## Extract ISO file contents to '20.04-x86_64' folder
cp -a /mnt/* /var/www/html/pub/installation_media/ubuntu/20.04-x86_64/

## Unmount ISO File
umount /mnt/

Once I had the ISO contents in place. I created the installation media in Foreman as follows:

Once I created the installation media I created the OS and assigned the templates I think are needed.

The templates above are the templates that came with Foreman 3.4.0. However, Im not sure If Im missing any templates, or need to make modifications to the above templates.

In anycase I go to PXE boot the machine and get the following error that Im not sure how to fixed. And when I check the production.log or the proxy.log there is no input. Even with logging set to debug level.

Any help is greatly appreciated.

Thanks

Shawn OG

I would like to add that I just tried doing the same steps above but with 20.04.5 live server. and get the same error in the PXE booting screen shot. I also checked /var/log/httpd/foreman_access.log and see the following:

172.*.*.* - - [13/Oct/2022:07:00:11 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/initrd HTTP/1.1" 404 196 "-" "curl/7.61.1"
172.*.*.* - - [13/Oct/2022:07:00:11 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/vmlinuz HTTP/1.1" 404 196 "-" "curl/7.61.1"
172.*.*.* - - [13/Oct/2022:10:32:47 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/vmlinuz HTTP/1.1" 404 196 "-" "curl/7.61.1"
172.*.*.* - - [13/Oct/2022:10:32:47 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/initrd HTTP/1.1" 404 196 "-" "curl/7.61.1"
172.*.*.* - - [14/Oct/2022:05:24:03 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/vmlinuz HTTP/1.1" 404 196 "-" "curl/7.61.1"
172.*.*.* - - [14/Oct/2022:05:24:03 -0700] "GET /pub/installation_media/ubuntu/20.04-x86_64//casper/initrd HTTP/1.1" 404 196 "-" "curl/7.61.1"

I checked /var/www/http/pub/installation_media/ubuntu/20.04-x86_64/ and it has casper/initrd and casper/vmlinuz present.

Anyways still stuck and hope for some guidance.

Thanks again

Shawn OG

Hey Team,

I managed to make some progress. For what ever reason during PXE the VM can not download the ISO from the foreman server. So I tried moving the ISO to a external webserver. Verified I can download the ISo file from the external server. Than updated the installation media path to piont to the external webserver where the ISO is located. Than proceeded to boot the VM. Sure enough the VM booted this time and was able to download the ISO. HOwever. it never auto provisions. I do not think its sees the userdata file.

So I guess Im wondering is there anything we need to change in the apache configuration, or settings I need to change on foreman to allow the download the ISO directly from foreman?

Thanks

Shawn OG

@sgoetz ,

The initrd and vmlinuz files should be present in the /var/lib/tftpboot folder.

In the PXELinux template you use their should be configured something like this:

For Legacy BIOS:

LABEL linux cloud-init autoinstall
    KERNEL ubuntu/<%= @host.operatingsystem.release_name %>/vmlinuz nomodeset
    INITRD ubuntu/<%= @host.operatingsystem.release_name %>/initrd

For UEFI:

   linux ubuntu/<%= @host.operatingsystem.release_name %>/vmlinuz nomodeset ip=dhcp url=http://<%= @preseed_server %><%= @preseed_path %> autoinstall ds=nocloud-net\;s=http://<%= @preseed_server %>/userdata/ root=/dev/ram0 ramdisk_size=1500000 fsck.mode=skip
    initrd ubuntu/<%= @host.operatingsystem.release_name %>/initrd

Where @host.operatingsystem.release_name points to the focal or jammy sub-folder.

So the files initrd and vmlinuz should be present in /var/lib/tftpboot/ubuntu/{focal|jamy}

Hope this helps you further.

@langesmalle Thank you for the response. I ended up figuring it out. Basically the http path for downloading the ISO is different in mine than what the published instructions say. I had to look at the httpd.conf to figure out where to place the ISO. Once I placed the ISO where the httpd.conf said. It all started working. I also had to fix several default templates to get things to work.

My next big issue to figure out and hope someone can lead me down the correct path is how to get Foreman to Provision baremetal with SecureBoot enabled.

Secureboot enabled with Redhat 8.6 == works
Secureboot enabled with Ubuntu 22.04 == invalid signature

I think I have to replace some files in /var/lib/tftpboot/grub2/ but Im not 100% sure. Anyways has anyone gotten secureboot to work with ubuntu 20.04/22.04 and point me in the right direction?

Thanks

Shawn OG

Sorry for the late response.
Idk whether this is helpful anymore since you got your setup working. Still, I had a look at your initial configuration and I assume Foreman did not configure your tftpboot directory properly:

In your operating system config (figure os_os_tab), you set “20” as major and “04” as minor version. But, “20.04” must be the major and “5” the minor version since you are using 20.04.5. Depending on this version, Foreman decides on how to extract the boot files from your Installation Media.

Since this is not configured properly, the boot files are not set up as it’s intended. You can verify this by checking your /var/lib/tftpboot/boot folder. It should contain the boot files for Ubuntu 20.04 and the size must be ~100MB for the initrd and ~11MB for vmlinuz. If this is not the case, change your operating system config as I’ve described earlier, delete the existing ubuntu boot files in /var/lib/tftpboot/boot and trigger a host deployment again. Now, Foreman is going to re-trigger the boot file download and they should be identified correctly.

If your httpd confg is different, you should have to adapt this path in the PXELinux Autoinstall template only and it shoudn’t be necessary to adapt any other default templates.

Regarding grub2 configuration: We are currently in the process of adding a GRUB2 template. Moreover, we adapt the existing PXELinux template and introduce a snippet which takes all Autoinstall configurations. This should make the deployment process more intuitive. You can have a look here.

@langesmalle the manual setup of the boot files is not necessary anymore. Since Foreman 3.3, it can identify the boot files automatically when the Operating System is configured properly (be aware of the major/minor issue mentioned earlier).

Hi,
Does anybody know why it is not asking for OTP (one time password) from IPA using this cloud-init method.
I have finish template and ‘$HOST[OTP]’ is not populated there as one time password is not asked from IDM/Freeipa server for some reason. Tried build/cancel build, even new host creation etc…

Might be something to watch for future Ubuntu autoinstalls with Foreman: [spec] Publishing netboot artifacts - Foundations - Ubuntu Community Hub

Canonical are planning to publish netboot images again and already available for 23.04: Ubuntu 23.04 (Lunar Lobster)

Not any official documentation yet, but looks promising for the next LTS release.

2 Likes

i still face this issue when trying to download the full image of an ubuntu server. i don’t see the below path in “Preseed default PXELinux Autoinstall” , not sure where it comes from!

Oops, we’re sorry but something went wrong ERF42-8287 [Foreman::Exception]: Unable to download boot file http://foreman/pub/installation_media/ubuntu-22.04//dists/jammy/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux, HTTP return code 404

Hey!

As mentioned here, Foreman uses a different boot files path on the Installation Media depending on the Operating System version (major/minor). It seems like you want to install Ubuntu 22.04, but Foreman uses the boot files path from 20.04.1/2 (preseed/debian installer).

Please, check that your operating system is configured properly (22.04 as major, none or a specific version as minor).

Also, have a look at the documentation:

Create an Operating System

https://docs.theforeman.org/nightly/Provisioning_Hosts/index-foreman-el.html#Creating_an_Operating_System_for_Ubuntu_provisioning

Create an Installation Media

https://docs.theforeman.org/nightly/Provisioning_Hosts/index-foreman-el.html#Creating_an_Installation_Medium_for_Ubuntu_22_04_provisioning

(Provision Ubuntu hosts through Proxies)

https://docs.theforeman.org/nightly/Provisioning_Hosts/index-foreman-el.html#Provisioning_Ubuntu_Autoinstall_Through_Smart_Proxies_provisioning

Let me know if this helps! :slight_smile:

@bastian-src That definitely helped! thanks for that.
Now struggling to make automated installation working after successful boot and downloading the iso before the installation. here is my templates. instead of starting installation, it started interactive OS installation. my foreman setup is rocky 8.8 and foreman 3.7:

DEFAULT linux cloud-init autoinstall
LABEL linux cloud-init autoinstall
    KERNEL boot/ubuntu-22-04-rPlU9KhtByaF-hwe-vmlinuz
    INITRD boot/ubuntu-22-04-rPlU9KhtByaF-hwe-initrd
    APPEND root=/dev/ram0 ip=dhcp ramdisk_size=1500000 fsck.mode=skip autoinstall url=http://foreman:80/pub/installation_media/ubuntu-22.04.iso cloud-config-url=/dev/null ds=nocloud-net;s=http://foreman.example.com/userdata/ console-setup/ask_detect=false locale=en_US localechooser/translation/warn-light=true localechooser/translation/warn-severe=true hostname=buildtest1.example.com domain=example.com

based on some random comments here I have change preseed_kernel_options_autoinstall snippet like this:

 userdata_option = "ds=nocloud-net;s=http://#{foreman_request_addr}/userdata/"
  #userdata_option = "ds=nocloud-net;s=http://#{foreman_request_addr}/userdata/#{mac ? mac + '/' : ''}"

Thanks for your help

Happy to hear that!


Your PXELinux template looks fine to me - the .iso and userdata paths should be correct.


The change you’ve made to your preseed_kernel_options_autoinstall snippet is only important if you want to deploy your host through a Smart Proxy - the Smart Proxy does currently not support the mac-based userdata interface. (Even if you don’t provision through a Smart Proxy, you can leave it like that for now - just pay attention to use the default snippet again as soon as the Smart Proxy supports the mac-based approach such that you don’t miss any updates on the snippet)

Ubuntu usually switches to the interactive installation if it encounters an error with the cloud-init/userdata setup. Please, have a look at the Preseed Autoinstall cloud-init user data template and verify that it is a valid YAML.
Thereby, it could be an issue that you didn’t choose the Preseed default autoinstall partition table during the host deployment process (or in your host group).

If that hasn’t been the issue, please post that template here (after masquerading any sensitive information).

Hi All,

I am new to Foreman, I was able to provision CentOS however still facing in installing Ubuntu 20.04. I am using the updated templates “Preseed Autoinstall cloud-init user data” but when I try to open the provisioning link(http://foreman.example.com/userdata/ on the foreman master) updated in tftp, the webpage doesn’t exists. Also the files updated under /var/lib/tftpboot/boot are not as per the ISO & in Kb size.

Kindly suggest what could be the issue & If possible pls share any link having complete steps to be followed for provisioning Ubuntu 20.04 and above machines?

Hey @ashishsn6!

Did you follow the documentation for creating an OS and the Installation Media as mentioned here?


The URL is not supposed to be opened from your browser. The host calls the API and depending on the host’s IP, Foreman returns the corresponding Userdata template.
But, the latest Foreman supports calling http://foreman.example.com/userdata/<host MAC>/user-data. You can call that API also from other machines like your browser to validate the template.


It seems like your boot files are not extracted correctly from the Installation Media:
Currently, the default provisioning method if you just define your OS as Ubuntu with Major <20.04> and Minor empty or 1 or 2, Foreman supposes you want to use Preseed debian-installer. Accordingly, it tries a distinct path to set up the Installation Media.
You have to define explicitly Minor <3> or higher, so Foreman will assume that you want to use Autoinstall. Then, it will also use the corresponding path for extracting the boot files from the Installation Media.

Hi @bastian-src

Thanks for your response.

  1. Yes I have tried with mentioning the major & minor version, it is still the same and following the documentation.
  2. http://foreman.example.com/userdata/<host MAC>/user-data this webpage also doesn’t exist.
  3. Since the files were not get downloaded in /var/lib/tftpboot/boot, I have manually downloaded the initrd & vmlinuz from the ISO. The endpoint started the booting from PXE however it got stuck post “Running /scripts/caser-premount” with error “can’t open /dev/sr0: No medium found”.

Sharing the below information if it helps:
Foreman Version: 3.3
Templates used:
Partition table: Preseed default autoinstall
Finish template: Preseed default finish
Host initial configuration template: Linux host_init_config default
PXELinux template: Preseed default PXELinux Autoinstall
User data template: Preseed Autoinstall cloud-init user data

Ubuntu ISO is hosted on a separate machine and no http logs are getting generated on that machine when starting the installation from Foreman.

Anything that I need to modify?