Skip to main content

Foreman - upgrade from el7 to el8 using leapp

Since Foreman 3.3 and Katello 4.5 are the last supported versions on EL7, I decided to do an in-place upgrade from CentOS 7 to Almalinux 8 using leapp. I'm using a fully up-to-date (as of 19th September 2022) installation of Foreman 3.3, Katello 4.5.

So first, make sure you're up to date with your installation:

 [root@katello01 ~]# yum -y clean all  
 [root@katello01 ~]# rm -rf /var/cache/yum  
 [root@katello01 ~]# yum -y makecache fast  
 [root@katello01 ~]# yum -y update  

If any foreman-packages have been updated, go ahead and ensure that your foreman-installation is consistent:

 [root@katello01 ~]# foreman-maintain service stop  
 [root@katello01 ~]# foreman-installer --scenario katello  

Make sure that the installer runs without errors before continuing.

Check if you need to reboot the server and reboot it if package updates require it

 [root@katello01 ~]# yum needs-restarting -r  
 [root@katello01 ~]# reboot  

The foreman team is hosting a patched version of the leapp upgrade utility, so first download that repo and install the required packages to upgrade. As mentioned earlier, I will be upgrading to Almalinux so I have to install the 'leapp-data-almalinux' package:

 [root@katello01 ~]# curl -Lo '/etc/yum.repos.d/theforeman-leapp.repo' -X GET 'https://copr.fedorainfracloud.org/coprs/g/theforeman/leapp/repo/epel-7/group_theforeman-leapp-epel-7.repo'  
 [root@katello01 ~]# yum -y install leapp leapp-repository leapp-data-almalinux  

After the packages have been installed, you will need to add the foreman and katello repos to the leapp_upgrade_repositories.repo file in addition to the currently existing repos:

 [root@katello01 ~]# vim /etc/leapp/files/leapp_upgrade_repositories.repo  
 [leapp-foreman]  
 name=Foreman 3.3  
 baseurl=https://yum.theforeman.org/releases/3.3/el8/$basearch  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman  
 enabled=1  
 gpgcheck=1  
 module_hotfixes=1  
 
 [leapp-katello]  
 name=Katello 4.5  
 baseurl=https://yum.theforeman.org/katello/4.5/katello/el8/$basearch/  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman  
 enabled=1  
 gpgcheck=1  
 module_hotfixes=1  
 
 [leapp-katello-candlepin]  
 name=Candlepin: an open source entitlement management system.  
 baseurl=https://yum.theforeman.org/katello/4.5/candlepin/el8/$basearch/  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman  
 enabled=1  
 gpgcheck=1  
 module_hotfixes=1  
 
 [leapp-pulpcore]  
 name=pulpcore: Fetch, Upload, Organize, and Distribute Software Packages.  
 baseurl=https://yum.theforeman.org/pulpcore/3.18/el8/$basearch/  
 gpgkey=https://yum.theforeman.org/pulpcore/3.18/GPG-RPM-KEY-pulpcore  
 enabled=1  
 gpgcheck=1  
 module_hotfixes=1  
 
 [leapp-foreman-plugins]  
 name=Foreman plugins 3.3  
 baseurl=https://yum.theforeman.org/plugins/3.3/el8/$basearch  
 enabled=1  
 gpgcheck=0  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman  
 module_hotfixes=1  
 
 [leapp-foreman-client]  
 name=Foreman client 3.3  
 baseurl=https://yum.theforeman.org/client/3.3/el8/$basearch  
 enabled=1  
 gpgcheck=1  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman-client  
 
 [leapp-puppet7]  
 name=Puppet 7 Repository el 8 - $basearch  
 baseurl=http://yum.puppetlabs.com/puppet7/el/8/$basearch  
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-2025-04-06-puppet7-release  
 enabled=1  
 gpgcheck=1  

Now that the repositories are added, you'll have to remove the 'epel-release', 'centos-release-scl', and 'centos-release-scl-rh' packages as they are not compatible with the upgrade:

 [root@katello01 ~]# yum -y remove epel-release centos-release-scl centos-release-scl-rh  

All preparations should be done now so we can continue with running the preupgrade checks using leapp:

 [root@katello01 ~]# leapp preupgrade  

This tool will point out possible issues with the upgrade that need to be addressed. For me, I had two issues that needed to be taken care of:

 [root@katello01 ~]# leapp answer --section authselect_check.confirm=True  
 [root@katello01 ~]# leapp answer --section remove_pam_pkcs11_module_check.confirm=True  

If you've fixed any problems that came up with your installation, rerun 'leapp preupgrade' and ensure that it returns a green state.

OPTIONAL: Check for immutable files on your filesystem:

 [root@katello01 ~]# lsattr -aR / 2> /dev/null | grep -iE '\-i\-'   

In case you have any immutable files on the filesystem, make sure to remove the attribute before upgrading. This for loop did the trick for me:

 [root@katello01 ~]# for file in $(lsattr -aR / 2> /dev/null | grep -iE '\-i\-' | awk '{print $2}'); do chattr -i $file; done  

Now that that's been taken care of, go ahead and run the upgrade:

 [root@katello01 ~]# leapp upgrade  

Once leapp finishes, reboot the machine and let leapp upgrade do its thing. Note that this can take a while depending on disk and cpu performance:

 [root@katello01 ~]# reboot  

After the reboot, grub will automatically boot into the leapp upgrade boot entry and the system will be upgraded. After the machine is back, check the state of 'leapp_resume':

 [root@katello01 ~]# journalctl -fu leapp_resume.service  

If 'leapp_resume' has finished, there's still some minor work we have to do to ensure selinux is running in 'enforcing' mode again, python is set to the correct executable and all foreman-services are running as expected. Let's start with the python alternatives entry:

 [root@katello01 ~]# alternatives --set python /usr/bin/python3  

Enable the 'katello:el8' and 'pulpcore:el8' AppStream Modules:

 [root@katello01 ~]# dnf -4y --refresh module enable katello:el8 pulpcore:el8  

We're almost done. If you want SELiunx to be enforcing, reinstall 'foreman-selinux' and 'katello-selinux' and edit '/etc/selinux/config':

 [root@katello01 ~]# dnf -4y --refresh reinstall foreman-selinux katello-selinux  
 [root@katello01 ~]# sed -i 's/SELINUX=permissive/SELINUX=enforcing/g' /etc/selinux/config  
 [root@katello01 ~]# reboot  

I'd suggest a reboot at this point just to be sure everything is working as expected.

When the machine is back up, you're almost done with the upgrade, there's just some minor cleanup tasks left to do. Once again, ensure foreman and all foreman-services are consistent:

 [root@katello01 ~]# foreman-maintain service stop  
 [root@katello01 ~]# foreman-installer --scenario katello  

Optionally, remove the previously installed leapp-packages and repo file:

 [root@katello01 ~]# dnf -4y --refresh remove leapp leapp-repository leapp-data-almalinux  
 [root@katello01 ~]# rm -f /etc/yum.repos.d/theforeman-leapp.repo  

That's it, the upgrade is done from el7 to el8 and everything should be right back where you left it on el7. Be sure to test the instance though to confirm functionality.

Freel free to comment and / or suggest a topic.


Comments

Popular posts from this blog

Dynamic DNS with BIND and ISC-DHCP

I personally prefer to work with hostnames instead of ip-addresses. If you have anything like freeipa or active directory, it will do that for you by registering the client you added to your realm to the managed dns and edit the records dynamically. We can achieve the same goal with just bind and isc-dhcp. I'll use a raspberry pi with raspbian 9 for this setup. So here is a quick tutorial on how to configure the isc-dhcp-server to dynamically update bind. First set a static ip to your server. [archy@ddns ~]$ sudo vim /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto eth0 iface eth0 inet static address 172.31.30.5 network 172.31.30.0 broadcast 172.31.30.255 netmask 255.255.255.0 ...

LACP-Teaming on CentOS 7 / RHEL 7

What is teaming? Teaming or LACP (802.3ad) is a technique used to bond together multiple interfaces to achieve higher combined bandwith. NOTE: every clients speed can only be as high as the single link speed of one of the members. That means, if the interfaces I use in the bond have 1 Gigabit, every client will only have a maximum speed of 1 Gigabit. The advantage of teaming is, that it can handle multiple connections with 1 Gigabit. How many connections depends on the amount of your network cards. I'm using 2 network cards for this team on my server. That means I can handle 2 Gigabit connections at full rate on my server provided the rest of the hardware can deliver that speed. There also exists 'Bonding' in the Linux world. They both do the same in theory but  for a detailed comparison check out this  article about teaming in RHEL7 . To create a teaming-interface, we will first have to remove all the interface configurations we've done on the (soon to be) sla...

Push logs and data into elasticsearch - Part 2 Mikrotik Logs

This is only about the setup of different logging, one being done with Filebeat and the other being done with sending logging to a dedicated port opened in Logstash using the TCP / UDP Inputs. Prerequesites: You'll need a working Elasticsearch Cluster with Logstash and Kibana. Start by getting the Log Data you want to structure parsed correctly. Mikrotik Logs are a bit difficult since they show you Data in the interface which is already enriched with Time / Date. That means a message that the remote logging will send to Logstash will look like this: firewall,info forward: in:lan out:wan, src-mac aa:bb:cc:dd:ee:ff, proto UDP, 172.31.100.154:57061->109.164.113.231:443, len 76 You can check them in the grok debugger and create your own filters and mapping. The following is my example which might not fit your needs. Here are some custom patterns I wrote for my pattern matching: MIKROTIK_DATE \b(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|jun(?:e)?|jul(?...

FreeIPA - Integrating your DHCPD dynamic Updates into IPA

I recently went over my network configuration and noticed that the dhcp-leases were not pushed into the IPA-DNS yet. So I thought, why not do it now. The setup is very similar to setting it up on a single bind instance not managed by IPA (I've already written a guide about this here ). My setup is done with the following hosts: ipa01.archyslife.lan - 172.31.0.1 inf01.archyslife.lan - 172.31.0.5 First of all, create a rndc-key: [archy@ipa01 ~]$ sudo rndc-confgen -a -b 512 This will create the following file '/etc/rndc-key' [archy@ipa01 ~]$ sudo cat /etc/rndc.key key "rndc-key" { algorithm hmac-md5; secret "secret_key_here=="; }; We also need to make named aware of the rndc-key and allow our remote dhcp server to write dns entries: [archy@ipa01 ~]$ sudo vim /etc/named.conf ... include "/etc/rndc-key"; controls { inet 172.31.0.1 port 953 allow { 172.31.0.5; } keys ...

SSSD - Debugging PAM permission denied

Sometimes there's weird errors in IT that occur on random chance. I've had such an encounter with SSSD in combination with IPA(+AD-Trust) recently, where only sometimes, a connection to one of the IPA-Servers would fail with this error: Jul 13 13:36:42 ipa02.archyslife.lan sshd[3478]: pam_sss(sshd:account): Access denied for user runner: 4 (System error) Jul 13 13:36:42 ipa02.archyslife.lan sshd[3478]: fatal: Access denied for user runner by PAM account configuration [preauth] In my case, it was only happening sometimes when running a basic system setup role using ansible on every host in the entire environment. This way, there was no consistent pattern besides being the same host every time if it failed. First up, add the 'debug_level=X' to every section required in the /etc/sssd/sssd.conf where X is a number from 1 to 10 with 10 being the most verbose. Afterward, restart sssd and check the logs for any obvious problems. 1) If you are using local users, check the...