Bookmark this page

Guided Exercise: Enable DNF Software Repositories

Configure your server to get packages from a remote DNF repository, and then update or install a package from that repository.

Outcomes

  • Configure a system to obtain software updates from a classroom server, and update the system to use the latest packages.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start software-repo

Instructions

  1. Use the ssh command to log in to the servera system as the student user. Use the sudo -i command to switch to the root user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ sudo -i
    [sudo] password for student: student
    [root@servera ~]#
  2. Configure the software repositories on servera to obtain custom packages and updates from the following URL:

    1. Use the dnf config-manager command to add the custom packages repository.

      [root@servera ~]# dnf config-manager \
      --add-repo "http://content.example.com/rhel9.3/x86_64/rhcsa-practice/rht"
      Adding repo from: http://content.example.com/rhel9.3/x86_64/rhcsa-practice/rht
    2. Examine the software repository file that the previous command created in the /etc/yum.repos.d directory. Edit the /etc/yum.repos.d/content.example.com_rhel9.3_x86_64_rhcsa-practice_rht.repo file, and add the gpgcheck=0 parameter to disable the GPG key check for the repository.

      [content.example.com_rhel9.3_x86_64_rhcsa-practice_rht]
      name=created by dnf config-manager from http://content.example.com/rhel9.3/x86_64/rhcsa-practice/rht
      baseurl=http://content.example.com/rhel9.3/x86_64/rhcsa-practice/rht
      enabled=1
      gpgcheck=0
    3. Create the /etc/yum.repos.d/errata.repo file to enable the updates repository with the following content:

      [rht-updates]
      name=rht updates
      baseurl=http://content.example.com/rhel9.3/x86_64/rhcsa-practice/errata
      enabled=1
      gpgcheck=0
    4. Use the dnf repolist all command to list all repositories on the system.

      [root@servera ~]# dnf repolist all
      repo id                                                repo name       status
      content.example.com_rhel9.3_x86_64_rhcsa-practice_rht  created by .... enabled
      ...output omitted...
      rht-updates                                            rht updates     enabled
  3. Disable the rht-updates software repository and install the rht-system package.

    1. Use the dnf config-manager --disable command to disable the rht-updates repository.

      [root@servera ~]# dnf config-manager --disable rht-updates
    2. List, and then install, the rht-system package.

      [root@servera ~]# dnf list rht-system
      Available Packages
      rht-system.noarch  1.0.0-1 content.example.com_rhel9.3_x86_64_rhcsa-practice_rht
      [root@servera ~]# dnf install rht-system
      Dependencies resolved.
      ================================================================================
       Package            Arch           Version                Repository       Size
      ================================================================================
      Installing:
       rht-system         noarch         1.0.0-1               content..._rht   3.7 k
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Installed:
        rht-system-1.0.0-1.noarch
      Complete!
    3. Verify that the rht-system package is installed, and note the version number of the package.

      [root@servera ~]# dnf list rht-system
      Installed Packages
      rht-system.noarch  1.0.0-1 @content.example.com_rhel9.3_x86_64_rhcsa-practice_rht
  4. Enable the rht-updates software repository and update all relevant software packages.

    1. Use dnf config-manager --enable to enable the rht-updates repository.

      [root@servera ~]# dnf config-manager --enable rht-updates
    2. Use the dnf update command to update all software packages on servera.

      [root@servera ~]# dnf update
      Dependencies resolved.
      ================================================================================
       Package            Arch           Version                Repository       Size
      ================================================================================
      Upgrading:
       rht-system         noarch         1.0.0-2                rht-updates      7.5 k
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
    3. Verify that the rht-system package is upgraded, and note the version number of the package.

      [root@servera ~]# dnf list rht-system
      Installed Packages
      rht-system.noarch                      1.0.0-2              @rht-updates
  5. Exit from servera.

    [root@servera ~]# exit
    logout
    [student@servera ~]$ exit
    logout
    Connection to servera closed.
    [student@workstation ~]$

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish software-repo

Revision: rh199-9.3-8dd73db