RHCE 9.0 Practice Exam: Configuring Your System to Use Default Repositories

Expertise in Cloud, Networking & DevOps
Photo by Boitumelo / Unsplash

πŸ“Œ Introduction

In this RHCE 9.0 Ansible exam practice guide, we will configure managed nodes to use default YUM repositories using Ansible. This ensures that all required software can be installed smoothly from predefined repositories.

This guide includes:

  • How to create and configure YUM repositories using Ansible
  • How to use yum_repository module for repository management
  • How to verify that repositories are correctly configured
  • How to troubleshoot repository-related issues

πŸ’‘ What You Will Learn

βœ… How to configure YUM repositories on managed nodes using Ansible
βœ… How to automate repository management with yum_repository
βœ… How to verify repository configuration using yum repoinfo
βœ… How to install and validate package installations


πŸ“œ 1. Task Requirements

πŸ“ 1.1. Problem Statement

  1. Create an Ansible playbook named /home/greg/ansible/yum_repo.yml to configure YUM repositories on all managed nodes.
  2. Configure two YUM repositories:
    • EX294_BASE:
      • Description: EX294 base software
      • Base URL: http://content/rhel9.0/x86_64/dvd/BaseOS
      • GPG Key URL: http://content/rhel9.0/x86_64/dvd/RPM-GPG-KEYredhat-release
      • GPG Check: Enabled
    • EX294_STREAM:
      • Description: EX294 stream software
      • Base URL: http://content/rhel9.0/x86_64/dvd/AppStream
      • GPG Key URL: http://content/rhel9.0/x86_64/dvd/RPM-GPG-KEYredhat-release
      • GPG Check: Enabled
  3. Ensure both repositories are enabled.
  4. Verify repository configuration and install a test package (ftp).

πŸ“œ 2. Preparing the Environment

πŸ“ 2.1. Confirm Managed Nodes

$ ansible-inventory --graph

πŸ“Œ Expected Output:

@all:
  |--@dev:
  |  |--node1
  |--@test:
  |  |--node2
  |--@prod:
  |  |--node3
  |  |--node4
  |--@balancers:
  |  |--node5

βœ… Ensures all managed nodes are correctly listed in inventory.


πŸ“ 2.2. Verify YUM Module is Available

$ ansible-doc -l | grep yum

πŸ“Œ Expected Output:

yum                         Manage packages with the `yum` package manager
yum_repository              Add or remove YUM repositories

βœ… Confirms that the required yum_repository module is available.


πŸ“œ 3. Writing the Ansible Playbook

πŸ“ 3.1. Create the Playbook File

$ vim /home/greg/ansible/yum_repo.yml

πŸ“„ Playbook Breakdown (Step-by-Step)

---
- name: Configure YUM Repositories
  hosts: all
  become: yes
  tasks:
    - name: Configure EX294_BASE repository
      ansible.builtin.yum_repository:
        name: EX294_BASE
        description: "EX294 base software"
        baseurl: http://content/rhel9.0/x86_64/dvd/BaseOS
        gpgcheck: yes
        gpgkey: http://content/rhel9.0/x86_64/dvd/RPM-GPG-KEYredhat-release
        enabled: yes

    - name: Configure EX294_STREAM repository
      ansible.builtin.yum_repository:
        name: EX294_STREAM
        description: "EX294 stream software"
        baseurl: http://content/rhel9.0/x86_64/dvd/AppStream
        gpgcheck: yes
        gpgkey: http://content/rhel9.0/x86_64/dvd/RPM-GPG-KEYredhat-release
        enabled: yes

πŸ“Œ Explanation:

  • become: yes β†’ Runs the playbook with root privileges.
  • yum_repository: β†’ Manages YUM repositories.
  • Each repository is defined separately with:
    • name: β†’ Repository name.
    • description: β†’ Repository description.
    • baseurl: β†’ Defines the repository source.
    • gpgcheck: yes β†’ Ensures GPG key validation.
    • gpgkey: β†’ Points to the location of the GPG key.
    • enabled: yes β†’ Ensures repositories are enabled.

πŸ“œ 4. Running the Playbook

$ ansible-navigator run /home/greg/ansible/yum_repo.yml -m stdout

πŸ“Œ Expected Output

PLAY [Configure YUM Repositories] ********************************************

TASK [Configure EX294_BASE repository] ***************************************
changed: [node1]
changed: [node2]
changed: [node3]
changed: [node4]
changed: [node5]

TASK [Configure EX294_STREAM repository] *************************************
changed: [node1]
changed: [node2]
changed: [node3]
changed: [node4]
changed: [node5]

PLAY RECAP ******************************************************************
node1  : ok=2 changed=2 unreachable=0 failed=0
node2  : ok=2 changed=2 unreachable=0 failed=0
node3  : ok=2 changed=2 unreachable=0 failed=0
node4  : ok=2 changed=2 unreachable=0 failed=0
node5  : ok=2 changed=2 unreachable=0 failed=0

βœ… Confirms that repositories have been successfully configured on all nodes.


πŸ“œ 5. Verifying Repository Configuration

πŸ“ 5.1. Check Repository Information

$ ansible all -a 'yum repoinfo'

πŸ“Œ Expected Output:

repo id               repo name                            status
EX294_BASE           EX294 base software                 enabled
EX294_STREAM         EX294 stream software               enabled

βœ… Ensures both repositories are correctly added and enabled.


πŸ“ 5.2. Install a Test Package (ftp)

$ ansible all -a 'yum -y install ftp'

πŸ“Œ Expected Output:

Installed:
  ftp.x86_64 0:0.17-81.el9
Complete!

βœ… Confirms that the repository is functional and can install packages.


πŸ“ 5.3. Verify Installed Package

$ ansible all -a 'rpm -q ftp'

πŸ“Œ Expected Output:

ftp-0.17-81.el9.x86_64

βœ… Ensures that the ftp package was installed correctly from the configured repositories.


πŸ“œ 6. Common Issues & Troubleshooting

πŸ”΄ Issue 1: Cannot retrieve repository metadata

βœ… Solution:

  • Ensure that the base URL is correct.

Check network connectivity using:

$ ansible all -a 'ping -c 4 content/rhel9.0/x86_64/dvd/BaseOS'

πŸ”΄ Issue 2: GPG check failure

βœ… Solution:

Verify that the GPG key file exists and is accessible:

$ ansible all -a 'curl -I http://content/rhel9.0/x86_64/dvd/RPM-GPG-KEYredhat-release'

πŸ“œ 7. Summary

  • Created an Ansible playbook (yum_repo.yml) to configure YUM repositories.
  • Configured EX294_BASE and EX294_STREAM repositories.
  • Verified repository setup using yum repoinfo.
  • Tested package installation with ftp.
  • Troubleshot common repository-related issues.

πŸš€ Congratulations! You have successfully configured YUM repositories using Ansible for RHCE 9.0! πŸš€
πŸ“’ If you found this guide helpful, share it with your RHCE 9.0 study group! πŸ“’

πŸ”₯ Good luck on your RHCE 9.0 exam! πŸ”₯

Read more