RHCSA Practical Lab Series – Configuring YUM/DNF Repositories

Expertise in Cloud, Networking & DevOps
Photo by Luca Bravo / Unsplash

πŸ” Lab 2: Setting Up Your System to Use Default Repositories

πŸ“Œ Objective

Configure your system to use local repositories by creating a custom YUM/DNF repo file. You will:

βœ” Manually define a repository for BaseOS and AppStream
βœ” Verify repository settings
βœ” Install a package using the new repository


πŸ“Œ Step 1: Create a Custom YUM Repository File

Red Hat uses YUM/DNF package managers to install software. Instead of relying on external repositories, we'll configure local repositories using an internal server.

1️⃣ Open the YUM repository configuration file

[root@node1 ~]# vim /etc/yum.repos.d/rhcsa.repo

πŸ“Œ This command opens the file in Vim editor. If Vim is not installed, use nano instead:

[root@node1 ~]# nano /etc/yum.repos.d/rhcsa.repo

πŸ“Œ Step 2: Define BaseOS and AppStream Repositories

Inside the rhcsa.repo file, add the following configuration:

[Base]
name=Base
baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS
enabled=1
gpgcheck=no

[App]
name=App
baseurl=http://content/rhel9.0/x86_64/dvd/AppStream
enabled=1
gpgcheck=no

πŸ”Ή Explanation of the configuration:

  • [Base] β†’ Defines a repository named Base for essential system packages.
  • name=Base β†’ Display name for the repository.
  • baseurl=http://content/rhel9.0/x86_64/dvd/BaseOS β†’ URL for fetching packages.
  • enabled=1 β†’ Enables this repository.
  • gpgcheck=no β†’ Disables signature verification (not recommended for production systems).
  • [App] β†’ Defines a repository named App for application packages.

πŸ“Œ Tip:

  • Ensure the base URL is accessible (ping content can check connectivity).
  • If working with a local ISO/DVD repository, mount it first:
[root@node1 ~]# mount -o loop /dev/cdrom /mnt

And modify the baseurl accordingly:

baseurl=file:///mnt/BaseOS
baseurl=file:///mnt/AppStream

πŸ“Œ Step 3: Verify Repository Configuration

After saving the file, verify that the repositories are correctly set up:

[root@node1 ~]# yum repoinfo

πŸ”Ή Expected Output (partial):

Repo-id      : Base
Repo-name    : Base
Repo-revision: 123456789
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/BaseOS
Repo-expire  : 172800 second(s) (last: Thu Mar 28 12:45:56 2024)
Repo-filename: /etc/yum.repos.d/rhcsa.repo

Repo-id      : App
Repo-name    : App
Repo-revision: 987654321
Repo-baseurl : http://content/rhel9.0/x86_64/dvd/AppStream
Repo-expire  : 172800 second(s) (last: Thu Mar 28 12:45:56 2024)
Repo-filename: /etc/yum.repos.d/rhcsa.repo

βœ… If the repositories are listed, the configuration is correct.

πŸ“Œ Troubleshooting:

  • If the repository doesn’t appear, check for typos in /etc/yum.repos.d/rhcsa.repo.
  • If using a local DVD, ensure it is mounted (df -h can check).

πŸ“Œ Step 4: Install a Test Package

Now, install a package (vsftpd) to verify that YUM/DNF is working:

[root@node1 ~]# yum -y install vsftpd

πŸ”Ή Expected Output (partial):

Installing       : vsftpd-3.0.3-34.el9.x86_64                      1/1
Verifying        : vsftpd-3.0.3-34.el9.x86_64                      1/1
Installed:
  vsftpd-3.0.3-34.el9.x86_64
Complete!

βœ… If the installation completes successfully, your repository is working.


πŸ“Œ Step 5: Verify Installed Package

To check if the package is correctly installed:

[root@node1 ~]# rpm -q vsftpd

πŸ”Ή Expected Output:

vsftpd-3.0.3-34.el9.x86_64

βœ… This confirms the package was installed from the configured repository.


πŸ“Œ Step 6: Enable and Start the Service (Optional)

If using vsftpd for FTP services, start and enable it:

[root@node1 ~]# systemctl enable --now vsftpd

πŸ”Ή Verify service status:

[root@node1 ~]# systemctl status vsftpd

πŸ”Ή Expected Output (partial):

● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2024-03-28 13:00:00 UTC; 2min ago

βœ… Your FTP server is now running!


πŸ“Œ Step 7: Ensure Repository Persists After Reboot

Reboot the system:

[root@node1 ~]# reboot

After reboot, verify the repository and package installation:

[root@node1 ~]# yum repoinfo
[root@node1 ~]# rpm -q vsftpd

πŸ”Ή Expected Output:

vsftpd-3.0.3-34.el9.x86_64

βœ… If the repo and package persist, everything is correctly configured.


βœ… Final Summary

In this lab, you successfully:
βœ” Created a custom YUM repository configuration
βœ” Verified repository settings
βœ” Installed vsftpd using the configured repo
βœ” Ensured persistent configuration


πŸ“Œ Next Lab: Configuring Firewalld to Allow HTTP on Port 8080

πŸ“© Subscribe for more RHCSA exam labs and hands-on tutorials! πŸš€


Read more