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 '{print $1}' > names.rpms

Note that without | awk '{print $1}' the command will show the name and version for all packages. 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
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
core-0                                                                    | 3.6 kB  00:00:00
minimal                                                                   | 2.5 kB  00:00:00
minimal/primary_db                                                        | 816 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package bind-libs.x86_64 32:9.9.4-72.el7 will be updated
---> Package bind-libs.x86_64 32:9.9.4-73.el7_6 will be an update
---> Package bind-libs-lite.x86_64 32:9.9.4-72.el7 will be updated
---> Package bind-libs-lite.x86_64 32:9.9.4-73.el7_6 will be an update
---> Package bind-license.noarch 32:9.9.4-72.el7 will be updated
...
...
Transaction Summary
=============================================================================================
Install   2 Packages
Upgrade  50 Packages

Total download size: 140 M
Is this ok [y/d/N]:

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
   centos7-x86_64

and the profile details

[root@master ~]# cobbler profile report --name centos7-x86_64
Name                           : centos7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : centos7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm

It can be seen that the profile centos7-x86_64 does not contain any repository (see Repos).

  • Add the minimal repository to this profile with:

[root@master ~]# cobbler profile edit --name=centos7-x86_64 --repo=minimal
[root@master ~]# cobbler sync

now the profile’s report will contain the minimal repository

[root@clm2 ~]# cobbler profile report --name centos7-x86_64
Name                           : centos7-x86_64
...
Repos                          : ['minimal']
Server Override                : <<inherit>>
...

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.