RHCE 9.0 Practice Exam: Installing Software Packages Using Ansible
π Introduction
In this RHCE 9.0 Ansible exam practice guide, we will install and manage software packages across multiple managed nodes. We will use Ansibleβs yum
module to install individual packages, package groups, and update all packages.
This guide includes:
- How to install specific software packages using Ansible
- How to install package groups using Ansible
- How to update all installed packages to the latest version
- How to verify package installations and troubleshoot issues
π‘ What You Will Learn
β
How to use Ansible to install software packages across multiple nodes
β
How to install RPM package groups using Ansible
β
How to update all installed packages to their latest versions
β
How to verify package installations using rpm
and yum
commands
π 1. Task Requirements
π 1.1. Problem Statement
- Create an Ansible playbook named
/home/greg/ansible/packages.yml
to perform the following tasks:- Install
php
andmariadb
on all nodes indev
,test
, andprod
groups. - Install the
RPM Development Tools
package group on all nodes indev
group. - Upgrade all installed packages to the latest version on
dev
group nodes.
- Install
- Verify that all packages have been installed and updated correctly.
π 2. Preparing the Environment
π 2.1. Verify the YUM Module in Ansible
$ 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
module is available for package management.
π 3. Writing the Ansible Playbook
π 3.1. Create the Playbook File
$ vim /home/greg/ansible/packages.yml
π Playbook Breakdown (Step-by-Step)
---
- name: Install PHP and MariaDB
hosts: dev,test,prod
become: yes
tasks:
- name: Install PHP and MariaDB
ansible.builtin.yum:
name:
- php
- mariadb
state: present
- name: Install RPM Development Tools and Upgrade Packages on Dev Nodes
hosts: dev
become: yes
tasks:
- name: Install RPM Development Tools Group
ansible.builtin.yum:
name: "@RPM Development Tools"
state: present
- name: Upgrade all installed packages
ansible.builtin.yum:
name: '*'
state: latest
π Explanation:
become: yes
β Ensures root privileges for package installation.- First Playbook Block (
dev, test, prod
):- Installs
php
andmariadb
on all nodes indev
,test
, andprod
.
- Installs
- Second Playbook Block (
dev
only):- Installs the RPM Development Tools package group.
- Upgrades all installed packages to the latest version.
π 4. Running the Playbook
$ ansible-navigator run /home/greg/ansible/packages.yml -m stdout
π Expected Output
PLAY [Install PHP and MariaDB] **************************************************
TASK [Install PHP and MariaDB] *************************************************
changed: [node1]
changed: [node2]
changed: [node3]
changed: [node4]
PLAY [Install RPM Development Tools and Upgrade Packages on Dev Nodes] *********
TASK [Install RPM Development Tools Group] **************************************
changed: [node1]
TASK [Upgrade all installed packages] *******************************************
changed: [node1]
PLAY RECAP **********************************************************************
node1 : ok=3 changed=3 unreachable=0 failed=0
node2 : ok=1 changed=1 unreachable=0 failed=0
node3 : ok=1 changed=1 unreachable=0 failed=0
node4 : ok=1 changed=1 unreachable=0 failed=0
β Confirms that packages were successfully installed and upgraded across nodes.
π 5. Verifying Software Installation
π 5.1. Verify Installed Packages
$ ansible dev,test,prod -a 'rpm -q php mariadb'
π Expected Output:
node1 | CHANGED | rc=0 >>
php-7.4.19-1.el9.x86_64
mariadb-10.5.13-1.el9.x86_64
node2 | CHANGED | rc=0 >>
php-7.4.19-1.el9.x86_64
mariadb-10.5.13-1.el9.x86_64
β
Confirms that php
and mariadb
are installed on all relevant nodes.
π 5.2. Verify Installed Package Groups
$ ansible dev -a 'yum grouplist'
π Expected Output:
Installed Groups:
RPM Development Tools
β
Confirms that RPM Development Tools
is installed on dev
group nodes.
π 5.3. Verify That All Packages Are Upgraded
$ ansible dev -a 'yum update'
π Expected Output:
...
Nothing to do.
β Confirms that all packages are already up-to-date.
π 6. Common Issues & Troubleshooting
π΄ Issue 1: No package php available
β Solution:
- Ensure that the EX294_BASE and EX294_STREAM repositories are enabled.
Verify that the repositories are correctly configured:
$ ansible all -a 'yum repoinfo'
π΄ Issue 2: Error: Group RPM Development Tools does not exist
β Solution:
- If missing, enable the required repository.
Verify available package groups using:
$ ansible dev -a 'yum group list'
π΄ Issue 3: Packages Not Upgrading
β Solution:
If necessary, force package upgrades:
$ ansible dev -m shell -a 'yum -y upgrade'
Check for held packages:
$ ansible dev -a 'yum check-update'
π 7. Summary
- Created an Ansible playbook (
packages.yml
) to install and upgrade software packages. - Installed
php
andmariadb
ondev
,test
, andprod
nodes. - Installed
RPM Development Tools
ondev
nodes. - Upgraded all installed packages on
dev
nodes. - Verified package installations using
rpm -q
andyum grouplist
. - Troubleshot common package installation and upgrade issues.
π Congratulations! You have successfully managed software packages 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! π₯