Autoinstalling ubuntu-server 20.04.3 from the live-iso

Good Morning All,

I’ve been trying to follow along this convo to setup Ubuntu 20.04 & 22.04 provisioning via Foreman but having troubles understanding what exactly needs to be done. So wondering if anyone here can either point me to an article with exact steps or provide me with the steps. Keep in mind Im very new to Foreman/Linux management and have only been doing this for 6 months. So trying my best to understand everything :smiley:

My Environment

  • Foreman Version: 3.3.0 - non ketello

  • OS Hosting Foreman: AlmaLinux 8.6

  • All foreman components on same server. Single server deployment currently.

  • This version has all the templates created earlier in this post with auto install in the name

    So far this post has been a bit confusing with steps for modifying tftp to steps for copying the ISO down and its contents to the correct folder structure. And its in all kinds of order lol. So just wondering if someone could write a step by step guide from step 1 to actually provisioning a Ubuntu machine. What templates do I need to use? What settings do I need to change in Foreman? etc.

Thanks

Shawn OG

2 Likes

hi @sgoetz

I have picked up my work on docs for Ubuntu again: Procedures to provision hosts running Ubuntu 22.04. I will notify you once this has been reviewed and merged. cc @bastian-src

1 Like

Good news: we have merged documentation for Ubuntu Autoinstall:

Feedback is appreciated.

1 Like

Awesome docs @maximilian! I wrote a post trying to untangle everything to do with autoinstall on Ubuntu, I think it might help some other folks who stumble across this forum.

The biggest thing is how to modify the ISO to automatically boot (if desired) and some underyling components.

It’s essentially the doc I wish I found when starting to explore this topic, heh

4 Likes

Hi, Long time viewer of the forum, first time poster :slight_smile:

So i have to do a fresh build of some ubuntu 20.04 hosts and bumped into all these issues… - i even reinstalled my foreman host from scratch thinking i was having major dramas because of customising provisioning templates etc anyway…

For me the instructions largely work if you are in a plain PXE environment which we moved away from some time back due to the number of discrete subnets/networks we are running accross africa meant it wasn’t the most scalable for us - we use foreman_bootdisk with static IP addressing.

for us we had to hack the iPXE template that foreman_bootdisk chainloads to account for the new autoinstall params etc - thanks to this AskUbuntu link for guidance on getting the static config right for casper - networking - assign ip to ubuntu 20.04 during installation (packer/cloud-init context) - Ask Ubuntu

my iPXE template for Ubuntu 20.04 and assuming will work for 22.04 too is here - Preseed default iPXE - AUTOINSTALL · GitHub

it probably could do with a lot of cleanup/fixing (staticv6 is untested for example) but will help steer those using foreman_bootdisk

now the manuals say to copy the whole ISO contents to the pub directory - this might not be entirely required

from my server access logs the only files downloaded other than the iso itself (twice!)
/pub/install_media/ubuntu/20.04-x86_64//casper/vmlinuz
/pub/install_media/ubuntu/20.04-x86_64//casper/initrd

i also saw these:

/userdata/meta-data
/userdata/user-data

which were fine and also repeated hits on
/userdata/vendor-data
which was giving a 404

i haven’t yet tried doing from a smart proxy

i now appear to be bumping into the eject cd rom issue in vmware again - will take a seperate look at that

Hey @anthonysomerset!

Thanks for your comment. The latest version of the PXELinux Autoinstall template does also support static IP deployment. Have a look here:

Do I understand you right that the bootdisk setup uses the PXELinux template still or does it take a different one?

The fact that your ISO is downloaded twice origins from a design issue of Ubuntu Autoinstall. You can append cloud-config-url=/dev/null. Have a look here: askubuntu.com.

I don’t quite understand the question in your post, could you elaborate it more? In case you want some help debugging your vmware issue: It sounds a bit like the typical error that occurs when the user-data template is not correct. Can you verify this?

Hi

The bootdisk plugin at least for the dynamic host specific iso chain loads iPXE and NOT PXELinux - I think for the generic host image it still uses the PXELinux but I have separate unrelated config issues to work through to get generic host images working in my environment

Will test with the cloud-config-url param because i was seeing weird issues when i had both cloud-init and user-data templates specified in the OS config - i didn’t have time to debug that other than to ensure i wasn’t specifying the cloud init template at all.

the cd eject issue was actually a byproduct of that issue - it actually doesn’t happen when only the proper autoinstall user-data is present as then the correct late commands are run which includes an eject command

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