Updating base packages
In this exercise you will configure a local software repository for the packages already installed on the compute nodes to update them. As we saw in the previous section, the creation of the local repository consist of three main steps:
Create the folder for the repository
Download a set of rpms into the repository folder
Create and populate the repository database (
createrepo
command)
Let’s begin creating the folder /root/minimal
in the master node. Then, in order to know the list of packages to be downloaded, capture a list of the packages already installed in one compute node. For instance for node c01
(commands in master):
[root@master ~]# mkdir minimal
[root@master ~]# cd minimal
[root@master ~]# ssh c01 yum list installed | awk 'NR > 1 {print $1}' > names.rpms
Note that without | awk 'NR > 1 {print $1}'
the command will show the name and version for all packages, plus a header.
In our case, as we want to update the system, names are enough.
Now, download the packages in the names.rpms
file.
[root@master ~]# yumdownloader `cat names.rpms`
Finally, create and populate the repository database:
[root@master ~]# createrepo .
Using Cobbler to manage repositories
Up to this point the just created minimal
repository is not yet exposed in the web server.
In contrast with the previous exercise, instead of adding it manually to the web server in /var/www/html
, we will use Cobbler to do that.
By doing it via Cobbler, we will have additional features, including:
Systems and profiles can be configured to automatically add the necessary .repo files in deployment time.
Synchronization is made easy with the command
cobbler reposync
; With this command the repository folder is copied into the web server/var/www/cobbler/repo_mirror
.
In order to add the repository minimal
to Cobbler’s database, run the following command (if the folder minimal
is located in
/root
):
[root@master ~]# cobbler repo add --name=minimal --mirror=/root/minimal
Now, run the command to expose the repository to the web server with cobbler:
[root@master ~]# cobbler reposync --only=minimal
After this command is done, check that the location /var/www/cobbler/repo_mirror/minimal
exists and contains the rpm
packages. Let’s now ssh into a compute node and use the minimal
repository to update the system, for instance for node c01
:
[root@master ~]# ssh c01
[root@c01 ~]# yum update
will show No packages marked for update:
[root@c01 ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
core-0 | 3.6 kB 00:00:00
No packages marked for update
Once again, as in The Smallest Example explained, the repository can be used on the compute nodes by adding the necessary .repo
file containing:
[root@c01 yum.repos.d]# cat minimal.repo
[minimal]
name=minimal
baseurl=http://192.168.16.1/cobbler/repo_mirror/minimal
enabled=1
gpgcheck=0
priority=1
in /etc/yum.repos.d/
. After this procedure is complete, the yum update
command will now show new updates, meaning that the
updated packages from minimal
overwrite the older ones in core-0
.
[root@c01 ~]# yum update
minimal 6.8 MB/s | 850 kB 00:00
Dependencies resolved.
===================================================================================
Package Arch Version Repo Size
===================================================================================
Installing:
kernel x86_64 4.18.0-553.54.1.el8_10 minimal 10 M
Upgrading:
NetworkManager x86_64 1:1.40.16-19.el8_10 minimal 2.3 M
NetworkManager-libnm x86_64 1:1.40.16-19.el8_10 minimal 1.9 M
NetworkManager-team x86_64 1:1.40.16-19.el8_10 minimal 160 k
NetworkManager-tui x86_64 1:1.40.16-19.el8_10 minimal 355 k
autofs x86_64 1:5.1.4-114.el8_10.3 minimal 719 k
bind-libs x86_64 32:9.11.36-16.el8_10.4 minimal 176 k
...
Transaction Summary
===================================================================================
Install 3 Packages
Upgrade 122 Packages
Total download size: 676 M
Is this ok [y/N]: y
Note
If no pakages were found for update, try to rebuild the yum cache by running yum makecache
As we said before, the necessary .repo
files can be automatically added in deployment time.
To do so, simply add the repository to a Cobbler system or profile.
There is an advantage of adding the repository to a profile rather to a system.
while a system is a single object in cobbler, profiles can group systems, and therefore, adding the repository to a given profile will affect to all these systems.
In this example we will add the minimal
repository to one existent profile.
Check the available profiles:
[root@master ~]# cobbler profile list
almalinux8-compute
almalinux8-x86_64
and the profile details
[root@master ~]# cobbler profile report --name=almalinux8-compute
Name : almalinux8-compute
Automatic Installation Template : compute.ks
Automatic Installation Metadata : {}
TFTP Boot Files : {}
Comment :
DHCP Tag : <<inherit>>
Distribution : <<inherit>>
Enable gPXE? : 0
Enable PXE Menu? : <<inherit>>
Fetchable Files : {}
DHCP Filename Override : <<inherit>>
Kernel Options : {}
Kernel Options (Post Install) : {}
Management Classes : <<inherit>>
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Next Server Override : <<inherit>>
Owners : ['admin']
Parent Profile : almalinux8-x86_64
Proxy : <<inherit>>
Red Hat Management Key : <<inherit>>
Repos : <<inherit>>
...
It can be seen that the profile almalinux8-compute
does not contain any repository (see Repos
).
Add the
minimal
repository to this profile with:
[root@master ~]# cobbler profile edit --name=almalinux8-compute --repo=minimal
[root@master ~]# cobbler sync
now the profile’s report will contain the minimal
repository
[root@master ~]# cobbler profile report --name=almalinux8-compute
Name : almalinux8-compute
...
Repos : ['minimal']
...
With this configuration, the next time a compute node is reimaged (reinstalled) the necessary .repo
files containing the minimal
repository information will be automatically added at installation time.
This also means that a fresh installation will contain the most updated packages, no further updates are needed.