RHCE 9.0 Practice Exam: Configuring Ansible Collections
π Article Overview
This tutorial is designed for RHCE 9.0 certification candidates and explains in detail how to configure and install Ansible collections from local sources.
What You Will Learn:
- How to create and configure
requirements.yml
for collection installation - How to install collections in a custom directory
- How to verify installed collections using
ansible-navigator
- Common issues and troubleshooting tips
- Detailed step-by-step guide with explanations
π 1. Task Requirements
π 1.1. Problem Statement
- Install the following Ansible collections:
redhat-insights-1.0.7.tar.gz
community-general-5.5.0.tar.gz
redhat-rhel_system_roles-1.19.3.tar.gz
- These collections should be installed in the directory:
/home/greg/ansible/mycollection
- Verify the installed collections
- Check documentation for a specific module in the installed collections
π 2. Preparing the Environment
Before proceeding, ensure that:
- Ansible is installed on the control node (
control
). - The collections are available at
http://classroom/materials/
. - You have
ansible-navigator
installed for verification.
π 3. Creating requirements.yml
vim /home/greg/ansible/requirements.yml
π Add the following content:
---
collections:
- name: http://classroom/materials/redhat-insights-1.0.7.tar.gz
- name: http://classroom/materials/community-general-5.5.0.tar.gz
- name: http://classroom/materials/redhat-rhel_system_roles-1.19.3.tar.gz
π Key Points:
- The
collections:
key lists all collections to be installed. - We provide direct URLs to
.tar.gz
files instead of using Ansible Galaxy.
Save and exit (ESC
-> :wq
)
π 4. Installing Ansible Collections
Now, install the collections to the custom directory /home/greg/ansible/mycollection
:
ansible-galaxy collection install -r /home/greg/ansible/requirements.yml -p /home/greg/ansible/mycollection
π Key Points:
-r requirements.yml
: Reads the collection list fromrequirements.yml
-p /home/greg/ansible/mycollection
: Installs collections in a custom directory
β Expected Output
Starting galaxy collection install process
Process install dependency map
Downloading http://classroom/materials/redhat-insights-1.0.7.tar.gz to /home/greg/.ansible/tmp/...
Installing collection redhat.insights:1.0.7 from /home/greg/.ansible/tmp/...
Downloading http://classroom/materials/community-general-5.5.0.tar.gz...
Installing collection community.general:5.5.0...
Downloading http://classroom/materials/redhat-rhel_system_roles-1.19.3.tar.gz...
Installing collection redhat.rhel_system_roles:1.19.3...
π 5. Verifying Installed Collections
To confirm the collections were installed correctly:
ansible-navigator collections
π Expected Output
ansible_collections:
community.general
redhat.insights
redhat.rhel_system_roles
β If the collections are listed, the installation was successful!
π 6. Checking Collection Documentation
To view documentation for a specific module, such as community.general.filesystem
:
ansible-navigator doc community.general.filesystem -m stdout
π Expected Output
> FILESYSTEM (MODULE)
Manage filesystems on remote machines
EXAMPLES:
- name: Create a new ext4 filesystem
community.general.filesystem:
fstype: ext4
dev: /dev/vdb1
β If the documentation is displayed, the module is correctly installed.
π 7. Scoring Criteria
Step | Description | Score |
---|---|---|
1. Create requirements.yml |
Defines collections with correct URLs | 5 points |
2. Install collections to a custom path | Ensures correct directory installation | 10 points |
3. Verify collections with ansible-navigator |
Confirms successful installation | 10 points |
4. Check module documentation | Ensures collection modules are accessible | 10 points |
β Total Score: 35 points
π 8. Common Questions & Troubleshooting
β Q1: How do I remove a collection if something goes wrong?
β
Run:
ansible-galaxy collection remove <collection_name>
For example:
ansible-galaxy collection remove redhat.insights
β Q2: What if ansible-navigator collections
does not show my collections?
β
Ensure the collections/ansible_collections
directory exists in /home/greg/ansible/mycollection
:
ls /home/greg/ansible/mycollection/ansible_collections
If the directory is missing, re-run:
ansible-galaxy collection install -r /home/greg/ansible/requirements.yml -p /home/greg/ansible/mycollection
β Q3: How do I check the version of an installed collection?
β
Run:
ansible-galaxy collection list
This will display the version of each installed collection.
π Congratulations! You have successfully configured Ansible collections for RHCE 9.0 certification! π
π’ If you found this guide helpful, share it with your RHCE 9.0 study group! π’