RHCE 9.0 Practice Exam: Configuring Your System to Use Default Repositories
π 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
- Create an Ansible playbook named
/home/greg/ansible/yum_repo.yml
to configure YUM repositories on all managed nodes. - 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
- EX294_BASE:
- Ensure both repositories are enabled.
- 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
andEX294_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! π₯