Foreman has supported el9 for several releases. With Foreman 3.12 and Katello 4.14 being the last supported versions on el8, it's time to upgrade. Upgrading to el9 will provide access to future upgrades, streamline the verisons used in my infrastructure and the latest security and performance improvements. I'll be upgrading my Server using leapp again just like I did previously. The procedure is outlined quite well in the documentation but here's my own take on documenting the procedure.
NOTE: before continuing, please ensure you have a way to roll back any changes in case anything goes wrong.
First, apply the latest patches for all packages:
[root@katello01 ~]# dnf -4y --refresh update
Check if a reboot is required:
[root@katello01 ~]# dnf needs-restarting -r
Perform a reboot if system libraries and packages have been upgraded:
[root@katello01 ~]# systemctl reboot
Once the server is back online, we can begin with the upgrade. To facilitate the transition from EL8 to EL9, we will enable the foreman/leapp copr repository, which provides the necessary tools and packages for the upgrade process. Then, we will install the required packages:
[root@katello01 ~]# dnf -4y --refresh copr enable @theforeman/leapp
[root@katello01 ~]# dnf -4y --refresh install leapp leapp-upgrade-el8toel9
I'll be upgrading from Almalinux 8 to Almalinux 9, so I'll have to install the 'leapp-data-almalinux' package:
[root@katello01 ~]# dnf -4y --refresh install leapp-data-almalinux
With all the packages installed, we'll have to append the Foreman-Repos to the leapp upgrade repo file:
[root@katello01 ~]# vim /etc/leapp/files/leapp_upgrade_repositories.repo
[leapp-foreman]
name=Foreman 3.12
baseurl=https://yum.theforeman.org/releases/3.12/el9/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman
enabled=1
gpgcheck=1
[leapp-foreman-plugins]
name=Foreman plugins 3.12
baseurl=https://yum.theforeman.org/plugins/3.12/el9/$basearch
enabled=1
gpgcheck=0
[leapp-katello]
name=Katello 4.14
baseurl=https://yum.theforeman.org/katello/4.14/katello/el9/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman
enabled=1
gpgcheck=1
[leapp-candlepin]
name=Candlepin: an open source entitlement management system.
baseurl=https://yum.theforeman.org/candlepin/4.4/el9/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-candlepin
enabled=1
gpgcheck=1
[leapp-pulpcore]
name=pulpcore: Fetch, Upload, Organize, and Distribute Software Packages.
baseurl=https://yum.theforeman.org/pulpcore/3.49/el9/$basearch/
gpgkey=https://yum.theforeman.org/pulpcore/3.49/GPG-RPM-KEY-pulpcore
enabled=1
gpgcheck=1
[leapp-puppet8]
name=Puppet 8 Repository el 9 - $basearch
baseurl=http://yum.puppetlabs.com/puppet8/el/9/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-2025-04-06-puppet8-release
enabled=1
gpgcheck=1
That's the leapp configuration done. Now ensure all Foreman services are stopped:
[root@katello01 ~]# foreman-maintain service stop
I'm using a nfs share to files to foreman for the dhcp-proxy feature, so I'll have to unmount them and comment them out in '/etc/fstab':
[root@katello01 ~]# umount /mnt/nfs/etc/dhcp /mnt/nfs/var/lib/dhcpd
[root@katello01 ~]# vim /etc/fstab
# satellite capsule stuff
# infra01.archyslife.lan:/exports/etc/dhcp /mnt/nfs/etc/dhcp nfs ro,vers=3,auto,nosharecache,context="system_u:object_r:dhcp_etc_t:s0" 0 0
# infra01.archyslife.lan:/exports/var/lib/dhcpd /mnt/nfs/var/lib/dhcpd nfs ro,vers=3,auto,nosharecache,context="system_u:object_r:dhcpd_state_t:s0" 0 0
Since I've upgraded my installation over time, there are still some packages left over from previous versions of the foreman and katello packages that will cause dependency issues down the road. We'll have to remove them beforehand:
[root@katello01 ~]# dnf -4y autoremove
[root@katello01 ~]# dnf -4y remove python39
The upgrade using leapp will cause a lot of open file handles, so we'll have to increase the available file handles using 'ulimit' for the current shell session:
[root@katello01 ~]# ulimit -n 65536
Now, let's run the preupgrade and check for inhibitors:
[root@katello01 ~]# leapp preupgrade
The report shows no inhibitors, so let's run the upgrade:
[root@katello01 ~]# leapp upgrade
This command will take a few minutes to complete since it will download a lot of packages and create a initramfs that will take care of the upgrade. That also means that there's another reboot required:
[root@katello01 ~]# systemctl reboot
The system will now reboot into the newly generated initramfs and perform the upgrade from el8 to el9.
Progress can be monitored using 'journalctl' and following the service 'leapp-resume.service':
[root@katello01 ~]# journalctl -b -e -f -u leapp-resume.service
In my case, there was an error because of duplicate entries of puppet facts. The fix is documented by Red Hat in KB6998041:
[root@katello01 ~]# foreman-maintain service stop --exclude postgresql
[root@katello01 ~]# cat << EOF | foreman-rake console
conf.echo = false
FactName.unscoped.all.pluck(:type).uniq.each do |type|
type.constantize.unscoped.group_by(&:name).select{|k,v| v.size > 1}.values.each do |dup_names|
existing = dup_names[0]
dup_name_ids = dup_names[1..-1].map(&:id)
p "Found duplicate fact names #{existing.type} #{existing.name} ids #{dup_name_ids}"
values = FactValue.unscoped.where(fact_name_id: dup_name_ids)
p "Merging #{values.size} fact values."
values.in_batches.update_all(fact_name_id: existing.id)
p "Deleting duplicate fact names."
FactName.unscoped.where(id: dup_name_ids).destroy_all
end
end
EOF
Now, re-run the installer to ensure a consistent system state:
[root@katello01 ~]# foreman-installer --scenario katello
After the installer has run through without an issue, continue to enable selinux and reboot once more:
[root@katello01 ~]# sed -i 's/SELINUX=permissive/SELINUX=enforcing/g' /etc/selinux/config
[root@katello01 ~]# systemctl reboot
After the server has come up again with SELinux enabled, stop the foreman services and run the installer once last time for this upgrade:
[root@katello01 ~]# foreman-maintain service stop
[root@katello01 ~]# foreman-installer --scenario katello
After completion, check the health of the system:
[root@katello01 ~]# foreman-maintain service status
[root@katello01 ~]# foreman-maintain health check
Okay, everything seems healthy and stable so far. We can now move to cleaning up the system from old resources. First, clean up any old packages that are left over from el8. There's a good article on that here: Performing post-upgrade tasks on the RHEL 9 system. It essentially boils down to these commands:
[root@katello01 ~]# rpm -qa | grep -e '\.el[78]' | grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' | sort
[root@katello01 ~]# dnf -y remove $(rpm -qa | grep -iIE '\.el[78]' | grep -viIE 'gpg-pubkey|libmodulemd|katello-ca-consumer')
[root@katello01 ~]# dnf -y remove leapp-deps-el9 leapp-repository-deps-el9
[root@katello01 ~]# rm -rf /var/log/leapp /root/tmp_leapp_py3 /var/lib/leapp
The only thing left to do now is replacing the old rescue-kernel and initramfs with the current versions. Again, theres a good resource available online here: Performing post-upgrade tasks on the RHEL 9 system. Start by removing the old initramfs and rescue-kernels:
[root@katello01 ~]# rm /boot/vmlinuz-*rescue* /boot/initramfs-*rescue*
Then, regenerate both of them and let dracut create entries in the bootmenu:
[root@katello01 ~]# /usr/lib/kernel/install.d/51-dracut-rescue.install add "$(uname -r)" /boot "/boot/vmlinuz-$(uname -r)"
That's it, the system is now upgraded from el8 to el9 with a working Foreman/Katello installation.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment