Foreman 3.3 and Ubuntu 22.04

Problem:
I want to provision ubuntu 22.04 with foreman, but currently the machine boot, ubuntu start to load until it stuck on “reached targed cloud-init target” and then failed beacuse of 10 minute cloud-init timeout
Expected outcome:
Ubuntu 22.04 should be installable
Foreman and Proxy versions:
currently foreman 3.3
Foreman and Proxy plugin versions:

Distribution and version:
oracle linux 7.9
Other relevant data:
First i patched my 3.3 installation to suport ubuntu 22.04, so this files where modified

/usr/share/foreman/app/views/unattended/provisioning_templates/snippet/preseed_kernel_options.erb
/usr/share/foreman/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2.erb
/usr/share/foreman/app/models/operatingsystems/debian.rb

also the templates where asociated whith the 22.04 SO and are rendered fine in the host i believe

Finish template: Custom finish install (based on default)
Host initial configuration template: Linux host_init_config default
Provisioning template: pressed custom (based on default)
PXEGrub2 template: preseed default PXEGrub2
PXELinux template: Pressed default PXELinux Autoinstall
User data template: Pressed Autoinstall cloud-init user data

The custom templates works fine in 18.04, so i suspect the trouble is something in the last template

Ok progress, the trouble i was facing was to low memory, 4g where not enought to run this and cloud-init was oom-killed. now i’m having another error.

Im getting stuck in the language selection screen of ubuntu and in foreman these logs are showing

192.168.0.14 - - [23/Feb/2023:15:25:10 -0500] "GET /pub/installation_media/ubuntu/22.04-x86_64.iso HTTP/1.1" 200 147487334                                        4 "-" "Cloud-Init/22.2-0ubuntu1~22.04.3"
192.168.0.14 - - [23/Feb/2023:15:25:30 -0500] "GET /userdata/meta-data HTTP/1.1" 200 176 "-" "Cloud-Init/22.2-0ubuntu1~22.                                        04.3"
192.168.0.14 - - [23/Feb/2023:15:25:30 -0500] "GET /userdata/user-data HTTP/1.1" 200 5407 "-" "Cloud-Init/22.2-0ubuntu1~22                                        .04.3"
192.168.0.14 - - [23/Feb/2023:15:25:30 -0500] "GET /userdata/vendor-data HTTP/1.1" 404 1564 "-" "Cloud-Init/22.2-0ubuntu1~

Im’ assuming the 404 error in the vendor-data is the problem here.

Hey!

Ubuntu returns back to the manual UI-based installation if there is a problem with the User data template - so, I assume there is an error retrieving the template or the template itself is not alright.

The template itself
The 404 regarding vendor-data is not a problem. The important request is the user-data call which should return the User data template you defined for that host. Can you maybe provide the rendered template or check that it is correct yaml?

Retrieving the template
In case you use PXEGrub2 deployment, the template must be set to Preseed default PXEGrub2 Autoinstall. Unfortunately, this template was introduced in Foreman 3.4, but you can just add it from here (please rename the template such that there won’t be any conflict when you upgrade your Foreman.):

For PXELinux deployment, it should be fine.

Let me know if this helps!

Hi, thank you, here is the renderd user data template:

#cloud-config
autoinstall:
  version: 1
  apt:
    geoip: false
    preserve_sources_list: false
    primary:
      - arches: [amd64, i386]
        uri: http://archive.ubuntu.com/ubuntu
      - arches: [default]
        uri: http://ports.ubuntu.com/ubuntu-ports
  identity:
    hostname: biostest.internal.mycompany.com
    realname: root
    username: root
    password: "$HASHEDPASSWORD"
  keyboard: {layout: us, toggle: null, variant: ''}
  locale: en_US.UTF-8
  network:
    version: 2
    ethernets:
      :
        dhcp4: false
        dhcp6: false
        addresses: [ 192.168.0.14/24 ]
        gateway4: 192.168.0.1
        nameservers:
          search: [ internal.mycompany.com ]
          addresses: ["192.168.0.1", "8.8.8.8"]
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  updates: security
  
  
  # Use the first detected hard disk as default installation disk
  d-i partman/early_command string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
  
  ### Partitioning
  # The presently available methods are: "regular", "lvm" and "crypto"
  d-i partman-auto/method string lvm
  
  # If one of the disks that are going to be automatically partitioned
  # contains an old LVM configuration, the user will normally receive a
  # warning. This can be preseeded away...
  d-i partman-lvm/device_remove_lvm boolean true
  # The same applies to pre-existing software RAID array:
  d-i partman-md/device_remove_md boolean true
  # And the same goes for the confirmation to write the lvm partitions.
  d-i partman-lvm/confirm boolean true
  d-i partman-lvm/confirm_nooverwrite boolean true
  
  # For LVM partitioning, you can select how much of the volume group to use
  # for logical volumes.
  d-i partman-auto-lvm/guided_size string max
  d-i partman-auto-lvm/new_vg_name string VG1
  
  
  d-i partman-basicfilesystems/no_mount_point boolean false 
  d-i partman-auto/expert_recipe string                   \
        boot-root ::                                      \
                1 1 1 free method{ biosgrub } .           \
                512 512 512 ext4                          \
                  $primary{ }                             \
                  $bootable{ }                            \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  mountpoint{ /boot }                     \
                .                                         \
                22240 22240 22240 ext4                    \
                  $lvmok{ }                               \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  mountpoint{ / }                         \
                  lv_name{ RAIZ }                         \
                .                                         \
                10240 10240 10240 ext4                       \
                  $lvmok{ }                               \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  mountpoint{ /home }                     \
                  lv_name{ HOME }                         \
                .                                         \
                10240 10240 10240 ext4                       \
                  $lvmok{ }                               \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  mountpoint{ /opt }                      \
                  lv_name{ OPT }                          \
                .                                         \
                22240 22240 22240 xfs                        \
                  $lvmok{ }                               \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ xfs }     \
                  mountpoint{ /var/lib/docker }           \
                  lv_name{ DOCKER_IMAGES }                \
                .                                         \
                2048 2048 2048 linux-swap                 \
                  $lvmok{ }                               \
                  method{ swap } format{ }                \
                  lv_name{ SWAP}                          \
                .                                         \
                256 25600000 1000000000 ext4              \
                  $lvmok{ }                               \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  lv_name{ placeholder }                  \
                .
  
  # This makes partman automatically partition without confirmation, provided
  # that you told it what to do using one of the methods above.
  d-i partman/confirm_write_new_label boolean true
  d-i partman/choose_partition select finish
  d-i partman/confirm boolean true
  d-i partman/confirm_nooverwrite boolean true
  user-data:
    runcmd:
      - wget -Y off http://foreman.internal.mycompany.com/unattended/finish?token=39ae328f-b6bf-4e63-b955-7bdf00040365 -O /tmp/finish.sh
      - chmod +x /tmp/finish.sh
      - /tmp/finish.sh

For me it seems right… in the afternoon i’ll try to add the PXEGrub2 autoinstall and see if that works

Hey @crubio! Sry, for the late response.

Actually, there are two flaws in your template:

It is supposed to be a valid YAML. But, after the updates: security line, the “old” debian-installer commands are injected. This might be due to your partition layout. It must be Preseed default autoinstall - please check your operating system configuration and your host.

Second, the network configuration has an issue as well since it just says the following:

...
ethernets:
  :
    dhcp4: false
...

This is not a valid yaml again, due to the fact that the corresponding template relies on a network identifier. This is a design flaw of this respective version of the preseed_netplan_generic_interface snippet.
This can be fixed in two (three) ways:

  • a) define an identifier for the interface during the host deployment
  • b) update the snippet to the latest version (introduces MAC-matching instead of identifier-matching)
  • ( c) update to the latest foreman )

I would suggest to try a) first since b) is a bit more complicated (actually 2 templates must be adapted) and c) is just a recommendation but I understand if it is not feasible for you at the moment.

So, going for a): It is important to name the interface according to Ubuntu’s naming scheme according to that machine. For my test machines, it was usually ens160. But, this depends on the hardware. Therefore, I would recommend deploying a machine with this interface name. This is probably gonna result in a host which is not fully deployed due to some netplan error. BUT, when the installer fails, you can actually check the interface name, the Ubuntu installer applies to your hardware. Then, re-deploy the machine with this name.

Let me know if this helps you!

Thanks a lot for everything, now it’s woking, I need to change a lot of things from the old installer to the new but now that’s ubuntu sh…t
After i finish this upgrade of machines from 18.04 to 22.04 i’ll reinstall foreman from scratch and migrate the hosts. ¿Which is the recomended/suporterted distro moving forward?

1 Like

As stated in the quick guide: Foreman :: Quickstart, I would recommend EL8 using Alma Linux.

Happy to hear that the Ubuntu deployment works fine now! :+1: