Autoinstalling ubuntu-server 20.04.3 from the live-iso

@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?

Ah okay, this API endpoint has been introduced in Foreman 3.4 - so that makes sense now.

So, the installation process is started but it stops at this point? I haven’t seen it stopping at this point before.

How much RAM did you give the machine? (Ubuntu Autoinstall needs at least ~3GB).

That shouldn’t be an issue - but you should still see some event in your var/log/foreman/production log when the host downloads the userdata template from Foreman.

Yes the installation starts and then stays hung at this point. The VM has
4GB RAM allocated to it.

I can see a log generated in the
var/log/foreman/production…

Am I using the correct templates?
Or any recommendations pls?

Do you see something similar to the following?

2023-10-24T11:39:17 [I|app|8dce6478] Started GET "/userdata/user-data?url=<foreman URL> for <host IP> at 2023-10-24 11:39:17 +0200
2023-10-24T11:39:17 [I|app|8dce6478] Processing by UserdataController#userdata as TEXT
2023-10-24T11:39:17 [I|app|8dce6478]   Parameters: {"url"=>"<foreman URL>", "userdatum"=>{}}
2023-10-24T11:39:18 [I|app|8dce6478]   Rendered text template (Duration: 0.0ms | Allocations: 1)
2023-10-24T11:39:18 [I|app|8dce6478] Completed 200 OK in 506ms (Views: 1.0ms | ActiveRecord: 65.8ms | Allocations: 76581)

There might be also some calls to userdata/vendor-data but those can be ignored.

The associated templates are fine. So, for further debugging, please post the rendered version of the Preseed default PXELinux Autoinstall and Preseed Autoinstall cloud-init user data templates :slight_smile:

I have never been able to install with this little RAM. We’ve told our techs they need at least 5GB. I’d be curious if you try with 6GB (or even 8GB) if your install works.

I also use 6 GB for Autoinstall.

Hi @bastian-src

Apologies for the delay in response…

These logs are not visible in var/log/foreman/production.

These are the templates I am using:

@esw Tried with 6GB RAM as well still getting the same error “can’t open /dev/sr0: No medium found”.

Then, the issue occurs probably before the userdata template is downloaded.

Can you please post the rendered version of your PXELinux template (masquerading any sensitive information of course)?

I am getting this in the preview section:

#
# This file was deployed via ‘<%= template_name %>’ template
#
# Supported host/hostgroup parameters:
#
# blacklist = module1, module2
# Blacklisted kernel modules
#
# lang = en_US
# System locale
#
#
# 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 boot/filename-vmlinuz**
** INITRD boot/filename-initrd**
** APPEND ip=dhcp url=http://xxxxxxxx/pub/installation_media/ubuntu/20.04.6/ autoinstall ds=nocloud-net;s=http://foreman-server-domain/userdata/ root=/dev/ram0 ramdisk_size=1500000 fsck.mode=skip**

I’ve just compared your template to the latest version of it (that I just used for my own Ubuntu host deployment).
I recognized that in your version, there is no parameter cloud-config-url=/dev/null. There is currently a bug in the Ubuntu installer which let’s it download the iso image twice - passing this parameter prevents the installer from doing so. Look here for further information on this: server - pxe autoinstall fails with ubuntu 20.04.04 - Ask Ubuntu
You can create a custom template and add the paramter.

Besides that, your template looks fine.

Can you verify that your boot files are downloaded correctly?
There should be some files similar to these in your boot files directory /var/lib/tftpboot/boot/ on your Foreman:

-rw-r--r--. 1 foreman-proxy foreman-proxy  85M Mar 14  2023 ubuntu20lts-mirror-AETB3fdcwlLC-initrd
-rw-r--r--. 1 foreman-proxy foreman-proxy  14M Mar 14  2023 ubuntu20lts-mirror-AETB3fdcwlLC-vmlinuz

The naming could be different, but the file size is important. It should be similar to these.


PS: Have a look here on how to post code blocks (so you don’t run into formatting issues when sharing templates for example): An Unofficial Discourse User Reference Guide - TechForum Site and Post Help - Electronic Component and Engineering Solution Forum - TechForum │ Digi-Key


EDIT:

In your version of the template, you would have to change line 50 to the following:

    APPEND ip=dhcp 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 cloud-config-url=/dev/null