
Master Ansible automation for Linux infrastructure by setting up AWS environments, managing inventories with Ansible Navigator, and writing secure playbooks with YAML, loops, variables, and vault.
Set up an Ansible environment on AWS and configure a control node on EC2. Install Ansible, enable passwordless SSH, and manage two Ubuntu hosts via inventory and ad hoc commands.
Launch an EC2 instance running Red Hat Enterprise Linux 9 as an Ansible control node, create a key pair, and set 10 GB storage with default networking.
Access the Ansible control node via SSH, then install Ansible from the default AppStream repository on RHEL 9.5 using sudo dnf install des core, with AWS EC2-user and private key.
Install and verify Ansible, configure a control node, launch two Ubuntu client instances on AWS, and establish SSH access and initial system updates as preparation for passwordless authentication.
Enable ssh communication by configuring password and public key authentication on both Ansible client machines, restart ssh, and prepare for passwordless authentication from the control node.
Create a common user account named Tech Star on the Ansible control node and all client machines, configure /etc/hosts entries, and verify password-based SSH access.
Generate an ssh key pair with ssh-keygen -t rsa -b 2048 on node, placing keys in .ssh, then copy the public key to Ansible clients for password-free access and inventory.
This lecture guides creating the host inventory file on the Ansible control node, defining a dev group with two clients, and listing hosts to verify connectivity.
Test the connection between the Ansible control node and the client using ad hoc commands with the ping module on the dev inventory group, confirming hosts are reachable.
Practice Ansible ad hoc commands with the command module to view uptime and IP addresses on the dev group, noting normal user limits for firewall status.
Use an ansible ad hoc command with --become to elevate to root and run ufw status, then edit sudoers on managed nodes to allow tech start passwordless sudo.
Define Ansible inventory as the list of servers Ansible connects to for automation. Use static files or dynamic sources, in ini or yml formats, with groupings like web and database.
Compare static and dynamic inventories in Ansible: static inventory uses a fixed host list in an inventory file, while dynamic inventory fetches hosts from cloud providers for changing environments.
Add host entries to the default inventory file at CTC slash ansible slash host, grouping servers into prod, dev, test, and web server; verify with ansible --list-hosts all.
Configure ansible inventory to add hosts with custom ports and users by defining a db group and specifying ansible_user Sam for targeted hosts via a nonstandard ssh port like 12345.
Learn how to define multiple hosts in an ansible inventory using range syntax for ip addresses and hostnames, creating groups and reducing manual entries.
Learn to use Ansible Navigator, a CLI tool with a text user interface, to run playbooks, view inventories and logs, and manage automation workflows on RHEL 9.
Explore Ansible Navigator modes—run the playbook, inspect inventory, view collections, and access module documentation like the ping module.
Compare ansible-navigator and ansible-playbook, highlighting gui-based, text-based interface, execution environment use, structured task logs, inventory browsing, built-in module docs, and easier debugging for Red Hat Ansible Automation Platform users.
Install ansible navigator by confirming the Ansible core is installed, then install python3 and pip, use pip3 install ansible-navigator --user, and verify with ansible-navigator --version.
Set up Ansible Navigator, a command line tool with a text user interface to run playbooks, browse inventories, review logs, and manage automation workflows using podman for images.
View the inventory content with Ansible Navigator in stdout mode, listing servers by group and validating hosts to confirm presence in the inventory.
Explore inventory in a text user interface using ansible-navigator, view groups and hosts from an inventory file, and navigate with numbers to inspect dev, test, and other servers.
Configure Ansible basics by managing ansible.cfg and ansible-navigator.yml in your project, learn how to identify the active configuration with ansible --version, and understand default module search paths and locations.
Identify the default Ansible configuration location and verify it with ansible --version. Create a user-level .ansible.cfg in the home directory and set inventory, remote_user, host_key_checking, and retry_files_enabled.
Define the inventory file path in the Ansible config and place the inventory at that location. Use Ansible --list-hosts to verify the dev group and all hosts.
Configure ansible-navigator with a default inventory file and execution environment by editing ansible-navigator.yml, enabling direct local execution instead of running in a container.
Learn to run an ansible playbook with ansible navigator on a Red Hat RHEL 9 node, via container and directly on host, to ping dev group clients and test connectivity.
Validate connectivity from the Ansible server to the dev group hosts using Ansible Navigator, exploring containerized and host-based execution methods with a ping playbook and inventory.
Practice using ansible navigator's text user interface to run a playbook by pressing colon and run, specify the inventory path, and validate the output, then browse dev group hosts.
Automate repetitive server tasks with Ansible playbooks, using modules, tasks, variables, and elevated privileges. Run and validate playbooks from the CLI or Ansible Dash, with a guided hands-on exercise.
Define automated tasks to run on remote hosts with a plain text yaml playbook, using Ansible modules to install software, manage services, and copy files in a single command.
Understand how to format an Ansible playbook in yml, target all hosts or a group, enable become, and create a user with the built-in user module using state present.
Create your first Ansible playbook to ensure a DevOps user exists on managed hosts, using the user module, become, and Ansible Navigator, with verification and removal steps.
Execute an Ansible Navigator run with execution environment enabled to run the user.yml playbook using a specified inventory file, and verify the DevOps user is created on both clients.
Create an ansible playbook to create /opt/scripts with mode 077 using the ansible.builtin.file module, and verify syntax with a playbook syntax check.
Define, manage, and use Ansible variables and facts to create reusable playbooks, capture command output, and override values from the command line across many servers.
Explore how Ansible variables act as containers for values to avoid hard coding and enable dynamic configurations across playbooks, inventories, and command line.
Learn the rules for valid Ansible variable names by starting with a letter, allowing letters, numbers, and underscores, and avoiding spaces, special characters, or dots; apply recommended fixes using underscores.
Define group variables in an Ansible inventory by adding a web servers group with a vars section. Set a, b, and http_port to all hosts in the group.
Create a group_vars directory with a YAML file named after the group to apply http_port and doc_root to all hosts in the prod group.
Define per-host variables in the inventory by appending them to the host entry, such as ansible_host=192.168.1.1; or use a host_vars directory with a file named server one.yml to define variables.
Define variables at the playbook level or per task using set_fact for task-specific values. Use debug to show how variables flow across tasks in a dev group.
Override existing variables from the command line with the -e extra vars flag for dynamic values and environment deployments, using the ansible playbook syntax, without changing playbooks.
Override variables from the command line using ansible-navigator to run a playbook, specify inventory and user, and show that CLI-provided values are applied to the playbook.
Learn to use dictionaries as variables in Ansible by organizing data as key–value pairs, such as user_info with name, uid, and shell, and access via dot notation.
Learn to define and use dictionary variables in an Ansible playbook, access keys like name, uid, and shell, and run the playbook on dev group hosts with Ansible navigator.
Capture command output in Ansible using the register keyword and store it in a variable, such as disk_output. Access the output text via disk_output.stdout.
Capture the disk space output with a registered variable, show using debug, and install results via dnf, with root privileges and ansible navigator.
Learn to securely manage secrets in Ansible with Ansible Vault, encrypting passwords, keys, and credentials. Encrypt or decrypt files or variables and run encrypted playbooks.
Secure Ansible playbooks in this practice lab by creating an encrypted file with a password and a simple debug task that prints a message.
Learn to manage secrets with Ansible vault by creating an encrypted file and supplying the vault password from a password file, then decrypt to view the content.
Edit encrypted files with ansible vault edit using the file name and password, view content with vault view, and encrypt plain text files with vault encrypt.
Secure user creation with Ansible Vault by building a playbook that creates a linux user with a hashed password, encrypting the playbook, and running it via Ansible Navigator.
Create a playbook to securely add a user on managed hosts using the built-in user module, vaulting the password hash and encrypting the playbook with Ansible vault.
Execute this playbook using Ansible Navigator run, with -m stdout and --playbook-artifact false, vault-id prompt, inventory, and vault password at runtime; verify Deepak user on clients before proceeding.
Learn to securely create user accounts with Ansible Vault by running a hands-on playbook, validating on multiple clients, and testing access with the hash password configured in the playbook.
Learn to use loops and conditionals in Ansible to control tasks, iterate over items and dictionaries, and use registered variables to drive smarter playbooks.
Iterate tasks with loops in Ansible to run the same task for multiple items, using the loop keyword to install packages like httpd, git, and wget.
Demonstrate an Ansible playbook that uses a loop to install multiple packages (nginx, git, curl) on two dev servers via the package module.
Loop with a variable list demonstrates defining a list variable and looping over its items to run the same task, making the playbook flexible and easier to maintain.
This hands-on session demonstrates iterating a variable list with loops in an ansible playbook and using ansible navigator to install mail services on a targeted inventory across client machines.
Learn to loop over a list of dictionaries in Ansible, understand dictionaries and key-value pairs, define a users variable as that list, and create users while assigning them to groups.
Loop over a list of dictionaries in an ansible playbook to create linux users and assign them to groups. The lab covers idempotent group and user management with built-in modules.
Execute a playbook with Ansible Navigator to create users Alice, Bob, and Charlie, assign them to admin, dev, and QA groups, and verify IDs across two dev group hosts.
Explore earlier-style loop keywords in Ansible, including with_items, with_dict, and with_file, and see how they iterate over lists, dictionaries, and files to manage packages, users, and file contents.
discover how to use register with loop in Ansible to create multiple temporary files, capture results in a variable, and display outcomes with debug.
Run a playbook with Ansible Navigator to create multiple files and capture results using register with loops. Observe logs and messages showing file one, file two, and file three creation.
This training module is not authorized or affiliated with Red Hat, Inc. It is an independent educational resource designed to help learners prepare for the Red Hat Certified Engineer (RHCE) exam.
This course is part of the Red Hat Certified Engineer (RHCE) learning path and corresponds to RH294 Red Hat Ansible Automation.
The Red Hat Ansible Automation (RH294) course focuses on essential automation skills required to become a full-time Linux administrator or DevOps engineer and to validate those skills through the Red Hat Certified Engineer exam.
This course goes deeper into Enterprise Linux automation using Ansible, including playbooks, roles, variables, templates, inventories, and troubleshooting.
Part 1: Newly added lectures based on Red Hat Enterprise Linux 9 (RH294)
Part 2: Original lectures based on Red Hat Enterprise Linux 8 (RH294)
Part 1: Course Content
Red Hat Ansible Automation Training – RHEL 9 (RH294)
Ansible Setup in AWS Environment
Getting Started with This Section
Set Up an EC2 Instance as an Ansible Control Node
Install Ansible on Control Node
Set Up Two Client Machines as Managed Nodes
Enable SSH communication
Add Same User to All Machines
Generate SSH Key for Password-Free Access
Create Host Group in Inventory File
Test Connection Using Ad-Hoc Commands
Guided Exercise - 1
Guided Exercise - 2
Mastering Ansible Inventory and ansible-navigator: A Step-by-Step guide
Getting Started with This Section
Understanding Ansible Inventory
Static vs Dynamic Inventory in Ansible
How to Add Host Entries in Inventory
Adding Hosts with Custom Ports and Users
Using Host Ranges in Ansible Inventory
Getting Started with Ansible Navigator: Installation, Modes, and Usage
Ansible Navigator: Quick Overview
Navigator Modes Explained: Run, Inventory, Collections & More
ansible-navigator vs ansible-playbook: Key Differences
Installing ansible-navigator
Setting Up ansible-navigator
View Inventory with ansible-navigator (stdout mode)
Explore Inventory in TUI Mode Using ansible-navigator
Managing Ansible Configuration Files
Configuring Ansible Basics
Setting Up User-Specific Ansible Configuration
Defining Inventory File Path in Ansible Config
Working with ansible-navigator Configuration File
Ansible Navigator - Scenario Based Guided Lab
Getting Started with this Section
Hands-On Lab 1
Hands-On Lab 2
Hands-On Lab 3
Hands-On Lab 4
Implementing an Ansible Playbook
Getting Started with this Section
What is an Ansible Playbook
Ansible Playbook Syntax and Formatting
Lab Exercise: Creating Your First Ansible Playbook
Lab Exercise: Run Playbook Using Ansible Navigator
Lab Exercise: Ansible Navigator with EE Enabled
Lab Exercise: Directory Creation Using Playbook
Ansible Variable and Facts
Getting Started with this Section
Introduction to Ansible Variables
Valid and Invalid Variable Names
Defining Group Variables in Ansible Inventory
Defining Group Variables via group_vars
Defining Host Variables
Defining Variables in Ansible Playbooks
Overriding Variables with ansible playbook
Overriding Variables with ansible-navigator
Use Dictionaries as Variables in Ansible
Hands-On: Use Dictionaries
Capturing Output with Registered Variables
Hands-On: Capturing Output with register
Managing Secrets in Ansible
Introduction to Ansible Vault and Secret Storage
Ansible Vault: File Encryption
Ansible Vault: Using Password Files for Encryption
Ansible Vault: Modify Encrypted Files
Hands-On 1: Secure User Creation with Ansible Vault
Hands-On 2: Secure User Creation with Ansible Vault
Hands-On 3: Secure User Creation with Ansible Vault
Hands-On 4: Secure User Creation with Ansible Vault
Hands-On 5: Secure User Creation with Ansible Vault
Task Control Implementation in Ansible
Getting Started with this Section
Task Iteration with Loops in Ansible
Hands-On: Installing Multiple Packages Using Loops
Loop with a Variable List
Hands-On: Iterating Variable Lists with Loops
Ansible Loops with List of Dictionaries
Hands-On 1: Looping Through Dictionary Lists
Hands-On 2: Looping Through Dictionary Lists
Earlier-style Loop Keywords: with_items, with_dict etc
Hands-On 1: Register with Loop in Ansible
Hands-On 2: Register with Loop in Ansible
Implementing Conditional Task Control
Running Tasks Conditionally
Hands-On: Install Apache Only if RAM > 2GB
Hands-On: Run Task Only if OS is Debian
Hands-On: Run Task When web_enabled is True
Hands-On: Run Task if RAM > 2GB AND OS is CentOS
Hands-On: Run Task if OS is Ubuntu OR Debian
Deploying Files to Managed Hosts
Describing File Modules
Hands-On: Create a Directory
Hands-On: Copy a File to Remote
Hands-On: Fetch File From Remote to Local
Hands-On: Insert Line Using lineinfile Module
Hands-On: Insert Config Block Using blockinfile Module
Deploying Custom files with Jinja2 Templates
Introduction to Jinja Templating in Ansible
Control Structures with Loops and Variables
Hands-On: Control Structures
Using Ansible Facts in Jinja2 Templates
Guided Exercise - 1
Guided Exercise - 2
Guided Exercise - 3
Managing Complex Plays and Playbooks
Selecting Hosts with Host Patterns
Hands-On: Defining Ansible Host Patterns
Hands-On: Defining Ansible Host Patterns
Including and Importing Files
Include vs Import in Ansible
Import_playbook in Ansible
Hands-On 1: Include and Import Files – Apache Setup
Hands-On 2: Include and Import Files – Apache Setup
Hands-On 3: Include and Import Files – Apache Setup
Guided Exercise: Apache Web Server Automation
Overview of the Project
Hands-On Practice 1
Hands-On Practice 2
Modular Playbook Design with Roles and Collections
Describing Role Structure
Hands-On Project: Automate Server Hardening
Hands-On: Roles for User and Timezone Setup
Hands-On: Role for Firewall Custom Port Access
Hands-On: Role for SSH Configuration
Hands-On: Use Roles in a Playbook
Hands-On: Execute the Playbook
Hands-On: Verify Changes on Client Node
Using External Ansible Roles from Ansible Galaxy
Overview: Using External Roles from Galaxy
Hands-On: Install External Role geerlingguy.nginx
Hands-On: Create a Playbook with External Role
Hands-On: Run Playbook with ansible-playbook
Hands-On: Run Playbook with ansible-navigator
Troubleshooting in Ansible: Debugging and Error Handling
Analyzing Ansible Log Files
Using the debug Module for Troubleshooting
Handling Errors Gracefully in Ansible
Debugging Techniques in Ansible
Using check_mode to Test Playbook Execution
Part 2: Course Content
Red Hat Ansible Automation Training – RHEL 8 (RH294)
Introduction
What is Ansible?
Ansible Limitations
Ansible Architecture
Overview of Ansible Setup
Quiz1
Ansible Installation
Installing Ansible
Guided Exercise
Deploying Ansible
Ansible Components
- Ansible Configuration
- Host Inventory
- Core Modules
- Custom Modules
- Playbooks
- Connection Plugins
Ansible Host Inventories
Guided Exercise: Building an Ansible Inventory
Customizing Ansible
Managing Ansible Configuration files
AD HOC Commands With Ansible
Syntax of Ad Hoc Command
Ansible Modules
Ansible Command-line Options
Idempotent behavior of Ansible Modules
Guided Exercise
Implementing Playbooks
Overview of Playbook Syntax
Writing and Running Playbooks
Lab - Write a Simple Playbook, User Creation task
Guided Exercise - Web Server Installation
Guided Exercise - Multiple Tasks
Managing Variables & Facts in Ansible
Overview of variables in Ansible
Lab-Managing Variables
Hosts & Group variables
Lab on Host & Group Variables
Ansible Facts
Managing Secrets
Ansible Vault Command
Lab - Edit, encrypt, decrypt, and view files
Guided Exercise - 1
Guided Exercise - 2
Implementing Task Control
Manage task control, handlers, and task errors in Ansible Playbooks.
Task Iteration with Loops
Lab - Simple Loops, Loops over a List of Hashes
Lab - with_items, with_file
Lab - using register variables with loops
Lab - Running tasks Conditionally using when statement
Lab - when statement using ansible facts
Lab - Testing multiple conditions using when statement
Lab - "in" keyword
Lab - Combining Loops & Conditional Tasks
Lab - Combining Conditionals & Register Varaibles
Ansible Handlers
Lab - Ansible Handlers
Handling Task Failures
Managing task errors in plays - ignore_errors
Specifying task failure Conditions
failed_when keyword
changed_when keyword
Guided Exercise
Deploying files to managed hosts
Describing files modules
Lab - copy & fetch modules
Lab - lineinfile & blockinfile modules
Lab - modify file attributes such as SELinux Context
Lab - stat module
Guided Exercise
Deploying Custom files with Jinja2 Templates
Overview of Jinja Templates
Control Structure - using loops, variables
Lab - for, loop.index variable, if else in Jinja2 Templates
Guided Exercise
Configuring Parallelism
About Parallelism in Ansible
Managing rolling updates - serial keyword
Guided Exercise - Forks Parameter
Guided Exercise - Serial Keyword
Including & Importing Files
Overview of Importing & Including files
Import_playbook & import_tasks
define variables using import_tasks
Include_tasks and its comparison with import_tasks
Guided Exercise
Simplifying Playbooks with Roles
Ansible Roles
Create Ansible Roles
Lab: Simplifying Playbooks with Roles
Troubleshooting Ansible
Log Files for Ansible
The Debug Module
Managing Errors : --syntax-check, --step, --list-tasks, --start-at-tasks
Debugging
Using check mode as a Testing Tool
check_mode
Guided Exercise
Last Lecture
Bonus
Linux EX294 with Ansible Sample Practice Exams - OS Version 8