RHCE 9.0 Practice Exam: Configuring Ansible Collections

RHCE 9.0 Practice Exam: Configuring Ansible Collections
Photo by Kevin Horvat / Unsplash

πŸ“Œ 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

  1. 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
  2. These collections should be installed in the directory:
    /home/greg/ansible/mycollection
  3. Verify the installed collections
  4. 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 from requirements.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! πŸ“’

Read more