Scenario: Configure Inventory and Run Ad-Hoc Tasks
You are setting up Ansible for a small fleet of servers. You must verify Ansible is installed, inspect the inventory, test connectivity with the ping module, gather facts, install a package remotely, and copy a configuration file to managed hosts. Ad-hoc commands are tested on the RHCE exam alongside playbooks.
Learning Objectives:
RHCE EX294 — Ansible
Setup: Verify Ansible installation and configuration
Inventory: View and understand static inventory files
Connectivity: Test reachability with the ping module
Ad-Hoc: Execute remote tasks without playbooks
📋 Step-by-Step Instructions
Step 1: Verify Ansible Installation
🎯 Goal: Confirm Ansible is installed and check version
🎓 Checkpoint: You used Ansible ad-hoc commands with ping, setup, yum, and copy modules — essential RHCE skills.
Ansible Control Node
Terminal
Inventory Dashboard
Host Status
Activity Log
ansible@control:~$
Inventory Overview
Inventory FileNot viewed
Total HostsUnknown
GroupsUnknown
ConnectivityNot tested
Inventory Contents
View inventory to populate this panel.
Managed Hosts
HostGroupPingStatus
Recent Activity
[--:--:--]Lab session started. Ready for commands.
Progress:0/6 tasks completed
Score: 0/100
🎉 After Completing All Steps:
1. Click "Validate Configuration" to check completed vs pending tasks. 2. Use Inventory Dashboard and Host Status to verify visually. Tip: Ad-hoc commands are quick one-liners; playbooks are for repeatable automation.
Lab 20: Ansible Playbook Development
Advanced / Terminal + GUI
Scenario: Write and Execute an Ansible Playbook
You need to automate web server deployment. Create a playbook that installs httpd, starts the service, deploys content, and opens the firewall. You will check syntax, run the playbook, and verify the results. Playbook writing is the primary RHCE (EX294) skill.
Learning Objectives:
RHCE EX294 — Playbooks
Playbooks: View and understand YAML playbook structure
Syntax: Validate playbook syntax before execution
Execution: Run playbooks and interpret output
Verification: Check mode (dry run) and verbose output
📋 Step-by-Step Instructions
Step 1: View the Playbook
🎯 Goal: Inspect a pre-written playbook for web server deployment
💻 View playbook: cat /home/ansible/webserver.yml
💡 Tip: Playbooks use YAML syntax. Indentation matters — use spaces, never tabs.
Step 2: Check Playbook Syntax
🎯 Goal: Validate YAML and Ansible syntax before running
🎓 Checkpoint: You wrote, validated, ran, verified, and debugged an Ansible playbook — the core RHCE workflow.
Ansible Control Node
Terminal
Playbook Viewer
Run History
Activity Log
ansible@control:~$
webserver.yml
View playbook to populate this panel.
Playbook Run Summary
Syntax ValidNot checked
Last RunNever
Run ResultN/A
Check ModeNot run
Verbose RunNot run
Recent Activity
[--:--:--]Lab session started. Ready for commands.
Progress:0/6 tasks completed
Score: 0/100
🎉 After Completing All Steps:
1. Validate configuration to review playbook execution status. 2. Use Playbook Viewer and Run History for visual inspection. Tip: The RHCE exam is entirely Ansible-based — practice writing playbooks from scratch.
Lab 21: Ansible Roles & Variables
Advanced / Terminal + GUI
Scenario: Build and Use Ansible Roles
Your team wants reusable automation. You must initialize a role directory structure, inspect it, create a playbook that uses the role with variables, run it, then use ansible-galaxy to install a community role. Roles and variables are heavily tested on the RHCE exam.
Learning Objectives:
RHCE EX294 — Roles
Roles: Initialize and understand role directory structure
Variables: Use role defaults and playbook variables
Galaxy: Install roles from Ansible Galaxy
Execution: Run role-based playbooks
📋 Step-by-Step Instructions
Step 1: Initialize a Role
🎯 Goal: Create a new role directory structure
💻 Create role: ansible-galaxy role init /home/ansible/roles/webconfig
💡 Tip:ansible-galaxy role init creates the standard directory structure: tasks, handlers, defaults, vars, files, templates, meta.
Step 2: View Role Directory Structure
🎯 Goal: Understand the role layout
💻 Show tree: find /home/ansible/roles/webconfig -type f | head -20
💡 Tip: Key directories: tasks/main.yml for logic, defaults/main.yml for default variables, handlers/main.yml for handlers.
Step 3: View the Role-Based Playbook
🎯 Goal: Inspect a playbook that references the webconfig role with variables
💻 View playbook: cat /home/ansible/site.yml
💡 Tip: Roles are referenced in the roles: section. Variables can override role defaults.
Step 4: Run the Role-Based Playbook
🎯 Goal: Execute the site playbook that uses the webconfig role
💻 Run playbook: ansible-playbook /home/ansible/site.yml -i /home/ansible/inventory
💡 Tip: Role tasks execute in order from tasks/main.yml. Handlers trigger at the end of the play.
Step 5: Install a Galaxy Role
🎯 Goal: Install a community role from Ansible Galaxy
💻 Install role: ansible-galaxy role install geerlingguy.firewall -p /home/ansible/roles
⚠️ Exam Note: On the RHCE exam, you may need to install roles from a provided requirements.yml file.
Step 6: List Installed Roles
🎯 Goal: Verify all roles are available
💻 List roles: ansible-galaxy role list -p /home/ansible/roles
🎓 Checkpoint: You created a role, ran a role-based playbook, and managed Galaxy roles — essential RHCE skills.
Ansible Control Node
Terminal
Roles Dashboard
Site Playbook
Activity Log
ansible@control:~$
Role Management
webconfig roleNot created
geerlingguy.firewallNot installed
Site playbook runNot run
Roles listedNo
Role Structure
Initialize a role to see its structure.
site.yml
View site.yml to populate this panel.
Recent Activity
[--:--:--]Lab session started. Ready for commands.
Progress:0/6 tasks completed
Score: 0/100
🎉 After Completing All Steps:
1. Validate to check role creation, playbook execution, and Galaxy installs. 2. Use Roles Dashboard and Site Playbook viewer for visual inspection. Tip: Roles are the most common way to organize Ansible code in production.
Modal
Confirm Reset
Are you sure you want to reset this lab? This will:
Clear all terminal output
Reset all completed tasks
Reset Ansible inventory, playbook, and role simulated configurations