Ansible Hour 5: Automation Operations — CI/CD and Platformization
- Be able to automation maturity model assess the team's current state and design an Ansible repository with Git as the single source of truth, and the dev → staging → prod environment promotion process.
- Build, in GitHub Actions, CI: yamllint, ansible-lint (production profile),
--syntax-check, Molecule matrix tests (multiple distributions × multiple ansible-core versions), and pin third-party Actions to full commit SHAs. - Use OIDC federated identity (Azure federated credentials / AWS IAM OIDC provider) so the CD pipeline runs without long-lived cloud keys playbooks; configure environment approvals,
--check --diffdry runs, andconcurrencyconcurrency control; master both SSH key and SSM connection methods. - Understand the AWX / AAP automation controller object model (organizations, projects, inventories, credentials, job templates, workflows, surveys); be able to deploy AWX in kind with AWX Operator for experiments, and know AWX's current “releases paused, being re-architected” status and the installation changes in AAP 2.6 / 2.7.
- Write Event-Driven Ansible rulebooks: event sources (webhooks, Alertmanager, Kafka), filters (including AAP 2.6's
event_splitter), conditions, and actions, and connect alerts to job templates to implement automated remediation. - Design credentials, RBAC, and audit schemes (external secret management, least privilege, job auditing), plus scheduling, notifications, and a self-service catalog, to turn Ansible from “scripts” into a “platform”.
1-Hour Time Allocation
| # | Time | Module | Core Content | Animation / Interactive | Lab |
|---|---|---|---|---|---|
| 0 | Pre-class | Prep: GitHub Repository and Platform Environment | Organize ansible-lab Repository layout, install ansible-dev-tools, confirm the Azure VM / EC2 targets from Hours 3/4 | Environment Self-Check List | Run lint + syntax-check locally |
| 1 | 00–06 | Automation Maturity and GitOps Workflow | Five maturity levels, Git as single source of truth, branch and PR flow, environment promotion, pull vs push | Environment Promotion Pipeline Simulator | Set up inventories/dev|staging|prod and branch protection |
| 2 | 06–15 | CI: Lint, Tests, and Pipeline | yamllint, ansible-lint profiles, Molecule scenarios, GitHub Actions matrix, SHA-pinned Actions, caching | Step-by-step CI pipeline execution (fault injection) | Write ci.yml and get a PR passing |
| 3 | 15–23 | CD: Running Playbooks with GitHub Actions + OIDC | OIDC token exchange, Azure federated credentials / AWS role trust policy, SSH keys and SSM, environment approvals, check dry runs, concurrency | OIDC token exchange sequence animation | cd.yml: staging automatic, prod approval |
| 4 | 23–33 | AWX / AAP Automation Controller | Object model, job execution path (receptor + EE containers), workflows, surveys, AWX Operator on kind, AAP 2.6 components and 2.7 installation changes | Job template launch → EE container execution path | Deploy AWX on kind and run the deploy-myapp template |
| 5 | 33–41 | Event-Driven Ansible | ansible-rulebook, event sources / filters / rules / actions, Alertmanager, Kafka, EDA controller, event_splitter, external secrets | Core animation: the full event-driven auto-remediation chain | webhook rulebook + simulated alert self-healing |
| 6 | 41–48 | Credentials, RBAC, and Auditing | Credential types and custom credentials, external secret lookups, organizations/teams/roles, activity stream and job auditing | RBAC Permission Evaluator | Custom credential type + team permissions |
| 7 | 48–54 | Scheduling, Notifications, and Self-Service | Scheduling (RRULE), notification templates (Slack/Teams/webhook/email), survey-based self-service, API triggers | RRULE Schedule Previewer | Nightly compliance check + Slack notification |
| 8 | 54–60 | Recap, Self-Check, and Cleanup for Hours 1–5 | Five-lesson knowledge map, self-test, cost and resource cleanup, CI/AWX/EDA troubleshooting trees | Knowledge map + interactive troubleshooting tree | Clean up kind / cloud resources |
| — | Post-class | Cheat Sheet · Capstone Lab | Git push triggers CI → after merge, CD deploys myapp → simulated alert triggers EDA auto-remediation | Final Quiz (12 questions) | Capstone Lab |
Knowledge Coverage Matrix
| Target Skill | M1 | M2 | M3 | M4 | M5 | M6 | M7 | M8 | Key Commands / Objects | Lab |
|---|---|---|---|---|---|---|---|---|---|---|
| Design Git-driven environment promotion | ✓ | · | ✓ | · | · | · | · | ✓ | branch protection,inventories/<env> | M1 Lab |
| Static checks and automated tests | · | ✓ | · | · | · | · | · | ✓ | ansible-lint,yamllint,molecule test | ci.yml |
| pipeline supply chain security | · | ✓ | ✓ | · | · | ✓ | · | · | pin Actions by SHA,permissions: | ci.yml / cd.yml |
| keyless cloud deployment (OIDC) | · | · | ✓ | · | · | ✓ | · | · | azure/login,configure-aws-credentials | cd.yml |
| controlled releases (approvals, dry runs, concurrency) | ✓ | · | ✓ | ✓ | · | · | ✓ | · | environment,--check --diff,concurrency | prod approval |
| automation controller object modeling | · | · | · | ✓ | · | ✓ | ✓ | · | awx CLI,ansible.controller collections | AWX on kind |
| event-driven auto-remediation | · | · | · | ✓ | ✓ | · | ✓ | ✓ | ansible-rulebook,run_job_template | M5 Lab |
| credential and permission governance, auditing | · | · | ✓ | ✓ | ✓ | ✓ | · | · | credential types, roles, activity stream | M6 Lab |
| scheduling, notifications, self-service | · | · | · | ✓ | · | · | ✓ | · | Schedule, Notification, Survey | M7 Lab |
| Platform troubleshooting and cleanup | · | ✓ | ✓ | ✓ | ✓ | · | · | ✓ | kubectl logs,gh run view | troubleshooting tree |
Out of scope for this lesson (and where to learn it)
| Topic | Why it is not in this lesson | Where to learn |
|---|---|---|
| Full orchestration of a multi-tier architecture (nginx load balancer + 2 app nodes + PostgreSQL) | This lesson focuses on “how to deliver and operate automation”; application architecture is left to the hands-on course | Hour 6: Architecture in Practice |
| Playbook performance tuning (forks, pipelining, mitogen alternatives), callback plugins, and deep debugging | Belongs to the troubleshooting and optimization topics | Hour 7 |
| Production-grade AAP high-availability topologies (multi-node gateways, cross-datacenter execution mesh, disaster recovery) | Requires a subscription and multiple RHEL hosts; exceeds 1 hour | AAP 2.6 official documentation(Tested deployment models) |
| Ansible Lightspeed / generative AI-assisted authoring | Only loosely related to CI/CD platformization, and requires a subscription | Red Hat official documentation |
| Kubernetes-native GitOps such as Argo CD / Flux | Targets K8s manifests; this lesson covers the GitOps approach for Ansible | Kubernetes courseHour 6 |
How to Use These Materials
Theory · diagrams · animations · commands · labs · production cases · troubleshooting · quizzes · audio · video. Read “Theory” and “Animation” first, then do the “Lab”. The Module 5 animation is the core of this lesson.
Progress counts once the quiz score is ≥ 70% or you click “Mark module complete”. It is saved in this browser (if local storage is blocked, it is cleared on refresh).
The “Audio” page reads the script aloud using the browser's built-in Web Speech API (en-US); without a Chinese voice pack, the script can still be read or passed to a TTS tool.
event_splitter filters; 2.6 is the last version supporting RPM installation (RHEL 9 only),from 2.7 on only containerized installation is supported (Operator installation on OpenShift is unaffected; refer to official docs).Module 0 · Prep: GitHub Repository and Platform Environment (complete before class)
- CompletedHour 1(inventory, modules, playbooks),Hour 2(roles, Vault, idempotency, myapp role),Hour 3(Azure VM, resource group
rg-ansible-lab, regioncanadacentral),Hour 4(AWS EC2,ca-central-1, SSM connection plugin). - Control node: Ubuntu 24.04 LTS (Azure VM or local machine), Python 3.12 (the 2.21 control node requires 3.12–3.14), Docker Engine 29 (from the Docker course), 4 vCPU / 16 GiB or more (running AWX in kind needs about 6–8 GiB of memory).
- GitHub account, with
ghCLI installed andgh auth login; Owner or User Access Administrator rights on the Azure subscription (to create federated credentials and role assignments), or permission in the AWS account to create an IAM OIDC provider / role.
Step 1: Install the Toolchain
ansible-dev-tools is the official “developer tools meta-package”; it installs ansible-core, ansible-lint, Molecule, ansible-navigator, ansible-builder, ansible-creator, and more in one go. You can also install them separately.
sudo apt-get update && sudo apt-get install -y pipx python3-venv git jq pipx ensurepath && exec $SHELL -l # Option A: install the official dev tools bundle in one step pipx install ansible-dev-tools # Option B: install on demand (the minimal set used in this lesson's modules) pipx install --include-deps ansible # community package 14.x (includes ansible-core 2.21) pipx install ansible-lint # brings its own ansible-core dependency pipx install molecule && pipx inject molecule ansible-core pipx install yamllint pipx install ansible-rulebook && pipx inject ansible-rulebook ansible ansible-runner sudo apt-get install -y openjdk-17-jre-headless # ansible-rulebook requires JDK ≥ 17 ansible --version | head -1; ansible-lint --version; molecule --version; ansible-rulebook --version
ansible [core 2.21.5]
ansible-lint 26.11.0 using ansible-core:2.21.5 ansible-compat:… ruamel-yaml:…
molecule 26.11.0 using python 3.12
ansible:2.21.5
__version__ = '1.3.2'
Executable location = /home/azureuser/.local/bin/ansible-rulebook
Drools_jpy version = …
Java home = /usr/lib/jvm/java-17-openjdk-amd64
…
requirements-dev.txt to pin the version (see Module 2), so local and pipeline results match. ansible-lint --version It will tell you if a new version is available, which serves as a reminder for periodic upgrades.Step 2: Organize the ansible-lab Repository Structure
Gather the inventory, roles, and playbooks from earlier lessons into one repository. All CI/CD, AWX projects, and EDA rulebooks in this lesson are built on this structure:
ansible-lab/
├── ansible.cfg
├── requirements.yml # collection dependencies (pinned versions)
├── requirements-dev.txt # CI tool versions (ansible-lint, molecule…)
├── .ansible-lint # profile: production
├── .yamllint
├── inventories/
│ ├── dev/hosts.yml + group_vars/all.yml
│ ├── staging/hosts.yml + group_vars/all.yml
│ └── prod/hosts.yml + group_vars/all.yml
├── playbooks/
│ ├── site.yml
│ ├── deploy-myapp.yml # deploy myapp (Flask + gunicorn + Redis)
│ └── remediate-myapp.yml # auto-remediation: restart service + health check
├── roles/myapp/
│ ├── tasks/main.yml handlers/main.yml templates/ defaults/main.yml
│ └── molecule/default/{molecule.yml,create.yml,destroy.yml,converge.yml,verify.yml}
├── rulebooks/myapp-remediate.yml # EDA rulebook
└── .github/workflows/{ci.yml,cd.yml}
[defaults] inventory = inventories/dev/hosts.yml roles_path = roles collections_path = ./collections host_key_checking = True stdout_callback = ansible.builtin.default callback_result_format = yaml retry_files_enabled = False interpreter_python = auto_silent [ssh_connection] pipelining = True
---
collections:
- name: ansible.posix
version: ">=2.0.0,<3.0.0"
- name: community.general
version: ">=11.0.0,<13.0.0"
- name: community.docker
version: ">=4.0.0,<6.0.0"
- name: amazon.aws
version: ">=10.0.0,<12.0.0"
- name: azure.azcollection
version: ">=3.0.0,<5.0.0"
- name: ansible.eda
version: ">=2.10.0,<3.0.0"
The version ranges are example syntax only: use ansible-galaxy collection list to check your actual local versions, then confirm the latest versions on Galaxy before tightening the ranges. Production repositories should pin exact versions and use Dependabot / Renovate to open upgrade PRs regularly.
---
all:
children:
web:
hosts:
vm-ansible-01:
ansible_host: 20.151.0.10 # public IP of the Hour 3 Azure VM (example value)
ansible_user: azureuser
vars:
app_env: staging
myapp_port: 8000
Step 3: Push to GitHub and Enable Branch Protection
cd ~/ansible-lab
git init -b main && git add . && git commit -m "chore: import ansible-lab from lessons 1-4"
gh repo create ansible-lab --private --source=. --push
# Branch protection (ruleset): main requires a PR + CI to merge
gh api -X POST repos/{owner}/ansible-lab/rulesets --input - <<'EOF'
{"name":"protect-main","target":"branch","enforcement":"active",
"conditions":{"ref_name":{"include":["~DEFAULT_BRANCH"],"exclude":[]}},
"rules":[{"type":"pull_request","parameters":{"required_approving_review_count":1,
"dismiss_stale_reviews_on_push":true,"require_code_owner_review":false,
"require_last_push_approval":false,"required_review_thread_resolution":true}},
{"type":"non_fast_forward"},{"type":"deletion"}]}
EOF
{owner} gh automatically replaces this with the current repository owner. Required status checks can only be added to the ruleset after CI has run at least once and the check names appear (last step of the Module 2 lab). Ruleset availability for private repositories depends on your GitHub plan; refer to GitHub docs.
Step 4: Confirm Target Hosts Are Reachable
ansible -i inventories/staging/hosts.yml web -m ansible.builtin.ping ansible-playbook -i inventories/staging/hosts.yml playbooks/deploy-myapp.yml --check --diff
vm-ansible-01 | SUCCESS => {
"changed": false,
"ping": "pong"
}
…
PLAY RECAP *********************************************************************
vm-ansible-01 : ok=9 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
Warm-up: answer from memory (30 seconds)
What do the --check and --diff of ansible-playbook each do? Which modules do not support check mode?
--check Makes modules that support check_mode only report whether they would change, without actually modifying anything; --diff shows the content of file/template changes. command/shell Skipped by default in check mode (unless set check_mode: false or using creates/removes). This is the basis for the Module 3 “dry run”.
How are Ansible Vault–encrypted variables decrypted in CI?
Via --vault-password-file or --vault-id pointing to a script/file, with the password injected in CI from platform secrets (GitHub Secret, Key Vault). Modules 3 and 6 cover better approaches: external secret management + OIDC.
Module 1 · Automation Maturity and GitOps Workflow
- Use the five-level maturity model to locate the team's current state, and name the capabilities needed for each step up (version control, testing, pipelines, platform, event-driven).
- Explain what “Git as the single source of truth” concretely means for Ansible: the inventory, variables, role versions, collection versions, and execution environment images must all come from a specific commit.
- Compare the “directory-per-environment” and “branch-per-environment” promotion models, and design dev → staging → prod promotion rules (the same commit SHA is promoted; configuration differences live only in the inventory).
What: the five levels of automation maturity
| Level | Characteristics | Typical Pain Points | Needed to Advance |
|---|---|---|---|
| L0 Manual | SSH into each server to operate; steps recorded in a wiki | Not repeatable, config drift, hard to hand over | Write as a playbook |
| L1 Scripted | Playbooks live on personal computers or shared drives, run by individuals | “Only one person can run it”; unknown versions; passwords scattered | Put into Git, manage secrets with Vault |
| L2 Versioned | Git repository + PR review, but still run from laptops | Inconsistent execution environments (ansible-core, collections, Python versions differ); no audit | CI tests + pinned dependencies |
| L3 Pipelined | CI runs lint/tests, CD runs from a runner, approvals and logs live on the platform | Non-developers can't self-serve; scheduling, credentials, and permissions are scattered across pipelines | Automation controller (AWX/AAP) |
| L4 Platformized | Controller unifies credentials, RBAC, scheduling, notifications, and auditing; self-service catalog | Still needs a person to notice the problem and click the button | Event-driven (EDA) |
| L5 Event-driven / self-healing | Monitoring alerts, tickets, and Git events automatically trigger rulebooks and jobs | Requires strict guardrails (rate limiting, approvals, rollback) | Continuous improvement, measure MTTR |
Why: why “Git as the single source of truth”
Ansible is a push-based tool: who runs it, on which machine, and with which version can change the result. The same playbook may behave differently on ansible-core 2.18 and 2.21 (2.19 introduced data tagging and stricter conditional evaluation), and collection upgrades may change module parameters. Put the following all inputs into Git (or reference them precisely via files in Git), so any run can be reproduced in full from a “commit SHA”:
- playbooks, roles, rulebooks, templates;
- the inventory and group_vars/host_vars (for dynamic inventories, the plugin configuration file);
requirements.ymlpinned collection/role versions inrequirements-dev.txtpinned ansible-core / ansible-lint in- the definition of the Execution Environment (EE) image
execution-environment.ymland the image digest; - Secrets are referenced (a Vault file or an external secret path), not as plaintext secrets.
How: the Ansible GitOps workflow
- Feature branch → PR: developers modify a role and push a branch; CI automatically runs lint, syntax-check, and Molecule.
- Review and merge: at least one reviewer + passing CI are required to merge into main (branch protection ruleset).
- Auto-deploy dev/staging: the merge triggers CD, which obtains cloud credentials via OIDC and runs against the staging inventory, first
--check --diffbefore the real run. - Promote to prod: the same commit SHA in a GitHub environment
prodwaits for approval, then runs against the prod inventory; or push a tagv1.4.0to trigger it. - Continuous reconciliation (optional): run on a schedule in check mode; if drift is detected, alert or auto-remediate. This borrows the “declarative reconciliation” idea for a push-based tool.
Push vs pull
| Push (CI runner / AWX execution) | Pull (ansible-pull / nodes pull on their own) | |
|---|---|---|
| Trigger | pipelines, controller, events | cron/systemd timer on the node runs periodically git pull and runs against localhost |
| Credentials | the control side holds SSH/SSM/cloud credentials | each node needs credentials to read from Git; no inbound SSH needed |
| Visibility | centralized logs, approvals, auditing | spread across nodes; you must aggregate them yourself |
| Best for | most server orchestration and ordered cross-host operations | large scale, network-isolated, bootstrapping (self-configuration after cloud-init) |
When: choosing a promotion model
| Model | Approach | Pros | Cons | Recommendation |
|---|---|---|---|---|
| Directory per environment (recommended) | a single main branch,inventories/dev|staging|prod, the same commit deployed to each environment in turn | environment differences are obvious; no cross-branch drift; promotion = the same SHA | requires the pipeline to control “when to deploy prod” | Default choice |
| Branch per environment | dev/staging/prod branches; merging promotes | intuitive; permissions can be controlled per branch | frequent drift between branches, cherry-pick hell; the same role has different contents on different branches | Only when the organization requires it |
| Artifact promotion | Package roles/collections as versioned artifacts (Galaxy / private Automation Hub); environments reference different versions | Suits roles shared across multiple teams | heavier release process | shared collections maintained by a platform team |
ansible-playbook, Git is not the single source of truth; enforce it via permissions (only the pipeline/controller holds prod credentials) to rule out bypasses. ② “Branch isolation makes environments safer” — the biggest risk of the branch model is exactly code drift between environments; safety should come from environment approvals and credential isolation. ③ “Ansible is push-based, so it can't reconcile” — scheduled check mode + drift alerts are reconciliation, and Module 7's scheduling will implement it.Architecture diagram: the Git-centered Ansible delivery chain
Flowchart: environment promotion of the same commit
Interactive simulator: environment promotion of a single change
Click “Play” to watch a commit travel from PR to prod; tick “Inject fault” to make a stage fail and see how promotion gets blocked. The terminal below shows the real command or GitHub event for each step.
Core Commands and Parameters
| Command | Purpose | Key Parameters / Notes |
|---|---|---|
git switch -c feat/x → gh pr create | Feature branches and PRs | --fill use commit messages; --reviewer |
ansible-inventory -i inventories/prod --graph | Confirm the inventory structure is consistent across environments | --list --yaml View the merged variables |
ansible-playbook … --check --diff | Dry run / drift detection | --limit,--tags; in check mode changed means drift |
ansible-galaxy collection install -r requirements.yml -p ./collections | Install collections at pinned versions | --force overwrite; add caching in CI |
ansible-pull -U <repo> -i localhost, playbooks/site.yml | Pull-based execution | -C main branch; --only-if-changed |
gh api repos/{owner}/{repo}/rulesets | Manage branch protection rulesets | pull_request, required_status_checks rules |
Compare effective variables across environments (to prevent “environment differences hiding elsewhere”)
for e in dev staging prod; do
echo "== $e"; ansible-inventory -i inventories/$e/hosts.yml --host vm-ansible-01 2>/dev/null \
| jq -S '{app_env, myapp_port, myapp_workers}' || ansible-inventory -i inventories/$e/hosts.yml --graph
done
== dev
@all:
|--@ungrouped:
|--@web:
| |--node1
== staging
{
"app_env": "staging",
"myapp_port": 8000,
"myapp_workers": 2
}
== prod
@all:
|--@ungrouped:
|--@web:
| |--vm-ansible-prod-01
| |--vm-ansible-prod-02
How to verify: The group structure (web, db…) should be identical across the three environments; only hosts and variable values differ. Common mistake: prod has a group that dev doesn't, so some tasks run only in prod — the first error happens in production. Production use: Put this script in CI so the PR fails when the group structure is inconsistent.
Drift detection (check mode + exit code)
ansible-playbook -i inventories/staging/hosts.yml playbooks/site.yml --check --diff | tee drift.log grep -E "changed=[1-9]" drift.log && echo "DRIFT DETECTED" || echo "no drift"
--- before: /etc/myapp/myapp.env +++ after: /home/runner/.ansible/tmp/…/myapp.env.j2 @@ -1,3 +1,3 @@ -MYAPP_WORKERS=4 +MYAPP_WORKERS=2 … vm-ansible-01 : ok=9 changed=1 unreachable=0 failed=0 skipped=1 DRIFT DETECTED
Someone manually changed /etc/myapp/myapp.env, and check mode will show the difference. Note that check mode results are only reliable if the role correctly supports check_mode (Module 2's ansible-lint helps you catch command missing changed_when issues, etc.).
Lab 1: Set up three-environment inventories and promotion rules (about 5 minutes)
cd ~/ansible-lab
for e in dev staging prod; do mkdir -p inventories/$e/group_vars; done
cat > inventories/dev/hosts.yml <<'EOF'
---
all:
children:
web:
hosts:
node1: { ansible_host: 172.30.0.11, ansible_user: ansible }
EOF
cat > inventories/dev/group_vars/all.yml <<'EOF'
---
app_env: dev
myapp_port: 8000
myapp_workers: 1
EOF
sed 's/dev/staging/; s/workers: 1/workers: 2/' inventories/dev/group_vars/all.yml > inventories/staging/group_vars/all.yml
sed 's/dev/prod/; s/workers: 1/workers: 4/' inventories/dev/group_vars/all.yml > inventories/prod/group_vars/all.yml
cat inventories/*/group_vars/all.yml#!/usr/bin/env bash
set -euo pipefail
shape() { ansible-inventory -i "inventories/$1/hosts.yml" --list \
| jq -r 'del(._meta) | keys[]' | sort | tr '\n' ' '; }
ref=$(shape dev)
for e in staging prod; do
s=$(shape "$e")
if [ "$s" != "$ref" ]; then echo "::error::inventory groups differ: dev=[$ref] $e=[$s]"; exit 1; fi
done
echo "inventory shape OK: [$ref]"
chmod +x scripts/check-inventory-shape.sh && ./scripts/check-inventory-shape.sh
inventory shape OK: [all ungrouped web ]
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
ME=$(gh api user -q .id)
gh api -X PUT repos/$REPO/environments/dev
gh api -X PUT repos/$REPO/environments/staging
gh api -X PUT repos/$REPO/environments/prod --input - <<EOF
{"wait_timer":0,"prevent_self_review":false,
"reviewers":[{"type":"User","id":$ME}],
"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}
EOF
gh api repos/$REPO/environments -q '.environments[].name'
dev prod staging
In production, you should set prevent_self_review: true (the pusher cannot approve their own deployment) and use a team as approvers; here you are the only person, so it is turned off. Availability of environment protection rules for private repositories depends on your GitHub plan; refer to GitHub docs.
git switch -c feat/three-envs git add inventories scripts && git commit -m "feat: dev/staging/prod inventories with shape check" git push -u origin feat/three-envs && gh pr create --fill
The PR has no checks for now — the CI in the next module will add them. Cleanup: No cleanup needed; the three-environment structure is used in later modules.
Case 1: branch-per-environment left prod missing a security patch
Problem: A team used three long-lived branches dev/staging/prod. After a fix to the SSH hardening role was merged into dev, it was cherry-picked to prod but one handler was missed, so prod's sshd configuration did not take effect for six months. Approach: Migrated to a single main + directory-per-environment; prod deployments may only reference SHAs already successfully deployed to staging (CD checks the staging deployment record). Configuration: GitHub environment prod 's deployment branch policy allows only main; in CD, use gh api repos/…/deployments?environment=staging&sha=$SHA to validate. Limitation: Requires the inventory structure to stay consistent across all environments; the initial cleanup effort is high.
Case 2: laptop bypass created an audit gap
Problem: During a nighttime outage, the on-call engineer ran a playbook directly against prod from a laptop, using an old local copy of the role, which overwrote the configuration merged during the day. Afterwards it was impossible to trace who made the change. Approach: prod's SSH private keys and cloud credentials are stored only in the CI environment and AWX credentials; personal accounts have read-only access; emergency changes go through the AWX “emergency fix” job template (a workflow node requiring two-person approval). Limitation: A fast enough emergency path must be provided, otherwise people will find ways around it.
Case 3: using scheduled check runs to report configuration drift
Problem: The compliance team requires weekly proof that all Linux hosts conform to the CIS baseline. Approach: Every night, in --check run the hardening playbook, then summarize changed the task counts into a report; if drift is found, notify the Teams channel (Module 7). Limitation: check mode is only accurate for modules that support check_mode,shell and such tasks need separate verification tasks.
Common Errors and Fixes
staging deploys succeed, prod fails: 'myapp_workers' is undefined
Cause: The variable is defined only in inventories/staging/group_vars ; prod is missing it. The environment difference was put into the inventory, but the role's defaults have no default value.
grep -rn myapp_workers inventories/ roles/myapp/defaults/ ansible-inventory -i inventories/prod/hosts.yml --host vm-ansible-prod-01 | jq .myapp_workers
Fix: Define all variables in the role's defaults/main.yml with safe default values, and let the inventory override only the differences; use ansible.builtin.assert to validate required variables at the start of the play.
remote: error: GH013: Repository rule violations found for refs/heads/main
Cause: main is protected by a ruleset, so directly git push origin main is rejected.
gh api repos/{owner}/{repo}/rules/branches/main -q '.[].type'
Fix: This is expected behavior: push to a feature branch and open a PR. If an emergency bypass is truly needed, an administrator configures a bypass list in the ruleset and records the reason.
ansible-pull: ERROR! Unable to find a playbook / "Repository has not changed, quitting."
Cause: In pull-based execution, the playbook path is relative to the repository root; using --only-if-changed does nothing when there is no new commit.
ansible-pull -U https://github.com/ORG/ansible-lab.git -C main -d /var/lib/ansible-pull -i localhost, playbooks/site.yml -vv
Fix: Confirm the path; when reconciliation is needed on every run, do not add --only-if-changed.
check mode reports changed, but the real run also reports changed (never converges)
Cause: The task is not idempotent, for example shell: echo ... >> file, a template embedding a timestamp,get_url downloading on every run.
Fix: Use declarative modules (lineinfile,template); command Add creates or changed_when; Molecule's idempotence stage catches this automatically (Module 2).
1. Using one command, run site.yml against staging in check mode, look only at the myapp role's tasks, and show file diffs.
ansible-playbook -i inventories/staging/hosts.yml playbooks/site.yml --check --diff --tags myapp
2. List all group names in the prod inventory (excluding _meta).
ansible-inventory -i inventories/prod/hosts.yml --list | jq -r 'del(._meta) | keys[]'
The team currently manages environments with three long-lived branches, and the manager wants “only the release manager can merge to the prod branch”. After switching to directory-per-environment, how do you still meet this control requirement?
The control point shifts from “who can merge branches” to “who can approve prod deployments”: GitHub environment prod with required reviewers set to the release manager team,prevent_self_review, deployment branch policy allows only main; prod credentials exist only in that environment (the OIDC federated credential's subject is bound environment:prod, Module 3), so even if someone modifies the workflow they cannot obtain prod credentials. CODEOWNERS can require inventories/prod/ changes to those files to be reviewed by the release manager.
Verified instructional videos
No verified video specifically covering “Ansible automation maturity and environment promotion” was found. Official documentation and a storyboard script are provided below. (For general GitOps concepts, see the CI/CD video on the Module 2 video page.)
Official documentation
- Ansible: Sample Ansible setup (directory layout, multi-environment inventory)
- ansible-pull
- GitHub: Managing environments for deployment
- GitHub: About rulesets
Video storyboard script (about 80 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: five steps, from “manual SSH” to “event-driven self-healing”, with a little figure climbing step by step.
Narration: Automation maturity has five levels. Most teams get stuck at level two: the code is in Git, but it still runs from laptops.
Visual: Git repository icon centered, with arrows pointing to CI, CD, AWX, and EDA, labeled “runs only what is in Git”.
Narration: Git is the single source of truth. Every execution entry point runs only content from a given commit; versions, inventories, and collections are all traceable.
Visual: the same commit-hash card slides in turn past dev, staging, the approval gate, and prod.
Narration: what gets promoted is the same already-verified commit; the only differences between environments are in inventory variables and credentials.
Visual: a laptop icon tries to connect to prod and is blocked by a lock icon.
Narration: For Git to truly be the single source of truth, close the bypass through permissions: production credentials go only to the pipeline and controller.
Module 2 · CI: Lint, Tests, and Pipeline
- Configure yamllint and ansible-lint (
profile: production), and read rule IDs (name[missing],no-changed-when,fqcn[action-core],risky-file-permissionsetc.) and use them appropriatelyskip_list/noqa. - Use Molecule's create → converge → idempotence → verify → destroy sequence to test the myapp role in a container.
- Write GitHub Actions CI: least
permissions, dependency caching, a distribution × ansible-core version matrix,pin third-party Actions to 40-character commit SHAs, and make the checks required for merging.
What: the four layers of checks in Ansible CI
| Layer | Tool | What it checks | Time |
|---|---|---|---|
| 1. YAML syntax and style | yamllint | indentation, duplicate keys, line length, truthy values (yes/on), document start --- | Seconds |
| 2. Ansible best practices | ansible-lint | FQCNs, task naming,changed_when, file permissions, deprecated modules, Jinja spacing, variable naming, meta information; also runs syntax-check internally | Seconds to minutes |
| 3. Syntax and references | ansible-playbook --syntax-check | Whether playbooks parse and roles/files can be found | Seconds |
| 4. Behavior tests | molecule test | Real execution in a temporary container/VM: convergence succeeds,idempotence (second run 0 changed), verify results (ports, services, HTTP /healthz) | Minutes |
Why: why Ansible in particular needs CI
Most Ansible errors only surface at runtime— misspelled variables, package names that do not exist on some distributions, and register references that only fail in check mode. From ansible-core 2.19 onward the templating engine is stricter (for example, conditionals must be real booleans; non-empty strings are no longer implicitly treated as true), so many old playbooks break on upgrade — matrix testing finds this before the upgrade.
How: ansible-lint profiles
ansible-lint rules stack up profile by profile: min → basic → moderate → safety → shared → production. production includes all the preceding rules and suits content that will be deployed to production or published to Automation Hub. For new projects, use production directly; for older projects, start from basic and tighten gradually.
Molecule's test sequence
molecule test By default runs in order: dependency → cleanup → destroy → syntax → create → prepare → converge → idempotence → side_effect → verify → cleanup → destroy. Among these, idempotence runs converge a second time, and fails if any task reports changed — this is the most reliable way to catch non-idempotent tasks. During development, you often use molecule converge / molecule verify / molecule login to iterate, and finally molecule destroy.
Current Molecule recommends the “ansible-native” style: creating and destroying instances is handled by create.yml / destroy.yml these two ordinary playbooks in the scenario directory (for example, using community.docker.docker_container to start containers and write out a temporary inventory), rather than relying on dedicated driver plugins. The official docs provide example playbooks for Docker and Podman.
Key GitHub Actions concepts
- Triggers:
pull_request(the PR's merge-preview commit) andpushto main. - Matrix:
strategy.matrixgenerate multiple parallel jobs;fail-fast: falsewhen one combination fails, the others keep running to completion, giving the full picture. - Least privilege: set permissions at the workflow top level
permissions: contents: read, so GITHUB_TOKEN is read-only by default. - Pin by SHA:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1. Tags can be moved (supply-chain attacks have repointed popular Action tags to malicious commits), whereas a 40-character commit SHA is immutable. Add the version number in a comment; Dependabot can still update the SHA by version.
When: where each check belongs
| Stage | Checks | Reason |
|---|---|---|
| Local pre-commit | yamllint, ansible-lint (can add --fix) | Second-level feedback; fewer CI round-trips |
| Every PR | lint + syntax-check + inventory structure check + Molecule (roles touched by the change) | Gate before merge |
| Nightly / dependency-upgrade PRs | Full Molecule matrix (all roles × all distributions × 2 ansible-core versions) | Long-running; catches upstream changes early |
Comparison with similar technologies
| Ansible (this lesson) | Terraform | Application code | |
|---|---|---|---|
| Static checks | ansible-lint, yamllint | terraform fmt/validate, tflint | eslint, ruff |
| Behavior tests | Molecule (real execution in containers/VMs) | terraform test (can mock the provider) | Unit/integration tests |
| “Idempotence” verification | idempotence stage | after apply, a re-plan should show no changes | — |
@v7 is secure enough” — major version tags are movable; GitHub's official security guide recommends pinning third-party Actions to a full commit SHA. ③ “Running the latest tools in CI pip install ansible is fine” — unpinned versions mean the same commit is green today and red tomorrow; pin the ansible-core/ansible-lint/molecule versions in requirements-dev.txt.Architecture diagram: the CI workflow triggered by a PR
Flowchart: what happens inside one Molecule scenario
Step-by-step CI pipeline execution (failures can be injected)
Pick a “bad commit”, then play. Watch which check layer stops it, and the real output you would see on GitHub.
Core Commands and Parameters
| Command | Purpose | Key Parameters / Notes |
|---|---|---|
yamllint -s . | YAML check | -s treat warnings as failures; -f github output in GitHub annotation format |
ansible-lint | Best practices check | --profile production,--fix (auto-fixes some rules),-f sarif,--offline |
ansible-playbook --syntax-check | Syntax check | requires roles and collections to be findable |
molecule test | Full test sequence | -s scenario name,--destroy=never,--all |
molecule converge / idempotence / verify / login / destroy | Development iteration | login -h instance name |
gh run list / view / watch | View CI runs | gh run view --log-failed View only failed-step logs |
gh api repos/OWNER/REPO/commits/TAG -q .sha | Look up the commit SHA for an Action tag | or git ls-remote --tags |
config file
---
profile: production
exclude_paths:
- .github/
- collections/
- roles/*/molecule/*/create.yml # test scaffolding is not checked to production standards
- roles/*/molecule/*/destroy.yml
warn_list:
- experimental
skip_list: [] # prefer noqa on specific tasks with a stated reason
offline: false
# let lint parse the rulebooks/ directory (ansible-lint supports rulebook schema validation)
kinds:
- rulebook: "rulebooks/*.{yml,yaml}"
---
extends: default
rules:
line-length: { max: 160, level: warning }
truthy: { allowed-values: ["true", "false"], check-keys: false }
comments: { min-spaces-from-content: 1 }
comments-indentation: false
braces: { max-spaces-inside: 1 }
octal-values: { forbid-implicit-octal: true, forbid-explicit-octal: true }
ignore: |
collections/
.venv/
# shared by CI and local; change here when upgrading and go through a PR ansible-core==2.21.5 ansible-lint==26.11.0 molecule==26.11.0 yamllint docker # community.docker in Molecule create.yml needs the Python docker SDK
ansible-core==2.21.5 is an example filled in per the spec's “latest patch, about 2.21.5”; use pip index versions ansible-core to confirm before pinning. yamllint and docker are left unpinned to avoid writing uncertain version numbers — production repositories should pin everything.
Run lint locally and read the output
yamllint -s . && ansible-lint
fqcn[action-core]: Use FQCN for builtin module actions (shell).
roles/myapp/tasks/main.yml:31 Use `ansible.builtin.shell` or `ansible.legacy.shell` instead.
no-changed-when: Commands should not change things if nothing needs doing.
roles/myapp/tasks/main.yml:31 Task/Handler: Initialize database
risky-file-permissions: File permissions unset or incorrect.
roles/myapp/tasks/main.yml:12 Task/Handler: Render myapp.env
Read documentation for instructions on how to ignore specific rule violations.
Rule Violation Summary
count tag profile rule associated tags
1 risky-file-permissions safety unpredictability
1 no-changed-when shared command-shell, idempotency
1 fqcn[action-core] production formatting
Failed: 3 failure(s), 0 warning(s) on 24 files. Last profile that met the validation criteria was 'moderate'.
How to read it: The last line tells you which profile level the content currently satisfies. Fix example:ansible.builtin.shell; add changed_when: false or creates:; template add mode: "0640". When an exception is truly needed, write # noqa: no-changed-when reason. Rule names and output format depend on the ansible-lint version you installed.
Lab 2: add Molecule tests to the myapp role and write a CI workflow (about 10 minutes)
---
dependency:
name: galaxy
options:
requirements-file: ../../../requirements.yml # relative to the scenario directory; adjust to your layout
driver:
name: default
options:
managed: true
platforms:
- name: myapp-${MOLECULE_DISTRO:-ubuntu2404}
image: ${MOLECULE_IMAGE:-geerlingguy/docker-ubuntu2404-ansible:latest}
provisioner:
name: ansible
inventory:
group_vars:
all:
app_env: molecule
myapp_port: 8000
myapp_workers: 1
scenario:
test_sequence:
- dependency
- destroy
- syntax
- create
- converge
- idempotence
- verify
- destroy
---
- name: Create test instances
hosts: localhost
gather_facts: false
tasks:
- name: Start systemd-capable containers
community.docker.docker_container:
name: "{{ item.name }}"
image: "{{ item.image }}"
state: started
privileged: true # CI/local testing only; used to run systemd in the container
cgroupns_mode: host
volumes: ["/sys/fs/cgroup:/sys/fs/cgroup:rw"]
command: /usr/sbin/init
published_ports: []
loop: "{{ molecule_yml.platforms }}"
- name: Write ephemeral inventory
ansible.builtin.copy:
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
mode: "0600"
content: |
molecule:
hosts:
{% for p in molecule_yml.platforms %}
{{ p.name }}:
ansible_connection: community.docker.docker
{% endfor %}
- name: Refresh inventory
ansible.builtin.meta: refresh_inventory
---
- name: Destroy test instances
hosts: localhost
gather_facts: false
tasks:
- name: Remove containers
community.docker.docker_container:
name: "{{ item.name }}"
state: absent
force_kill: true
loop: "{{ molecule_yml.platforms }}"
---
- name: Converge
hosts: molecule
become: true
roles:
- role: myapp
---
- name: Verify myapp
hosts: molecule
gather_facts: false
tasks:
- name: Service is active
ansible.builtin.command: systemctl is-active myapp
register: svc
changed_when: false
failed_when: svc.stdout != "active"
- name: Health endpoint returns 200
ansible.builtin.uri:
url: "http://127.0.0.1:{{ myapp_port }}/healthz"
status_code: 200
register: hz
retries: 10
delay: 3
until: hz.status == 200
Image geerlingguy/docker-*-ansible is a widely used community “test image that can run systemd” (not official); you can also adapt the Hour 1 node image Dockerfile. Running systemd inside a container requires privileges and cgroup mounts,so use it only in test environments. molecule.yml in ${VAR:-default} Environment variable substitution is a Molecule feature; different Molecule versions may handle keys such as platforms/provisioner differently, so refer to the official Docker example.
cd roles/myapp && molecule test; cd -
INFO default ➜ create: Executing … INFO default ➜ converge: Executing PLAY RECAP ********************************************************************* myapp-ubuntu2404 : ok=14 changed=9 unreachable=0 failed=0 INFO default ➜ idempotence: Executing PLAY RECAP ********************************************************************* myapp-ubuntu2404 : ok=14 changed=0 unreachable=0 failed=0 INFO default ➜ idempotence: Idempotence completed successfully. INFO default ➜ verify: Executing … INFO default ➜ destroy: Executed: Successful
for a in "actions/checkout v7.0.1" "actions/setup-python v7.1.0" "actions/cache v6.1.0"; do
set -- $a; echo "$1@$(git ls-remote https://github.com/$1.git "refs/tags/$2^{}" "refs/tags/$2" | tail -1 | cut -f1) # $2"
done
actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
An annotated tag points to a tag object,^{} and only after dereferencing do you get the commit SHA, so the command queries both and takes the last line. actions/* is maintained by GitHub itself, and many organizations allow tag references for it; however, for third-party Actions (including those from cloud vendors), pinning by SHA is always recommended.
name: ci
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true # cancel the old run when a new push arrives for the same PR
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install tools
run: pip install -r requirements-dev.txt
- name: Cache collections
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: collections
key: collections-${{ hashFiles('requirements.yml') }}
- run: ansible-galaxy collection install -r requirements.yml -p ./collections
- run: yamllint -s -f github .
- run: ansible-lint
- run: ansible-playbook -i inventories/dev/hosts.yml playbooks/site.yml --syntax-check
- run: ./scripts/check-inventory-shape.sh
molecule:
needs: lint
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
distro: [ubuntu2404, debian12, rockylinux9]
core: ["2.20", "2.21"]
env:
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_IMAGE: geerlingguy/docker-${{ matrix.distro }}-ansible:latest
PY_COLORS: "1"
ANSIBLE_FORCE_COLOR: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
cache: pip
- name: Install tools for ansible-core ${{ matrix.core }}
run: |
pip install -r requirements-dev.txt
pip install "ansible-core~=${{ matrix.core }}.0"
- name: Molecule
working-directory: roles/myapp
run: molecule test
ansible-core~=2.20.0 means the latest patch of 2.20.x. Note that ansible-lint 26.x itself has a minimum ansible-core version requirement; if it conflicts with older versions in the matrix, pip reports a dependency conflict — in that case, split the lint and molecule dependency files. On rockylinux9, the myapp role needs to handle package name differences (the module animation demonstrates this failure).
git add . && git commit -m "ci: lint + molecule matrix" && git push
gh pr checks --watch
gh run view --log-failed # when something fails, look only at the failed steps
# after the check names appear, add them to the ruleset (check name format: job name; matrix jobs are named like "molecule (ubuntu2404, 2.21)", etc.)
gh api repos/{owner}/{repo}/rulesets -q '.[] | {id,name}'
lint pass 41s molecule (ubuntu2404, 2.20) pass 3m12s molecule (ubuntu2404, 2.21) pass 3m05s molecule (debian12, 2.20) pass 3m20s molecule (debian12, 2.21) pass 3m18s molecule (rockylinux9, 2.20) fail 2m41s molecule (rockylinux9, 2.21) fail 2m39s
There are many matrix check names; a common approach is to add a summary job (needs: [lint, molecule],if: always(), whose check needs.*.result) and make only this summary job a required check. Cleanup:molecule destroy; docker ps -a | grep myapp- confirm no containers are left behind.
Case 1: matrix testing as a safety net before an ansible-core upgrade
Problem: The platform team planned to upgrade the execution environment from core 2.18 to 2.21, worried that the 2.19 templating engine changes (data tagging, stricter conditionals) would affect 120 roles. Approach: Add a 2.21 column to the nightly matrix, warn only without blocking at first; fix per the porting guide when: some_string such issues as non-boolean conditionals and unsafe template usage; switch the default version once everything is green. Limitation: Molecule can only cover roles that have test scenarios; roles without tests need to be supplemented by a full check-mode run against staging.
Case 2: incident response to a supply-chain attack via a tampered Action tag
Problem: There have been industry incidents where a popular third-party Action's tag was repointed to a malicious commit that printed CI secrets to the logs. Approach: All third-party Actions switched to SHA pinning; an organization-level setting to “allow only specified Actions”; at the top level of the workflow permissions: contents: read; Dependabot's github-actions ecosystem automatically opens PRs to update SHAs and version comments. Configuration:.github/dependabot.yml in package-ecosystem: github-actions. Limitation: SHA pinning does not protect against a pinned version that itself has a vulnerability; update PRs still need review.
Case 3: Molecule runs too long and slows down PRs
Problem: 40 roles × 3 distributions; each PR takes 1 hour to run. Approach: Use dorny/paths-filter a change-detection action (SHA-pinned) like this to test only the changed roles; move the full matrix to nightly; pre-pull images and cache collections. Limitation: When the shared group_vars or common roles change, a full test run must be triggered.
Common Errors and Fixes
couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.
Cause: The collection is not installed to a path Ansible can find (collections_path), or the CI cache hit an old directory.
ansible-galaxy collection list | grep -E "community.docker|ansible.posix" ansible-config dump --only-changed | grep -i collections
Fix:ansible-galaxy collection install -r requirements.yml -p ./collections, and make sure ansible.cfg's collections_path points to the same directory; the cache key includes hashFiles('requirements.yml').
CRITICAL Idempotence test failed because of the following tasks: * [myapp-ubuntu2404] => myapp : Initialize database
Cause: The task still reports changed on the second run (typically because command/shell it has no creates or changed_when).
molecule converge && molecule idempotence molecule login -h myapp-ubuntu2404
Fix: Switch to declarative modules; or creates: /var/lib/myapp/.initialized; or decide based on the output changed_when: "'created' in result.stdout".
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Cause: The test container's PID 1 is not systemd (the Docker course explained that a container's default PID 1 is your application process).
Fix: Use an image that supports systemd,command: /usr/sbin/init,privileged: true,cgroupns_mode: host, and mount /sys/fs/cgroup; or skip service tasks via a variable in Molecule and test only the configuration. This set of parameters usually works on GitHub-hosted runners (Ubuntu 24.04, cgroup v2); self-hosted runners need their Docker configuration checked.
Error: Unable to resolve action `some-org/some-action@abc123`, unable to find version `abc123`
Cause: The SHA was shortened (GitHub requires the full 40 characters), or the tag object's SHA was used instead of the commit SHA, or the commit does not belong to that repository.
git ls-remote https://github.com/some-org/some-action.git 'refs/tags/v1.2.3^{}' 'refs/tags/v1.2.3'
Fix: Use the full 40-character commit SHA (for an annotated tag, take ^{} the last line).
ERROR: Cannot install ansible-core~=2.20.0 and ansible-lint==26.11.0 because these package versions have conflicting dependencies.
Cause: The newer ansible-lint requires a higher minimum ansible-core version.
Fix: Matrix molecule jobs do not install ansible-lint (split out requirements-test.txt); lint only needs to run once, on the latest core.
1. Run ansible-lint with the production profile and try to auto-fix the fixable issues.
ansible-lint --profile production --fix
2. After a Molecule converge failure, keep the container and investigate it, then destroy it manually.
molecule test --destroy=never molecule login -h myapp-ubuntu2404 molecule destroy
Molecule passes everything on ubuntu2404, but when deployed to the Ubuntu VM in staging, the handler fails to restart myapp. How would you improve the tests?
First find the differences: systemd, users, SELinux/AppArmor, networking between container and VM (127.0.0.1 in a container vs. real NICs), and whether Redis exists. Improvements: ① add verification of the handler result in verify.yml (after the restart /healthz); ② install dependencies (Redis) in prepare.yml to match the real topology, or add a multi-instance scenario; ③ add a nightly scenario with a real VM for key roles (for example, a create.yml that creates a temporary VM via azure.azcollection); ④ add a smoke test in CD's staging stage as the final safeguard.
Verified instructional videos
Official documentation
- Ansible Lint documentation (profiles, rules, configuration)
- Molecule documentation · Docker example
- GitHub: Security hardening for GitHub Actions (pinning by SHA)
- yamllint documentation
Video storyboard script (about 90 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: a PR card is pushed into the pipeline; four gates light up in turn: yamllint, ansible-lint, syntax, Molecule.
Narration: every PR must pass four gates. The first three are static checks that finish in seconds; the last one actually runs the role in a container.
Visual: Molecule runs twice inside the container; on the second run one task turns yellow, labeled “changed”, and the gate turns red.
Narration: the idempotence test runs once more. If any task still reports a change on the second run, the test fails.
Visual: a 3×2 matrix of cells runs in parallel; one cell turns red: rockylinux9.
Narration: matrix testing covers multiple distributions and multiple ansible-core versions at once, so compatibility problems surface before an upgrade.
Visual: a tag label is moved by a hostile hand to another commit; next to it, the forty-character SHA stays locked in place.
Narration: tags can be moved, commit hashes cannot. Pin third-party Actions to the full commit hash.
Module 3 · CD: Running Playbooks with GitHub Actions + OIDC
- Explain the GitHub Actions OIDC token exchange: the runner requests a JWT → the cloud validates issuer/audience/subject → a short-lived access token is issued; state
subthe claim formats (branch, environment, pull_request) and the 2026 immutable subject changes. - Configure trust in Azure (app registration + federated credential) and AWS (IAM OIDC provider + role trust policy), and bind the subject to
environment:prod. - Choose a connection method for the playbook: SSH private key (retrieved from Key Vault), Entra ID short-lived SSH certificate, or AWS SSM (no SSH); use
--check --diffdry runs, environment approvals,concurrencyand concurrency control to prevent concurrent deployments.
What: OIDC federated identity
GitHub is an OpenID Connect identity provider (issuer https://token.actions.githubusercontent.com). The workflow declares permissions: id-token: write , and the runner can request a token issued for this job that expires within minutes JWT. The cloud platform is pre-configured to “trust this issuer and accept only tokens whose subject is X and audience is Y”, so the runner exchanges this JWT for a short-lived cloud token —no long-lived cloud keys are stored in the repository.
Claims in the JWT related to trust
| Claim | Example | Purpose |
|---|---|---|
iss | https://token.actions.githubusercontent.com | Issuer |
aud | Azure: api://AzureADTokenExchange; AWS: sts.amazonaws.com | Who the token is for |
sub | Legacy format repo:contoso/ansible-lab:environment:prodImmutable format repo:contoso@5544123/ansible-lab@821093847:environment:prod | The most critical trust condition |
repository_id / repository_owner_id | 821093847 / 5544123 | numeric ID, does not change on rename |
environment,ref,job_workflow_ref | prod, refs/heads/main | can be used for finer-grained conditions |
The sub format depends on the trigger context: if the job is bound to an environment → …:environment:<name>; otherwise, a push to a branch → …:ref:refs/heads/main; PR → …:pull_request; tag → …:ref:refs/tags/v1.0.
sub in which a numeric ID is appended after the owner and repository name (owner@owner_id/repo@repo_id), preventing someone from registering a same-named repository after a repository is deleted or renamed and hijacking the trust (subject recycling). From 2026-07-15, newly created, renamed, or transferred repositories automatically use the immutable format; existing repositories keep the legacy format until they opt in (via the repository or organization OIDC settings / REST API). The repository created in Module 0 of this lesson is a new repository ansible-lab , so federated credentials must use the immutable format, or else you will get an error AADSTS700213 (Azure) or Not authorized to perform sts:AssumeRoleWithWebIdentity (AWS). Microsoft recommends matching both repository_id claims.Why: why not use Service Principal secrets / Access Keys
- Long-lived keys can leak (via logs, forks, or a tampered Action) and need rotation; OIDC tokens expire within minutes and are valid only for jobs with a matching subject.
- With subject binding
environment:prod, only jobs that have passed prod approval can obtain prod permissions — even if someone modifies the workflow on a feature branch, they cannot get them.
How: how the playbook connects to target hosts
| Method | Mechanism | Are there still long-lived secrets? | Best for |
|---|---|---|---|
| A. SSH private key | OIDC login to Azure → read the deployment private key from Key Vault → write to a temporary file → --private-key | the private key itself is long-lived, but it lives only in Key Vault and can be rotated and audited | Most general; the runner must be able to reach port 22 (self-hosted runner, or public IP + NSG allowlist) |
| B. Entra ID SSH certificate | VM installs AADSSHLoginForLinux extension; az ssh config issues a short-lived SSH certificate for the current signed-in identity | None (certificate is short-lived) | Azure Linux VMs; requires the “Virtual Machine Administrator/User Login” role. Refer to Microsoft Learn for details |
| C. AWS SSM | OIDC exchange for an IAM role → amazon.aws.aws_ssm the connection plugin runs through SSM Session Manager, and files are relayed via an S3 bucket | None; no need to open SSH | EC2 (Hour 4) |
When: the three release controls
- Dry run:
ansible-playbook --check --diffoutput is written to the job summary, so reviewers see “what will change” before approving. - Approval: required reviewers on the GitHub environment; combined with
prevent_self_review. - Concurrency:
concurrency: { group: deploy-prod, cancel-in-progress: false }— only one deployment per environment at a time; later runs queue instead of cancelling the one in progress (cancelling a running playbook leaves the system half-configured).
Comparison with similar technologies
| GitHub Actions OIDC | Azure DevOps workload identity federation | AWX/AAP credentials | |
|---|---|---|---|
| Secret storage | No long-lived secrets | Service connection (keyless) | Controller encrypted storage or external secret lookup |
| Trust binding | sub (repository/branch/environment) | Service connection + project | RBAC: who can use this credential |
| Best for | Git-driven deployments | ADO users | Operations / self-service / scheduling / events |
repo:org/* is more convenient” — this lets any branch of any repository in the organization obtain permissions; scope it at least to the exact repository + environment. ③ “If check mode passes, it will definitely succeed” — check mode cannot simulate tasks that depend on the real results of a previous step (for example, installing a package and then starting a service); it is a review tool, not a guarantee.Sequence diagram: OIDC token exchange + playbook execution
Architecture diagram: CD workflow with automatic staging and approved prod
OIDC token exchange sequence animation (errors can be injected)
Choose a trust configuration and run context, then play and watch each step's real request and cloud-side validation result.
Core Commands and Parameters
| Command | Purpose | Key Parameters / Notes |
|---|---|---|
az ad app create / az ad sp create | Create app registration and service principal | --display-name |
az ad app federated-credential create | Add federated credential | --parameters cred.json (issuer, subject, audiences) |
az role assignment create | Grant a role scoped to a resource group | --scope /subscriptions/…/resourceGroups/rg-ansible-lab |
aws iam create-open-id-connect-provider | Register GitHub as an IAM OIDC provider | --url https://token.actions.githubusercontent.com --client-id-list sts.amazonaws.com |
aws iam create-role --assume-role-policy-document | Create CD role and trust policy | conditions :aud,:sub |
gh api users/OWNER -q .id,gh api repos/OWNER/REPO -q .id | retrieve owner/repo numeric IDs to build the immutable subject | for organizations, use orgs/ORG |
gh secret set -e prod / gh variable set -e prod | Set environment-level secrets/variables | Client IDs and similar values are not secrets and can be stored as variables |
Azure: app registration + two federated credentials (staging / prod)
OWNER=$(gh repo view --json owner -q .owner.login); REPO=ansible-lab
OWNER_ID=$(gh api users/$OWNER -q .id); REPO_ID=$(gh api repos/$OWNER/$REPO -q .id)
SUB_ID=$(az account show --query id -o tsv); TENANT_ID=$(az account show --query tenantId -o tsv)
APP_ID=$(az ad app create --display-name gh-ansible-lab-cd --query appId -o tsv)
APP_OID=$(az ad app show --id $APP_ID --query id -o tsv)
az ad sp create --id $APP_ID -o none
for ENV in staging prod; do
cat > cred-$ENV.json <<EOF
{ "name": "gh-$REPO-$ENV",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:$OWNER@$OWNER_ID/$REPO@$REPO_ID:environment:$ENV",
"audiences": ["api://AzureADTokenExchange"] }
EOF
az ad app federated-credential create --id $APP_OID --parameters cred-$ENV.json -o none
done
az ad app federated-credential list --id $APP_OID --query "[].subject" -o tsv
# least privilege: read VMs + read Key Vault secrets at resource-group scope (the lab uses one app; for production, use separate staging/prod apps)
RG_ID=$(az group show -n rg-ansible-lab --query id -o tsv)
az role assignment create --assignee $APP_ID --role "Reader" --scope $RG_ID
az role assignment create --assignee $APP_ID --role "Key Vault Secrets User" --scope $RG_ID
for ENV in staging prod; do
gh variable set AZURE_CLIENT_ID -e $ENV -b $APP_ID
gh variable set AZURE_TENANT_ID -e $ENV -b $TENANT_ID
gh variable set AZURE_SUBSCRIPTION_ID -e $ENV -b $SUB_ID
done
repo:contoso@5544123/ansible-lab@821093847:environment:staging repo:contoso@5544123/ansible-lab@821093847:environment:prod
How to verify: After running CD, look for a federated sign-in from GitHub under Entra ID → Enterprise applications → Sign-in logs → “Service principal sign-ins”. Common errors: The repository was created before 2026-07-15 but uses the immutable format (or vice versa) — first check the current subject format under the repository's Settings → Actions → OIDC, or decode the token in the workflow to confirm (see Troubleshooting). The azure/login docs recommend passing client-id and similar values via secrets ; these are not secrets. This lesson uses variables for easy inspection; switch to secrets if your organization requires it. Production use: Use one app registration each for staging and prod, with role scopes limited to each one's resource group.
Put the deployment private key in Key Vault (option A)
KV=kv-ansible-lab-$RANDOM az keyvault create -n $KV -g rg-ansible-lab -l canadacentral --enable-rbac-authorization true -o none ssh-keygen -t ed25519 -N "" -C "gh-cd-deploy" -f ./deploy_ed25519 az keyvault secret set --vault-name $KV -n deploy-ssh-key --file ./deploy_ed25519 -o none # add the public key to azureuser on the target VM (vm-ansible-01 created in Hour 3) az vm user update -g rg-ansible-lab -n vm-ansible-01 -u azureuser --ssh-key-value "$(cat deploy_ed25519.pub)" gh variable set KEY_VAULT -e staging -b $KV; gh variable set KEY_VAULT -e prod -b $KV shred -u deploy_ed25519 # do not keep the private key locally # the current user also needs Key Vault Secrets Officer to write secrets (RBAC mode)
AWS: OIDC provider + role (option C, with SSM from Hour 4)
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
aws iam create-open-id-connect-provider --url https://token.actions.githubusercontent.com \
--client-id-list sts.amazonaws.com
cat > trust.json <<EOF
{ "Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Federated": "arn:aws:iam::$ACCOUNT:oidc-provider/token.actions.githubusercontent.com" },
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
"token.actions.githubusercontent.com:sub": "repo:$OWNER@$OWNER_ID/$REPO@$REPO_ID:environment:prod"
} } }] }
EOF
aws iam create-role --role-name gh-ansible-lab-prod --assume-role-policy-document file://trust.json
# permissions: SSM sessions + S3 relay bucket (the ansible-ssm-<acct> bucket from Hour 4) + ec2:Describe* (dynamic inventory)
Newer IAM console/CLI versions may no longer require a thumbprint for the GitHub OIDC provider; if your CLI prompts for a --thumbprint-list, see the AWS docs. The configure-aws-credentials README also warns that new repositories use the immutable sub format, and a trust policy using the legacy format will cause Not authorized to perform sts:AssumeRoleWithWebIdentity.
Lab 3: cd.yml — staging deploys automatically, prod deploys after approval (about 8 minutes)
name: cd
on:
push:
branches: [main]
paths-ignore: ["**.md"]
workflow_dispatch:
permissions:
contents: read
id-token: write # required for OIDC
jobs:
deploy:
strategy:
max-parallel: 1 # in order: staging first, then prod
matrix:
env: [staging, prod]
runs-on: ubuntu-24.04
environment: ${{ matrix.env }} # prod waits for approval here; sub = …:environment:prod
concurrency:
group: deploy-${{ matrix.env }}
cancel-in-progress: false # queue; do not cancel an in-progress deployment
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with: { python-version: "3.12", cache: pip }
- run: pip install -r requirements-dev.txt && ansible-galaxy collection install -r requirements.yml -p ./collections
- name: Azure login (OIDC)
uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Fetch deploy key from Key Vault
run: |
install -m 700 -d ~/.ssh
az keyvault secret show --vault-name "${{ vars.KEY_VAULT }}" -n deploy-ssh-key \
--query value -o tsv > ~/.ssh/deploy_ed25519
chmod 600 ~/.ssh/deploy_ed25519
ssh-keyscan -H $(ansible-inventory -i inventories/${{ matrix.env }}/hosts.yml --list \
| jq -r '._meta.hostvars[].ansible_host') >> ~/.ssh/known_hosts 2>/dev/null
- name: Dry run (check + diff)
run: |
ansible-playbook -i inventories/${{ matrix.env }}/hosts.yml playbooks/deploy-myapp.yml \
--private-key ~/.ssh/deploy_ed25519 --check --diff | tee check.log
{ echo "### ${{ matrix.env }} dry run (${GITHUB_SHA::7})"; echo '```'; tail -n 40 check.log; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
- name: Apply
run: |
ansible-playbook -i inventories/${{ matrix.env }}/hosts.yml playbooks/deploy-myapp.yml \
--private-key ~/.ssh/deploy_ed25519
- name: Smoke test
run: |
ansible -i inventories/${{ matrix.env }}/hosts.yml web --private-key ~/.ssh/deploy_ed25519 \
-m ansible.builtin.uri -a "url=http://127.0.0.1:{{ myapp_port }}/healthz status_code=200"
- name: Remove key
if: always()
run: rm -f ~/.ssh/deploy_ed25519
Using matrix + max-parallel: 1 lets staging and prod share a set of steps and guarantees their order. Note: when an earlier matrix combination fails, whether the remaining combinations continue depends on the fail-fast default (true cancels the other combinations) — which here matches “do not deploy prod if staging fails”. A clearer approach is two jobs + needs: staging, choose whichever fits your team's habits. ssh-keyscan Trusting a host key on first connect carries TOFU risk; in production, write the host public keys into the repository's known_hosts file.
git add .github/workflows/cd.yml && git commit -m "cd: OIDC deploy staging→prod" && git push # merge via PR
gh run watch
gh run view --json jobs -q '.jobs[] | {name,status,conclusion}'
{"conclusion":"success","name":"deploy (staging)","status":"completed"}
{"conclusion":"","name":"deploy (prod)","status":"waiting"}
On the GitHub run page, view staging's job summary (the dry-run diff), then click “Review deployments” → tick prod → Approve.
Waiting for a pending job in the same concurrency group (queued). Note: within the same concurrency group keeps at most one queued run; a newer queued run replaces an older queued run (the older one is cancelled), which is usually exactly what you want: “only deploy the latest SHA”. - uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT }}:role/gh-ansible-lab-${{ matrix.env }}
aws-region: ca-central-1
- run: |
ansible-playbook -i inventories/aws-${{ matrix.env }}/aws_ec2.yml playbooks/deploy-myapp.yml \
-e ansible_connection=amazon.aws.aws_ssm \
-e ansible_aws_ssm_bucket_name=${{ vars.SSM_BUCKET }} -e ansible_aws_ssm_region=ca-central-1
The runner needs the Session Manager plugin installed (session-manager-plugin), and boto3/botocore. No SSH keys or inbound ports are needed at all.
az ad app delete --id $APP_ID; az keyvault delete -n $KV (recoverable within the soft-delete retention period via az keyvault purge); AWS: aws iam delete-role --role-name gh-ansible-lab-prod (detach policies first).Case 1: migrating from Service Principal secrets to OIDC
Problem: 20 repositories shared one SP secret (Contributor, subscription scope); every annual rotation meant changing 20 places, and a single leak exposed the whole subscription. Approach: one federated credential per repository × environment (an app registration is limited to 20 federated credentials; beyond that, use user-assigned managed identities or Microsoft's flexible federated credential expressions); narrow roles to resource groups; delete the old secret. Limitation: Availability of flexible federated credentials (claimsMatchingExpression) should be confirmed in Microsoft Learn.
Case 2: a prod deployment cancelled by concurrency left the system half-configured
Problem: The workflow used concurrency: cancel-in-progress: true, and when two merges happened in a row, the first prod deployment was cancelled midway through a handler restart: 2 hosts had the new configuration, 2 had the old, and the service was not restarted. Approach: The deployment job uses cancel-in-progress: false; the playbook uses serial: 1 + max_fail_percentage: 0 in batches; only CI jobs use cancellation. Limitation: Queuing means the latest change goes live a bit later.
Case 3: target hosts on a private network
Problem: The prod VM has no public IP, and GitHub-hosted runners cannot SSH to it. Approach: Deploy a self-hosted runner inside the VNet (or GitHub's Azure private-network hosted runner), and label the runner prod ; or, rather than running the playbook directly in CD, call the AWX/AAP job template API (the controller is on the internal network, Module 4). Limitation: Self-hosted runners must be isolated (do not use them for public repositories; ephemeral runners are safer).
Common Errors and Fixes
AADSTS700213: No matching federated identity record found for presented assertion subject 'repo:contoso@5544123/ansible-lab@821093847:environment:prod'
Cause: The federated credential's subject does not exactly match the sub in the token (mismatched old/new format, environment name case differences, or the sub becomes ref:refs/heads/main when the job is not bound to an environment). The error message shows the actual sub; copy it and compare directly.
az ad app federated-credential list --id $APP_OID --query "[].{n:name,s:subject}" -o table
Fix: Create a new federated credential using the sub from the error; or adjust the job's environment binding.
Error: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable / Please make sure to give write permissions to id-token in the workflow.
Cause: The workflow or job is missing permissions: id-token: write (once a permissions block is written, any permission not listed is none). Runs from fork PRs also cannot obtain an OIDC token.
Fix: Add it at the top level or job level; do not deploy from fork PR runs. id-token: write Cause:
An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity
Cause: The trust policy's :sub or :aud does not match; repositories created after 2026-07-15 use the immutable sub.
# Debug: print the token claims in the workflow (do not print the token itself)
- run: |
T=$(curl -sH "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sts.amazonaws.com" | jq -r .value)
echo "$T" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | jq '{sub,aud,repository_id,environment}'
Fix: Update the trust policy with the printed sub (you can use StringLike to match repo:owner@id/repo@id:environment:*, but do not widen it to an organization-wide wildcard).
fatal: [vm-ansible-01]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection timed out during banner exchange"}
Cause: The NSG does not allow port 22 from the runner's egress IP, or the VM has no public IP.
az network nsg rule list -g rg-ansible-lab --nsg-name vm-ansible-01NSG -o table curl -s https://api.github.com/meta | jq '.actions | length' # hosted runner IP ranges are very numerous
Fix: Use a self-hosted runner, Azure Bastion/private network, or switch to SSM/controller API. Never open port 22 to 0.0.0.0/0.
Check mode failure: "The service myapp could not be found" / 'dict object' has no attribute 'stdout'
Cause: On the first deployment, check mode does not really install packages or create unit files, so later tasks that depend on them fail; or in check mode command is skipped, so the register variable has no stdout.
Fix: Add to the dependent tasks when: not ansible_check_mode or ignore_errors: "{{ ansible_check_mode }}"; for read-only query-type tasks, command set check_mode: false + changed_when: false.
1. For the staging environment of repository contoso/ansible-lab (owner ID 5544123, repo ID 821093847), write the Azure federated credential JSON.
{ "name": "gh-ansible-lab-staging",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:contoso@5544123/ansible-lab@821093847:environment:staging",
"audiences": ["api://AzureADTokenExchange"] }2. List the protection rules (approvers) of the current repository's prod environment.
gh api repos/{owner}/{repo}/environments/prod -q '.protection_rules'The security team is worried: “any developer who can modify workflow files can write a new job and obtain prod permissions.” How would you rebut or harden this?
The prod federated credential trusts only sub=…:environment:prod, and a job entering the prod environment must satisfy: ① a deployment branch policy that allows only the protected main (jobs from feature branches cannot get it); ② required reviewer approval (with prevent_self_review). Modifying the workflow itself requires PR review to reach main; CODEOWNERS can require .github/workflows/ review by the platform team, and the ruleset requires code owner review. Further, require job_workflow_ref the job to reference a reusable workflow centralized in the organization (AWS conditions or Entra flexible credential expressions), so that only the standard deployment workflow can obtain the prod identity.
Verified instructional videos
No verified dedicated video on “GitHub Actions OIDC + Ansible” was found.
Official documentation
- GitHub: OpenID Connect reference (claims, subject formats, immutable subject)
- GitHub Changelog: Immutable subject claims for GitHub Actions OIDC tokens
- Microsoft Learn: Migrate GitHub Actions federated credentials to immutable subjects
- Microsoft Learn: Use GitHub Actions to connect to Azure (OIDC)
- aws-actions/configure-aws-credentials · Azure/login
- amazon.aws.aws_ssm connection plugin
Video storyboard script (about 90 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: a key labeled “long-lived key” hangs at the repository door, crossed out.
Narration: storing cloud keys in the pipeline is the most common source of leaks. OIDC lets each pipeline run obtain a temporary ID card valid for a few minutes.
Visual: the runner obtains a JWT from GitHub; the JWT expands to show the sub field, and an arrow carries it to Entra ID, which uses a magnifying glass to compare it against the federated credential.
Narration: the cloud checks three things: the issuer, the audience, and the subject (sub). The subject must match exactly, for example a specific repository's prod environment.
Visual: the “@number” part of the sub is highlighted, and the old format beside it is crossed out.
Narration: since 2026, the subjects of new repositories include an immutable numeric ID, which prevents a same-named repository from hijacking trust after the original is deleted.
Visual: staging completes automatically; an approval button appears before prod; after approval the playbook runs, and the PLAY RECAP turns green.
Narration: dry run first, then approval, then execution; only one deployment per environment is allowed at a time.
Module 4 · AWX / AAP Automation Controller
- Master the controller's object model: organizations, teams, users, projects, inventories (including inventory sources), credentials, execution environments, job templates, workflow job templates, and surveys.
- Explain the execution path of one job: API launch → task manager → dependencies (project sync / inventory sync) → receptor work unit → ansible-runner in the execution environment container → event return → UI.
- Use AWX Operator 2.19.1 to deploy AWX in kind, use
awxCLI orawx.awxcollections to create objects and launch jobs as code; understand AWX's current status and AAP 2.6's components and installation methods.
What: AWX, automation controller, and AAP
- AWX: an open-source upstream project (Apache 2.0) providing a web UI, REST API, and task engine. It is deployed on Kubernetes via the AWX Operator.
- Automation controller (formerly Ansible Tower): Red Hat's commercial version built on AWX, and one of the components of AAP .
- Main AAP 2.6 components: platform gateway (unified entry point, authentication, and RBAC; introduced in 2.5), automation controller, automation hub (private collection and EE image repository), Event-Driven Ansible controller, automation mesh (receptor execution mesh), and optionally Ansible Lightspeed. Refer to the AAP 2.6 documentation for the authoritative component list.
ansible.containerized_installer); ② Operator installation on OpenShift; ③ RPM installation —2.6 is the last version supporting RPM installation (RHEL 9 only),from 2.7 onward only containerized installation is supported (for the OpenShift Operator method, refer to the official docs). For new deployments, choose containerized or Operator installation directly.Object model
| Object | What it is | Equivalent in the command-line world | Example in this lesson |
|---|---|---|---|
| Organization / Team / User | Tenants, teams, and users; the principals of RBAC | — | org Lab, teams ops,app |
| Project | A collection of playbooks pointing to a Git repository (branch/tag/SHA); can be synced automatically before a job | git clone | ansible-lab, branch main |
| Inventory + Source | Hosts and groups; inventory sources can sync from files in Git, Azure, AWS, etc. | -i inventories/staging | staging (source: inventories/staging/hosts.yml in the project) |
| Credential | Encrypted stored secrets, injected by credential type (Machine, Source Control, Vault, Microsoft Azure Resource Manager, Amazon Web Services, Container Registry…) | --private-key, environment variables | deploy-ssh (Machine) |
| Execution Environment | Container image that runs playbooks (ansible-core + collections + Python dependencies), built with ansible-builder | your venv | default quay.io/ansible/awx-ee |
| Job Template | Project + playbook + inventory + credentials + EE + variables + options (check, limit, verbosity, prompt on launch) | a complete ansible-playbook command | deploy-myapp,remediate-myapp |
| Workflow Job Template | a DAG of nodes: success/failure/always edges, approval nodes, convergence | multiple commands + logic | deploy → smoke test → roll back on failure |
| Survey | a form shown at job/workflow launch; the answers become extra vars | -e | select version number, environment |
| Schedule / Notification | RRULE scheduling; notifications when a job starts / succeeds / fails | cron + mail script | Module 7 |
Why: why a controller is needed
- Credential management: users can “use” credentials to run jobs without ever seeing the plaintext.
- RBAC: “the app team can run deploy-myapp against staging, but cannot edit the template or run it against prod”.
- Consistent execution environment: all jobs run in the same EE image, thoroughly solving “it works on my machine”.
- Auditing and visibility: the full output of every job, its trigger, extra vars, and project SHA are recorded.
- Self-service, scheduling, notifications, API, and event-driven entry points: CI/CD, ITSM, and EDA all launch the same set of templates via the API.
How: the execution path of one job (Kubernetes deployment)
POST /api/v2/job_templates/<id>/launch/(UI, CLI, EDA, and CI all go through here); validates RBAC and the Survey; creates a job (status pending).- Task manager checks dependencies: if the project is set to “update on launch”, run a project sync first; if the inventory source is set to “update on launch”, run an inventory sync first; check instance group capacity.
- dispatcher hands the job to receptor, creating a work unit; on K8s, creates a
automation-job-<id>-xxxxxPod (container group) for the job, whose image is the template's EE. - Inside the Pod, ansible-runner executes
ansible-playbook: credentials are injected by type (SSH private keys via ssh-agent, cloud credentials as environment variables), and modules run against the managed nodes. - Each event (playbook_on_task_start, runner_on_ok…) flows back through receptor to the controller's callback receiver, is written to the database, and is pushed to the UI via websocket.
- Job finishes: status successful/failed; triggers the notification template and the next node of the workflow.
When: how Actions CD and the controller divide the work
| Scenario | Recommended entry point |
|---|---|
| Code change → automatic deployment (developer view) | GitHub Actions CD (Module 3), or Actions calling the controller API |
| Operations tasks (restarts, patching, scaling, certificate rotation), self-service for non-developers | Controller job template + Survey + RBAC |
| Scheduled inspections, compliance reports | Controller scheduling |
| Automatic remediation of alerts | EDA → controller job template (Module 5) |
| Targets on an internal network with no public entry point | The controller (or mesh execution nodes) on the internal network; CI triggers it via the API |
collections/requirements.yml (or requirements.yml) only if the related option is enabled in settings and the EE can reach Galaxy/Automation Hub; the safer approach is to bake the collections into a custom EE.Architecture diagram: AWX in kind (deployed with the Operator)
Flowchart: workflow job template “deploy → smoke test → roll back on failure”
Job template launch → execution environment Pod execution path
Play one deploy-myapp launch of the job template. You can tick “update project on launch” or “sync inventory on launch”, or inject the faults “EE missing collection” or “insufficient instance capacity” to see where the path forks.
Core Commands and Parameters
| Command | Purpose | Key Parameters / Notes |
|---|---|---|
kubectl apply -k . | Install AWX Operator with kustomize | pin in kustomization ?ref=2.19.1 and image tag |
kubectl -n awx get awx,pods,svc | View AWX CR and Pods | logs -f deploy/awx-operator-controller-manager -c awx-manager |
pip install awxkit → awx | Official CLI | --conf.host --conf.username --conf.password or environment variable CONTROLLER_HOST etc. |
awx projects create / update | Project | --scm_type git --scm_url --scm_branch --scm_update_on_launch true |
awx job_templates create / launch | Job template | --monitor follow the output; --extra_vars; --limit |
awx jobs stdout ID | View job output | — |
ansible-galaxy collection install awx.awx | Manage AWX objects with playbooks (configuration as code) | AAP uses ansible.controller; AAP 2.5+ platform-level objects use ansible.platform (refer to the official docs) |
curl -u admin:… https://host/api/v2/ping/ | Health check / version | When AAP 2.5+ is accessed through the platform gateway, the path prefix differs (e.g. /api/controller/v2/); refer to the docs |
CLI login and viewing
pipx install awxkit
export CONTROLLER_HOST=http://localhost:32000 CONTROLLER_USERNAME=admin
export CONTROLLER_PASSWORD=$(kubectl -n awx get secret awx-demo-admin-password -o jsonpath='{.data.password}' | base64 -d)
awx ping -f human
awx job_templates list -f human
ha version active_node install_uuid === ======== =========================== ==================================== no 24.6.1 awx-demo-task-6c9d8f7b5-xk2lp 1f6e… id name == ==================== 7 Demo Job Template
Manage AWX objects as code (recommended; also called Configuration as Code)
---
- name: Configure AWX objects for ansible-lab
hosts: localhost
gather_facts: false
module_defaults:
group/awx.awx.controller:
controller_host: "{{ lookup('env', 'CONTROLLER_HOST') }}"
controller_username: "{{ lookup('env', 'CONTROLLER_USERNAME') }}"
controller_password: "{{ lookup('env', 'CONTROLLER_PASSWORD') }}"
tasks:
- name: Organization
awx.awx.organization: { name: Lab, state: present }
- name: Source control credential (GitHub fine-grained PAT, read-only)
awx.awx.credential:
name: github-ro
organization: Lab
credential_type: Source Control
inputs: { username: git, password: "{{ lookup('env', 'GH_RO_TOKEN') }}" }
- name: Machine credential
awx.awx.credential:
name: deploy-ssh
organization: Lab
credential_type: Machine
inputs:
username: azureuser
ssh_key_data: "{{ lookup('file', lookup('env', 'DEPLOY_KEY_FILE')) }}"
- name: Project
awx.awx.project:
name: ansible-lab
organization: Lab
scm_type: git
scm_url: https://github.com/contoso/ansible-lab.git
scm_branch: main
scm_update_on_launch: true
credential: github-ro
- name: Inventory + source from project file
awx.awx.inventory: { name: staging, organization: Lab }
- name: Inventory source
awx.awx.inventory_source:
name: staging-from-git
inventory: staging
source: scm
source_project: ansible-lab
source_path: inventories/staging/hosts.yml
update_on_launch: true
overwrite: true
- name: Job template deploy-myapp
awx.awx.job_template:
name: deploy-myapp
organization: Lab
project: ansible-lab
playbook: playbooks/deploy-myapp.yml
inventory: staging
credentials: [deploy-ssh]
ask_limit_on_launch: true
diff_mode: true
survey_enabled: true
survey_spec:
name: deploy
description: choose version
spec:
- question_name: myapp version
variable: myapp_version
type: multiplechoice
choices: ["1.4.0", "1.3.2"]
default: "1.4.0"
required: true
- name: Job template remediate-myapp (used by EDA in module 5)
awx.awx.job_template:
name: remediate-myapp
organization: Lab
project: ansible-lab
playbook: playbooks/remediate-myapp.yml
inventory: staging
credentials: [deploy-ssh]
ask_limit_on_launch: true
ask_variables_on_launch: true
How to verify:awx job_templates list -f human You should see two templates. Common errors: Module parameter names may change with the awx.awx version (for example, survey-related parameters); refer to ansible-doc awx.awx.job_template for the correct names; the awx.awx Galaxy version corresponds to AWX 24.6.1. Production use: All controller objects are managed in Git and applied via CI; the UI is used only to view and run — this is the controller's own GitOps.
Lab 4: deploy AWX in kind and run deploy-myapp (about 15 minutes, including waiting)
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: awx
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 32000
hostPort: 32000
listenAddress: "127.0.0.1"
- role: worker
kind create cluster --config kind-awx.yaml kubectl cluster-info --context kind-awx
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/ansible/awx-operator/config/default?ref=2.19.1
images:
- name: quay.io/ansible/awx-operator
newTag: 2.19.1
namespace: awx
mkdir -p ~/awx && cd ~/awx # put the kustomization.yaml above here kubectl apply -k . kubectl -n awx rollout status deploy/awx-operator-controller-manager --timeout=5m
namespace/awx created customresourcedefinition.apiextensions.k8s.io/awxbackups.awx.ansible.com created customresourcedefinition.apiextensions.k8s.io/awxrestores.awx.ansible.com created customresourcedefinition.apiextensions.k8s.io/awxs.awx.ansible.com created … deployment "awx-operator-controller-manager" successfully rolled out
apiVersion: awx.ansible.com/v1beta1 kind: AWX metadata: name: awx-demo namespace: awx spec: service_type: nodeport nodeport_port: 32000
kubectl apply -f awx-demo.yaml kubectl -n awx logs -f deploy/awx-operator-controller-manager -c awx-manager | grep -E "PLAY RECAP|failed=" & kubectl -n awx get pods -w # about 5–10 minutes; press Ctrl+C once web/task are Running
NAME READY STATUS RESTARTS AGE awx-demo-migration-24.6.1-7hx2k 0/1 Completed 0 4m awx-demo-postgres-15-0 1/1 Running 0 6m awx-demo-task-6c9d8f7b5-xk2lp 4/4 Running 0 5m awx-demo-web-7f8d9c6b4-q9wzt 3/3 Running 0 5m awx-operator-controller-manager-58b7c9b5c4-2mtbn 2/2 Running 0 8m
kubectl -n awx get secret awx-demo-admin-password -o jsonpath='{.data.password}' | base64 -d; echo
# open http://localhost:32000 in a browser (remote VM: ssh -L 32000:127.0.0.1:32000 azureuser@VM)controller/configure.yml put it in the repository, and run:
ansible-galaxy collection install awx.awx
export GH_RO_TOKEN=github_pat_xxx # read-only fine-grained PAT (repository Contents: Read)
export DEPLOY_KEY_FILE=~/deploy_ed25519 # temporarily retrieve from Key Vault: az keyvault secret show … > file
ansible-playbook controller/configure.yml
awx job_templates launch deploy-myapp --extra_vars '{"myapp_version":"1.4.0"}' --monitor
------Starting Standard Out Stream------ Identity added: /runner/artifacts/12/ssh_key_data (gh-cd-deploy) PLAY [Deploy myapp] ************************************************************ TASK [Gathering Facts] ********************************************************* ok: [vm-ansible-01] TASK [myapp : Render myapp.env] ************************************************ ok: [vm-ansible-01] … PLAY RECAP ********************************************************************* vm-ansible-01 : ok=12 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 ------End of Standard Out Stream--------
“Identity added: /runner/artifacts/…” shows that ansible-runner loaded the Machine credential into ssh-agent — the private key does not appear in the job output. While the job runs, execute kubectl -n awx get pods | grep automation-job you can see the temporary job Pod.
- name: Launch AWX job template
env:
CONTROLLER_HOST: ${{ vars.CONTROLLER_HOST }}
CONTROLLER_OAUTH_TOKEN: ${{ secrets.CONTROLLER_TOKEN }}
run: |
pip install awxkit
awx job_templates launch deploy-myapp --extra_vars "{\"git_sha\":\"$GITHUB_SHA\"}" --monitor
When the controller is on the internal network, a self-hosted runner is needed to reach the API. For the token, use a dedicated user with minimal permissions (Execute permission on this template only).
kind delete cluster --name awx (see Module 8).Case 1: migrating from Jenkins scripts to the controller
Problem: The operations team had 80 Jenkins jobs, each one ssh jumping to a bastion host to run ansible-playbook, with credentials scattered across the Jenkins credential store and the bastion host. Approach: Each Jenkins job maps to one job template; credentials are consolidated into the controller (external secret lookup, Module 6); Jenkins is only responsible for calling awx job_templates launch; after three months, ansible access on the bastion host was turned off. Limitation: Parameterized Jenkins builds must be converted to Surveys one by one.
Case 2: a custom execution environment resolves dependency conflicts
Problem: The Python package versions required by the Azure and AWS collections conflict, and one venv cannot hold both. Approach: Use ansible-builder to build two EEs (ee-azure,ee-aws), push them to a private Automation Hub/ACR; job templates reference them as needed; EE definition files are kept in Git and built, scanned, and referenced by digest through CI. Configuration:execution-environment.yml 's dependencies.galaxy and dependencies.python. Limitation: EE images are large (on the order of 1 GB), requiring image caching and periodic rebuilds to patch.
Case 3: AAP 2.6 upgrade planning
Problem: The existing AAP 2.4 RPM installation runs on RHEL 8. Approach: Build a new containerized AAP 2.6 deployment (RHEL 9) and migrate objects using Configuration as Code (ansible.controller etc. collections), migrate data per the official migration guide; since 2.7 only supports containerized installation, RPM is no longer an option. Limitation: The upgrade path and support matrix should be confirmed against Red Hat's official documentation; a subscription is required.
Common Errors and Fixes
awx-demo-postgres-15-0 stuck in Pending: pod has unbound immediate PersistentVolumeClaims
Cause: The cluster has no default StorageClass, or the StorageClass requested by the PVC does not exist. kind ships with a default standard (local-path).
kubectl get sc; kubectl -n awx get pvc; kubectl -n awx describe pvc postgres-15-awx-demo-postgres-15-0
Fix: Make sure a default StorageClass exists, or set postgres_storage_class in the AWX CR.
Browser access to http://localhost:32000 gets no response / connection refused
Cause: The kind cluster was created without extraPortMappings (it cannot be added afterwards), or the Service's nodePort is not 32000, or the web Pod is not ready.
kubectl -n awx get svc awx-demo-service docker port awx-control-plane kubectl -n awx get pods -l app.kubernetes.io/component=awx
Fix: Temporarily use kubectl -n awx port-forward svc/awx-demo-service 8080:80; or recreate the kind cluster with the port mapping.
ERROR! couldn't resolve module/action 'community.general.slack' (the job fails in AWX but runs locally)
Cause: The job runs in an EE container, which does not include that collection; the local venv does.
podman run --rm quay.io/ansible/awx-ee:latest ansible-galaxy collection list | grep community.general
Fix: Place collections/requirements.yml in the project so project sync installs it, or build a custom EE (ansible-builder).
Job stays pending: "Job is waiting for capacity" / no output at all
Cause: Instance group capacity is insufficient (the container group's concurrent-job limit, or insufficient K8s node resources leave the job Pod Pending), or the dependent project sync failed.
kubectl -n awx get pods | grep automation-job kubectl -n awx describe pod automation-job-12-xxxxx | tail -20 awx instance_groups list -f human
Fix: Add node resources, adjust the job Pod's resource requests (container group pod spec), and check the output of the project sync job.
Failed to update project: fatal: could not read Username for 'https://github.com': terminal prompts disabled
Cause: The private repository has no associated Source Control credential, or the PAT has expired or lacks permissions.
Fix: Associate the project with the github-ro credential; use a fine-grained PAT (Contents: Read), a GitHub App, or an SSH deploy key.
1. Retrieve the initial admin password generated by the AWX Operator.
kubectl -n awx get secret awx-demo-admin-password -o jsonpath='{.data.password}' | base64 -d; echo2. Use the awx CLI to launch deploy-myapp, limited to vm-ansible-01, and follow the output.
awx job_templates launch deploy-myapp --limit vm-ansible-01 --monitor
The template must have “prompt on launch for limit” enabled (ask_limit_on_launch: true).
The company requires: “the development team can deploy myapp to staging by themselves, but cannot see the SSH private key and cannot deploy to prod; prod deployments require operations approval”. How do you design this in the controller?
Two inventories, staging and prod; two Machine credentials; a job template deploy-myapp-staging (inventory staging) and a workflow deploy-myapp-prod (containing an approval node, with the ops team as approvers). Grant the app team the Execute role on deploy-myapp-staging (no Admin/Use credential roles — the template supplies the credential at run time, so users never see the plaintext); for the prod workflow, grant only Read or Execute (ops approval is still required after triggering). All objects are managed by configure.yml in Git; the activity stream records every run and approval.
Verified instructional videos
Official documentation
- AWX GitHub (the release-pause note in the README)
- AWX Operator Releases · AWX Operator Basic install · kind installation
- Red Hat AAP 2.6 documentation
- awx.awx collection
Video storyboard script (about 90 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: a long ansible-playbook command is broken into building blocks — project, inventory, credentials, execution environment — which snap together into a “job template”.
Narration: a job template is a complete command turned into objects: which repository, which inventory, which credentials, and which execution environment it runs in.
Visual: clicking “Launch”; a task manager icon checks dependencies, then a job Pod pops up in Kubernetes, and the log streams back to the interface.
Narration: every job runs in its own execution-environment Pod; events stream back to the controller in real time and are stored permanently.
Visual: a developer's avatar has only a “Run” button; the credential icon has a lock on it.
Narration: users can run jobs using credentials without ever seeing the plaintext — this is the value of the controller.
Visual: next to the AWX logo, a “Releases paused” tag appears; next to the AAP 2.6 logo, a “Containerized installation” label appears.
Narration: AWX suits learning and experimentation; for production, evaluate AAP. Note that from 2.7 onward only containerized installation is supported.
Module 5 · Event-Driven Ansible
- Explain how ansible-rulebook works: event source plugins (Python asyncio) put events into a queue → filters process them → the Drools rules engine (running in the JVM via drools_jpy) matches conditions → actions execute.
- Write rulebooks:
sourcesevent sources (webhook, Alertmanager, Kafka),filtersfilters (includingeda.builtin.event_splitter,insert_hosts_to_meta),rules(condition, throttle) and actions (run_job_template,run_playbook,debug,post_event). - Connect alerts to AWX job templates for automated remediation, and understand AAP's EDA controller (decision environments, rulebook activations, event streams, and external secret support in 2.6).
remediate-myapp; basic concepts of Prometheus/Alertmanager. Importance:★★★★★ (the key step from L4 → L5; this lesson's core animation)What: rulebook
A rulebook is a YAML file containing one or more rulesets. Each ruleset declares: from which event sources it receives events, which filters to apply to the events, and which rules (condition + action) to use. ansible-rulebook The CLI runs for a long time, continuously waiting for events.
---
- name: myapp auto-remediation
hosts: all # host scope available to actions (works with the inventory)
sources:
- name: alertmanager
ansible.eda.alertmanager: # event source plugin in the ansible.eda collection
host: 0.0.0.0
port: 5050
data_alerts_path: alerts # default: split payload.alerts into individual events
data_host_path: labels.instance # default: host name written to event.meta.hosts
rules:
- name: myapp down → restart via AWX
condition: >-
event.alert.status == "firing" and
event.alert.labels.alertname == "MyappDown"
throttle: # fix at most once per host within 5 minutes, to prevent storms
once_within: 5 minutes
group_by_attributes:
- event.alert.labels.instance
action:
run_job_template:
name: remediate-myapp
organization: Lab
job_args:
limit: "{{ event.meta.hosts[0] }}"
extra_vars:
alert_name: "{{ event.alert.labels.alertname }}"
alert_started: "{{ event.alert.startsAt }}"
- name: resolved → just log
condition: event.alert.status == "resolved"
action:
debug:
msg: "resolved {{ event.alert.labels.alertname }} on {{ event.meta.hosts }}"
Component
| Part | Description | Common |
|---|---|---|
| Event source (source) | A Python plugin in the collection, implementing async def main(queue, args), putting dict events queue.put() into the queue | ansible.eda.webhook,ansible.eda.alertmanager,ansible.eda.kafka,ansible.eda.range (for testing),ansible.eda.generic (for testing). ansible.eda has deprecated a batch of sources since 2.11 (aws_sqs_queue, azure_service_bus, file, file_watch, journald, tick, url_check, etc.); for new projects, check the collection docs |
| Filters | Process events before they enter the rules engine | eda.builtin.event_splitter (split an array in one payload into multiple events; listed as a new feature in the AAP 2.6 release notes),eda.builtin.insert_hosts_to_meta,eda.builtin.json_filter,eda.builtin.dashes_to_underscores,eda.builtin.normalize_keys |
| Condition (condition) | Expressions on event.*,fact.*,vars.* of: ==,!=,>,is defined,in,contains,is match(…, pattern=),is search; all:/any:/not_all: combine multiple events | Note: the condition is not Jinja, do not add {{ }} |
| Action (action) | executed after a match | run_job_template,run_workflow_template,run_playbook,run_module,post_event,set_fact,retract_fact,debug,print_event,none,shutdown; actions: multiple can be listed |
| throttle | Throttle by attribute grouping: once_within (first triggering within the window) or once_after (triggers once after the window ends) | alert-storm protection |
Why: why event-driven
- Reduce MTTR: at 3 a.m., myapp crashes; the traditional flow is alert → page on-call → log in → restart (15–30 minutes); EDA completes a known fix within seconds and attaches the context (logs) to the notification.
- Reuse: the fix logic remains a job template in the controller, enjoying credentials, RBAC, and auditing; EDA only decides “when to trigger which template”.
- More than alerts: Git webhooks, ITSM tickets, Kafka messages, and cloud events can all serve as sources.
How: internal mechanism
- When ansible-rulebook starts, it creates one asyncio task per source (for example, the alertmanager plugin internally uses aiohttp to start an HTTP server).
- Alertmanager POSTs a JSON payload containing
alerts[]JSON; the plugin enqueues the raw payload (skip_original_data: false) and each alert separately; each alert event looks like{"alert": {...}, "meta": {"endpoint": …, "headers": …, "hosts": ["vm-ansible-01"]}}. - filters process the events in sequence; then the events are asserted into the Drools rules engine (Java, invoked via drools_jpy/JPype, so JDK ≥ 17 is required).
- After a rule matches, the engine calls back into the Python side to execute the action;
run_job_templatecalls the controller REST API to launch the template; by default, puts the triggering event into the extra vars underansible_eda.event(can be turned off withinclude_events: false). - Action results can be fed back into the rules engine via
post_events/set_factsto implement multi-step logic such as “remediation failed → escalate”.
EDA controller in AAP
| Object | Description |
|---|---|
| Project | Git repository containing the rulebooks (rulebooks placed in rulebooks/ or extensions/eda/rulebooks/) |
| Decision Environment (DE) | Container image that runs ansible-rulebook (contains the event source collections and Java), built with ansible-builder; the equivalent of an EE for jobs |
| Rulebook Activation | A long-running instance of “project + rulebook + DE + credentials + variables”; a restart policy can be set |
| Event Stream (2.5+) | A webhook entry URL provided by the platform (with token/HMAC or other authentication); the platform routes events to activations, so no separate port needs to be exposed for each activation |
| Credentials (2.6) | Red Hat AAP credentials (for calling the controller), container registry credentials, event stream authentication credentials; since 2.6, EDA supports external secret management systems (HashiCorp Vault, CyberArk, Azure Key Vault, AWS Secrets Manager), consistent with the controller |
The open-source upstream is ansible/eda-server(has an eda-server-operator). This lesson's lab uses the ansible-rulebook CLI + AWX directly; the mechanism is the same.
When: which events suit automatic remediation
| Suitable | Not suitable |
|---|---|
| Faults with a known root cause and a standard response (process crash and restart, disk cleanup, certificate renewal, scaling out) | Faults with an unknown root cause that need judgment (data corruption, security incidents) — only gather information and create a ticket |
| Remediation actions are idempotent and safe to repeat | Irreversible operations (deleting data, failing over a database) — add an approval node |
Comparison with similar technologies
| EDA | Alertmanager webhook → homegrown script | StackStorm / Rundeck | |
|---|---|---|---|
| Rule expression | YAML rulebook + Drools | Code | Rules / jobs |
| Execution | Controller job template (credentials, RBAC, auditing) | Script carries its own credentials | Each has its own executor |
| Ecosystem | Ansible collection event sources + existing playbooks | — | Separate ecosystem |
{{ event.x }}” — the condition uses the rulebook's own expression language,with no curly braces; Jinja references are only used in action parameters {{ event.… }}. ② “A rulebook can replace the playbook” — a rulebook only makes decisions; the actual change is still executed by a playbook or job template. ③ “The more automatic remediation, the better” — automatic remediation without throttling, failure escalation, or auditing will amplify a small fault into a restart storm.Architecture diagram: inside ansible-rulebook
Data flow: how an Alertmanager alert changes shape in a rulebook
alerts and writes labels.instance with the port removed, into meta.hostsCore animation: one event-driven automatic remediation
Alert → EDA event source → rule match → trigger job template → execute playbook → notify. Below each step, the terminal shows the real HTTP request, rules engine log, or job output. You can simulate an “alert storm” to see how throttle works, or simulate a “failed remediation” to see the escalation path.
Core Commands and Parameters
| Command / parameter | Purpose | Notes |
|---|---|---|
ansible-rulebook -r FILE -i INV | Run a rulebook | -r A rulebook inside the collection can also be written ns.coll.name |
--controller-url / --controller-token or --controller-username/--controller-password | Controller connection needed by run_job_template | environment variables EDA_CONTROLLER_URL,EDA_CONTROLLER_TOKEN…; --controller-ssl-verify |
--print-events,-v / -vv | Print received events / debug logs | Must be enabled when developing rules |
-e vars.yml / -E VAR1,VAR2 | Pass in variables / import from environment variables | Reference in rules with vars.x reference |
-S DIR | Directory of locally developed event source plugins | — |
ansible-galaxy collection install ansible.eda | Install the event source collection | The Python dependencies for webhook/alertmanager/kafka (aiohttp, aiokafka) must be in the same environment |
ansible-lint rulebooks/ | Rulebook schema validation | kinds must be declared in .ansible-lint (Module 2) |
Minimal runnable example: webhook + debug (no AWX required)
---
- name: hello webhook
hosts: all
sources:
- ansible.eda.webhook:
host: 0.0.0.0
port: 5000
rules:
- name: deploy requested
condition: event.payload.action == "deploy" and event.payload.env in ["dev", "staging"]
action:
debug:
msg: "would deploy {{ event.payload.version }} to {{ event.payload.env }}"
- name: anything else
condition: event.payload is defined
action:
print_event:
pretty: true
ansible-galaxy collection install ansible.eda
ansible-rulebook -r rulebooks/hello-webhook.yml -i inventories/dev/hosts.yml --print-events &
sleep 5
curl -s -X POST localhost:5000/endpoint -H 'Content-Type: application/json' \
-d '{"action":"deploy","env":"staging","version":"1.4.0"}'
{'payload': {'action': 'deploy', 'env': 'staging', 'version': '1.4.0'},
'meta': {'endpoint': 'endpoint', 'headers': {…}, 'received_at': '2026-11-15T09:12:03.512Z',
'source': {'name': 'ansible.eda.webhook', 'type': 'ansible.eda.webhook'}, 'uuid': '…'}}
** 2026-11-15 09:12:03.530 [debug] ****************************************
would deploy 1.4.0 to staging
**************************************************************************
The webhook source puts the HTTP body in event.payload, and the URL path in meta.endpoint. In production, authentication must be enabled: the webhook source supports token (Bearer) and HMAC signatures (hmac_secret etc. parameters), along with TLS certificate parameters; confirm the exact parameter names in ansible-doc -t eda or the collection docs; in AAP, use the Event Stream entry point instead.
event_splitter: when a single payload contains multiple events
sources:
- ansible.eda.webhook: # use the generic webhook to receive the Alertmanager payload
host: 0.0.0.0
port: 5000
filters:
- eda.builtin.event_splitter:
splitter_key: payload.alerts # the nested key where the array lives
extras:
source_system: alertmanager # add a static attribute to each split event
- eda.builtin.insert_hosts_to_meta:
host_path: labels.instance # host field in split events → meta.hosts
If splitter_key is missing, the default is to pass the payload through unchanged (can be changed with raise_error to raise an error); attributes_key_map parent fields (such as payload.receiver) can be copied to each split event. To see the exact structure of split events, use --print-events to observe before writing conditions.
Kafka event source
sources:
- ansible.eda.kafka:
host: kafka.lab.internal
port: 9092
topic: infra-events
group_id: eda-myapp
offset: latest
rules:
- name: disk almost full
condition: event.body.type == "disk" and event.body.used_pct >= 90
action:
run_job_template:
name: cleanup-disk
organization: Lab
job_args: { limit: "{{ event.body.host }}" }
The message body of a Kafka source event is usually located in event.body; ansible.eda 2.9–2.13 added multi-topic/pattern subscriptions, feedback queues, and Avro + Schema Registry support. Confirm SASL/TLS parameters in the collection docs.
Lab 5: simulate an Alertmanager alert; EDA triggers AWX automatic remediation (about 10 minutes)
remediate-myapp references it):
---
- name: Remediate myapp
hosts: web
become: true
gather_facts: false
vars:
myapp_port: 8000
tasks:
- name: Capture last 50 log lines before restart
ansible.builtin.command: journalctl -u myapp -n 50 --no-pager
register: before_logs
changed_when: false
- name: Restart myapp
ansible.builtin.systemd_service:
name: myapp
state: restarted
- name: Wait for /healthz
ansible.builtin.uri:
url: "http://127.0.0.1:{{ myapp_port }}/healthz"
status_code: 200
register: hz
retries: 10
delay: 3
until: hz.status == 200
- name: Summary for notification
ansible.builtin.debug:
msg: >-
remediated {{ inventory_hostname }} for
{{ alert_name | default(ansible_eda.event.alert.labels.alertname | default('manual')) }};
healthz={{ hz.status }}awx users create --username eda-bot --password "$(openssl rand -base64 18)" --email eda@lab.local awx roles grant --user eda-bot --job_template remediate-myapp --type execute 2>/dev/null \ || echo "Grant this in the UI according to your awxkit version: template → Access → add eda-bot → Execute" # log in to the UI as eda-bot → user details → tokens → create a personal access token (scope: write), save as EDA_TOKEN export EDA_CONTROLLER_URL=http://localhost:32000 EDA_CONTROLLER_TOKEN=<paste token>
The subcommand format for granting roles in awxkit varies by version; if it is unavailable, do it in the UI. Do not give the admin account to EDA.
rulebooks/myapp-remediate.yml from the “Theory” page):
ansible-rulebook -r rulebooks/myapp-remediate.yml -i inventories/staging/hosts.yml \ --controller-url "$EDA_CONTROLLER_URL" --controller-token "$EDA_CONTROLLER_TOKEN" \ --controller-ssl-verify no -v
2026-11-15 09:20:01,112 - ansible_rulebook.app - INFO - Starting sources 2026-11-15 09:20:01,113 - ansible_rulebook.app - INFO - Starting rules 2026-11-15 09:20:01,402 - drools.ruleset - INFO - Using jar: …/drools-ansible-rulebook-integration-runtime-…jar 2026-11-15 09:20:02,021 - ansible_rulebook.engine - INFO - load source ansible.eda.alertmanager 2026-11-15 09:20:02,644 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
ssh azureuser@20.151.0.10 'sudo systemctl stop myapp' # really take myapp down
curl -s -X POST http://localhost:5050/ -H 'Content-Type: application/json' -d @- <<'EOF'
{"version":"4","status":"firing","receiver":"eda","groupKey":"{}:{alertname=\"MyappDown\"}",
"groupLabels":{"alertname":"MyappDown"},"commonLabels":{"alertname":"MyappDown","severity":"critical"},
"externalURL":"http://alertmanager:9093",
"alerts":[{"status":"firing",
"labels":{"alertname":"MyappDown","instance":"vm-ansible-01:8000","job":"myapp","severity":"critical"},
"annotations":{"summary":"myapp /healthz failing"},
"startsAt":"2026-11-15T09:21:00Z","endsAt":"0001-01-01T00:00:00Z","fingerprint":"a1b2c3d4"}]}
EOF
… - ansible_rulebook.rule_set_runner - INFO - call_action run_job_template … - ansible_rulebook.job_template_runner - INFO - Job template remediate-myapp launched, job id 23 … - ansible_rulebook.job_template_runner - INFO - job results url: http://localhost:32000/#/jobs/playbook/23/details … - ansible_rulebook.rule_set_runner - INFO - Task action::run_job_template::myapp auto-remediation::myapp down → restart via AWX finished, active actions 0
Log wording depends on your ansible-rulebook version. In this lab, the host name in the instance label (after removing the port) must match the host name in the inventory limit in order to match.
awx jobs list --name remediate-myapp -f human | tail -3 awx jobs stdout 23 | tail -5 curl -s http://20.151.0.10:8000/healthz # if the NSG only opens 22, ssh in and curl 127.0.0.1 # immediately send the same alert again → no job starts again within the 5-minute window curl -s -X POST http://localhost:5050/ -H 'Content-Type: application/json' -d @alert.json
id name status started
== ================ ========== ====================
23 remediate-myapp successful 2026-11-15T09:21:07Z
ok: [vm-ansible-01] => {
"msg": "remediated vm-ansible-01 for MyappDown; healthz=200"
}
{"status":"ok","redis":"ok"}Case 1: automatic disk-alert cleanup (with failure escalation)
Problem: Log directories filling the disk happened several times a week. Approach: The rulebook matches DiskUsageHigh → run_workflow_template: disk-cleanup (clean old logs → re-check utilization); the workflow's failure branch creates a ServiceNow event and @-mentions on-call; throttle is set to once per host every 30 minutes. Configuration:run_workflow_template + post_events: true feed the result back; another rule matches “still above 90% after cleanup”. Limitation: Only clean regenerable logs; never automatically delete business data.
Case 2: Git push triggers configuration sync (GitOps supplement)
Problem: The network team wanted switch configuration repository changes pushed out immediately after merge, rather than waiting for the nightly schedule. Approach: GitHub webhook → AAP Event Stream → rulebook matches ref == "refs/heads/main" → run_job_template: push-network-config, the template runs first in check mode, and the diff is posted back to the PR. Limitation: The webhook must be validated with HMAC; events may be delivered more than once, so jobs must be idempotent.
Case 3: protection during an alert storm
Problem: A Redis failure caused 40 application hosts to raise MyappDown simultaneously; the rulebook started a restart job for each host, and restarting did not help — it lengthened the recovery. Approach: In the rule, use all:/count facts to recognize a “widespread outage”; in that case, only send notifications and do not remediate; only auto-restart for single-host failures; set a concurrency limit on the remediation template (turn off “allow concurrent jobs” + use slicing). Limitation: The threshold defining “widespread” must be set in advance.
Common Errors and Fixes
JVM not found / Java version 17 or later is required / drools_jpy import failure
Cause: The ansible-rulebook rules engine runs in the JVM and requires JDK ≥ 17, and JAVA_HOME must be findable.
java -version; echo $JAVA_HOME sudo apt-get install -y openjdk-17-jre-headless && export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ERROR - Source plugin ansible.eda.alertmanager not found / ModuleNotFoundError: No module named 'aiohttp'
Cause: The ansible.eda collection is not installed to a path ansible-rulebook can find, or the event source's Python dependencies are not in the virtual environment where ansible-rulebook lives (pipx isolation!).
ansible-galaxy collection list ansible.eda pipx inject ansible-rulebook aiohttp aiokafka
Events are received (visible with --print-events), but the rule never fires
Cause: The path in the condition does not match the actual event structure (for webhook it is event.payload.x, for alertmanager it is event.alert.x); string case; mistakenly used {{ }} in the condition; or suppressed by the throttle window.
Fix: Use -vv to view engine logs; first write a condition: event.alert is defined + print_event debug rule to confirm the structure.
Error connecting to controller: 401 Unauthorized / 404 Not Found when launching job template "remediate-myapp"
Cause: The token is invalid, eda-bot lacks Execute permission on the template (to it, the template “does not exist”, returning 404), the organization name does not match, or the URL points to the AAP platform gateway without the correct path prefix.
curl -s -H "Authorization: Bearer $EDA_CONTROLLER_TOKEN" "$EDA_CONTROLLER_URL/api/v2/job_templates/?name=remediate-myapp" | jq '.count'
The job starts but reports "Provided hosts list is empty, only localhost is available"
Cause:limit The instance taken from the alert (e.g. 10.0.1.5:8000 or FQDN) does not match the host name in the controller inventory.
Fix: Align Prometheus' instance label with inventory host names (add a hostname label via relabeling), or match in the playbook by ansible_host .
1. Write a rule: when the webhook event payload.severity is critical and payload.service starts with “myapp”, print the event.
- name: critical myapp
condition: event.payload.severity == "critical" and event.payload.service is match("myapp.*", ignorecase=true)
action:
print_event:
pretty: true2. Run the rulebook in debug mode, print every received event, and connect to a local AWX.
ansible-rulebook -r rulebooks/myapp-remediate.yml -i inventories/staging/hosts.yml --print-events -v \ --controller-url http://localhost:32000 --controller-token "$EDA_CONTROLLER_TOKEN"
You want to extend “automatically restart myapp when it goes down” to 200 production hosts. List at least 5 guardrails.
① throttle: remediate at most once per host within a window; ② widespread-failure detection: when the number of simultaneously failing hosts exceeds a threshold, only notify and do not remediate; ③ verify after remediation (/healthz), and escalate on failure (post_event → notification/ticket), never retry indefinitely; ④ minimum permissions for the remediation template (can only restart myapp), and EDA uses a dedicated token; ⑤ auditing: each automatic remediation carries ansible_eda.event a record in the job, and sends a notification; ⑥ maintenance-window suppression (Alertmanager silence or a fact check in the rule); ⑦ run the same rulebook in staging for a week first and count false triggers; ⑧ rulebooks go through PRs + ansible-lint validation.
Verified instructional videos
Official documentation
- ansible-rulebook documentation(installation · filters: event_splitter · CLI)
- ansible.eda collection (event source plugins)
- AAP 2.6: Using automation decisions (EDA controller)
Video storyboard script (about 100 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: 3 a.m.; the myapp icon turns red, and the on-call engineer's phone rings.
Narration: in the traditional process, a crashed process waits for someone to be woken up, log in, and restart it — often taking half an hour.
Visual: the alert JSON flies into the EDA event source, is split into individual events, and enters a gear labeled Drools.
Narration: event-driven Ansible receives the alert, splits it into events, and hands them to the rules engine to decide: is this a fault we know how to fix?
Visual: the rule matches; an arrow points to the AWX job template; a job Pod appears in Kubernetes, restarts the service, and checks the health endpoint.
Narration: once a rule matches, it calls the controller's job template. The actual fix is still done by the playbook; the credentials and auditing live in the controller.
Visual: the second alert for the same host is blocked by a shield labeled throttle; a Slack message reads “automatically remediated”.
Narration: throttling prevents a remediation storm, and the result is notified to the team; if the fix doesn't work, it escalates to a human.
Module 6 · Credentials, RBAC, and Auditing
- Distinguish built-in credential types, custom credential types (inputs + injectors), and external secret lookups (credential input source); know how credentials are injected into jobs (ssh-agent, environment variables, extra vars, temporary files).
- Design organization / team / role permissions — Admin, Execute, Use, Read, Update, Approve, Auditor, etc. — achieving “can use but not view, can run but not modify”.
- Use the activity stream, job records, and external log aggregation for auditing, and tie them to GitHub deployment records and cloud sign-in logs.
What: the three forms of credentials
| Form | Description | Examples |
|---|---|---|
| Built-in credential types | Predefined fields and injection methods of the controller | Machine (SSH user/private key/become), Source Control, Vault (Ansible Vault password), Amazon Web Services, Microsoft Azure Resource Manager, Container Registry, Red Hat Ansible Automation Platform (used by EDA to call the controller) |
| Custom credential types | Defined by yourself inputs (form fields, which can be marked secret) and injectors (injected as env / extra_vars / temporary files) | Slack Bot Token, internal API tokens, database DSN |
| External secret lookup | A credential field does not exist in the controller; instead it is read in real time from an external system when the job starts (credential input source) | Microsoft Azure Key Vault, HashiCorp Vault Secret Lookup / Signed SSH, CyberArk, AWS Secrets Manager Lookup, etc. (check the available list for your version) |
Injection methods: The Machine private key is loaded by ansible-runner into the ssh-agent inside the job Pod; cloud credentials become environment variables (such as AZURE_CLIENT_ID/AZURE_SECRET,AWS_ACCESS_KEY_ID); custom types can be written into extra_vars or use {{ tower.filename }} to generate temporary files. When the job finishes, the Pod is deleted and the secrets disappear with it; secret values in job output are masked as far as possible, but values the playbook itself debug prints out are not — sensitive tasks should add no_log: true.
Why: why external secret management
- Single source of truth: secrets are rotated only in Key Vault/Vault; the controller, CI, and applications all read from the same place, so you never get “rotated in Vault but the controller still has the old one”.
- Auditing: each read is logged in the Key Vault diagnostic logs and can be correlated with the controller job ID.
- Unified in AAP 2.6: the EDA controller also supports external secret management systems; the controller token used in rulebook activations and the HMAC key for event streams can both come from Vault/Key Vault, used the same way as in the controller.
How: RBAC model
| Role | Granted on | Allows |
|---|---|---|
| Organization Admin / Member / Auditor | Organization | Manage everything within the organization / membership / read-only view of all objects and jobs in the organization |
| Admin | Specific objects (templates, projects, inventories, credentials…) | Modify, delete, and grant authorization to others |
| Execute | Job templates, workflows | Launch (answer the Survey),without requiring permissions on their credentials/inventories |
| Use | Credentials, inventories, projects | Reference the object in templates they create/edit (cannot see secret values) |
| Read | Any object | View configuration and history |
| Update | Projects, inventories | Trigger project sync / inventory sync |
| Approve | Workflows | Approve/reject approval nodes |
Since AAP 2.5, authentication and RBAC are unified by the platform gateway (role definitions span the controller, EDA, and Hub); for the exact role names, refer to the AAP docs. AWX 24.x uses the classic per-object roles in the table above.
Audit data sources
| Data | Location | Question it answers |
|---|---|---|
| Job records | /api/v2/jobs/<id>/: launched_by, launch_type (manual/scheduled/workflow/…), extra_vars, limit, scm_revision, EE, credential list, full events | Who, when, which version, and what was done to which hosts |
| Activity stream | /api/v2/activity_stream/ | Who changed templates/credentials/permissions (object-level change history) |
| External logs | Settings → Logging: send job events and the activity stream to Splunk / Elastic / Loki / Azure Monitor, etc. | Long-term retention, cross-system correlation |
| GitHub | Deployment history, environment approval records, organization audit logs | Code and approval chain |
| Cloud | Entra ID service principal sign-in logs, Key Vault diagnostic logs, CloudTrail | Who read the secrets, who signed in via OIDC |
When: the principle of least privilege
- Regular users get only Execute; template maintainers get template Admin + credential Use Use; only the platform team gets credential Admin.
- Create a dedicated service account and a separate token for each automation caller (CI, EDA, ITSM), granting only the Execute permission on the templates they need.
- Keep prod credentials separate from staging credentials, and put prod templates behind an approval workflow.
- Controller objects are managed by Configuration as Code in Git; UI changes are treated as drift.
Comparison with similar technologies
| Controller credentials | Ansible Vault file | GitHub Secrets | |
|---|---|---|---|
| Storage | Database encryption / external lookup | Encrypted file in Git | GitHub encrypted storage |
| Can users see the plaintext? | No (can only use) | Anyone with the Vault password can | No (only workflows can use them) |
| Fine-grained authorization | Object-level RBAC | None | Repository / environment level |
| Best for | Operations platforms | A few variables distributed with the code | CI/CD |
no_log. ③ “Auditor is safe, so it can be handed out freely” — an Auditor can see all job output and extra vars, which may contain sensitive business data.Architecture diagram: data flow for external secret lookup
RBAC relationship diagram: can use but not view, can run but not modify
RBAC permission evaluator
Choose a user and an operation, click “Evaluate”, and simulate the controller's authorization check (read the user's teams → aggregate roles on the object → role implication → allow/deny); the terminal shows the corresponding API request and response code.
Core Commands and Parameters
| Command / module | Purpose | Key parameters |
|---|---|---|
awx.awx.credential_type | Custom credential type | kind: cloud,inputs,injectors |
awx.awx.credential_input_source | Point a credential field to an external lookup credential | input_field_name,target_credential,source_credential,metadata |
awx.awx.team / awx.awx.user | Teams and users | organization |
awx.awx.role | Grant roles | team/user,role: execute|use|admin|read|approval…,job_templates/credentials/workflows |
awx activity_stream list | View change history | --operation,--object1 |
awx jobs get ID | Job audit fields | -f json | jq '{launched_by:.summary_fields.created_by.username, launch_type, scm_revision, limit}' |
Custom credential type: Slack Bot Token
---
- name: Credential types, external lookup and RBAC
hosts: localhost
gather_facts: false
module_defaults:
group/awx.awx.controller:
controller_host: "{{ lookup('env', 'CONTROLLER_HOST') }}"
controller_username: "{{ lookup('env', 'CONTROLLER_USERNAME') }}"
controller_password: "{{ lookup('env', 'CONTROLLER_PASSWORD') }}"
tasks:
- name: Custom credential type for Slack
awx.awx.credential_type:
name: Slack Bot Token
kind: cloud
inputs:
fields:
- id: slack_token
type: string
label: Slack Bot Token
secret: true
- id: slack_channel
type: string
label: Default channel
required: [slack_token]
injectors:
env:
SLACK_TOKEN: !unsafe "{{ slack_token }}"
extra_vars:
slack_channel: !unsafe "{{ slack_channel }}"
- name: Azure Key Vault lookup credential
awx.awx.credential:
name: akv-lookup
organization: Lab
credential_type: Microsoft Azure Key Vault
inputs:
url: "https://{{ lookup('env', 'KV') }}.vault.azure.net/"
client: "{{ lookup('env', 'AKV_CLIENT_ID') }}"
secret: "{{ lookup('env', 'AKV_CLIENT_SECRET') }}"
tenant: "{{ lookup('env', 'AZURE_TENANT_ID') }}"
- name: Machine credential whose private key comes from Key Vault
awx.awx.credential:
name: deploy-ssh
organization: Lab
credential_type: Machine
inputs: { username: azureuser }
- name: Link ssh_key_data → Key Vault secret
awx.awx.credential_input_source:
input_field_name: ssh_key_data
target_credential: deploy-ssh
source_credential: akv-lookup
metadata:
secret_field: deploy-ssh-key
secret_version: ""
- name: Teams
awx.awx.team: { name: "{{ item }}", organization: Lab }
loop: [app, ops]
- name: app team may run staging deploys
awx.awx.role:
team: app
role: execute
job_templates: [deploy-myapp]
- name: ops team may use the deploy credential in templates they build
awx.awx.role:
team: ops
role: use
credentials: [deploy-ssh]
- name: eda-bot may only run the remediation template
awx.awx.role:
user: eda-bot
role: execute
job_templates: [remediate-myapp]
!unsafe Keep Ansible from rendering it when running the configure playbook {{ slack_token }}— this template should be passed to the controller unchanged, so the controller renders it at job launch. The Azure Key Vault lookup credential's input field names (url/client/secret/tenant/cloud_name) and metadata field names (secret_field, secret_version) follow the credential type definition in your AWX/AAP version; you can check them with awx credential_types get "Microsoft Azure Key Vault" -f json | jq .inputs to view them. A lookup credential itself needs an identity that can read Key Vault — here, a service principal secret (when the controller is outside the cluster); when AAP runs on Azure, consider a managed identity (see the docs).
Audit queries
awx jobs list --all -f json | jq -r '.results[] | [.id, .name, .launch_type, .summary_fields.created_by.username // "system", .scm_revision[0:7], .status] | @tsv' | tail -5 awx activity_stream list -f json | jq -r '.results[] | [.timestamp, .summary_fields.actor.username // "system", .operation, .object1, (.changes|tostring)[0:60]] | @tsv' | tail -5
21 deploy-myapp manual admin 3f9c2ab successful
22 deploy-myapp manual alice 3f9c2ab successful
23 remediate-myapp manual eda-bot 3f9c2ab successful
2026-11-15T09:40:12Z admin update credential {"inputs": {"username": "azureuser" …
2026-11-15T09:41:03Z admin associate team {"object1": "team", "object2": "role" …
Note: Jobs launched by EDA via the API have launch_type manual and creator eda-bot — so a separate account for each caller is very important, otherwise the audit only shows “admin”. The ansible_eda field in the extra vars further indicates which rule triggered the job.
Lab 6: external secret + team permissions + auditing verification (about 8 minutes)
AKV_SP=$(az ad sp create-for-rbac -n awx-akv-reader --role "Key Vault Secrets User" \ --scopes $(az keyvault show -n $KV --query id -o tsv) -o json) export AKV_CLIENT_ID=$(echo $AKV_SP | jq -r .appId) AKV_CLIENT_SECRET=$(echo $AKV_SP | jq -r .password) export AZURE_TENANT_ID=$(az account show --query tenantId -o tsv)
Risk: This is a long-lived client secret — ironically, we just eliminated this kind of secret in Module 3. Limit its scope to reading a single Key Vault, set a short expiry (--years or az ad app credential reset --end-date), and delete it in Module 8. In production, deploy AAP on Azure and use a managed identity or workload identity.
ansible-playbook controller/credentials.yml awx users create --username alice --password 'Lab-Alice-2026!' --email alice@lab.local awx teams associate app --user alice 2>/dev/null || echo "Add alice to team app in the UI"
A="-u alice:Lab-Alice-2026!"
curl -s $A localhost:32000/api/v2/job_templates/?name=deploy-myapp | jq '.count' # 1: the template is visible
curl -s $A localhost:32000/api/v2/credentials/?name=deploy-ssh | jq '.count' # 0: the credential is not visible
JT=$(curl -s $A localhost:32000/api/v2/job_templates/?name=deploy-myapp | jq '.results[0].id')
curl -s $A -X POST localhost:32000/api/v2/job_templates/$JT/launch/ -H 'Content-Type: application/json' \
-d '{"extra_vars":{"myapp_version":"1.4.0"}}' | jq '{job,status}'
curl -s $A -X PATCH localhost:32000/api/v2/job_templates/$JT/ -H 'Content-Type: application/json' \
-d '{"playbook":"playbooks/site.yml"}' -o /dev/null -w "%{http_code}\n" # 403
1
0
{
"job": 31,
"status": "pending"
}
403
Job #31 can successfully connect to the host, proving the private key was fetched from Key Vault at launch time. In Key Vault → Diagnostic settings / logs, you can see SecretGet records (diagnostic logging must be enabled beforehand).
az ad sp delete --id $AKV_CLIENT_ID.Case 1: short-lived SSH certificates issued by HashiCorp Vault
Problem: Thousands of hosts shared one deployment private key, and a former employee had once obtained it. Approach: Use the “HashiCorp Vault Signed SSH” lookup: at each job launch, the Vault SSH CA issues a certificate valid for a few minutes, and hosts trust only the CA public key (TrustedUserCAKeys). Limitation: Requires first using Ansible to deploy the CA public key and principals configuration to all hosts — a large one-time effort.
Case 2: secret leak caused by write access to the project repository
Problem: A developer had only Execute permission on a template, but could push to the branch the project uses, so in a playbook he debug: var=hostvars printed out the database password. Approach: The project tracks only the protected main; playbook changes require review; tasks that handle secrets must set no_log: true; ansible-lint custom rules forbid debug: var=hostvars. Limitation: Beyond technical controls, a code-review culture is still required.
Case 3: compliance audit evidence
Problem: The auditor required proof that all prod changes in Q3 went through approval. Approach: Send controller logs to the SIEM; query the approval node records of the prod workflow (approver, time) + the job's scm_revision → corresponding GitHub PR and reviewer. Limitation: The controller deletes old job data by default according to a cleanup schedule (system job “Cleanup Job Details”), so data within the audit period must be exported and retained externally.
Common Errors and Fixes
Unable to retrieve credential from Azure Key Vault: (Forbidden) Caller is not authorized to perform action on resource
Cause: The service principal used by the lookup credential lacks “Key Vault Secrets User” on a Key Vault in RBAC mode, or the Key Vault firewall blocks the controller's egress IP.
az role assignment list --assignee $AKV_CLIENT_ID --all -o table az keyvault show -n $KV --query "properties.networkAcls"
You do not have permission to perform this action. (403 when launching the template)
Cause: The user has no Execute permission on the template; or the launch supplied fields the template does not allow to be prompted on launch (such as limit, inventory, credentials).
Fix: Grant Execute; or enable the corresponding ask_*_on_launch in the template.
Job Template 'deploy-myapp' is missing or undefined: credential (editors cannot see the credential)
Cause: When saving the template, the template Admin referenced a credential they do not have Use permission on.
Fix: Grant that user/team the Use role on the credential.
Plaintext password appears in job output
Cause: The password does not come from a credential field but from extra vars / group_vars, and the task was not marked no_log, or used a verbosity level -v or higher.
Fix: Move the secret into a credential (custom type), and mark the related task no_log: true; rotate the leaked secret and delete that job record.
1. Use the awx.awx module to grant team ops approval permission on the workflow deploy-myapp-prod.
- awx.awx.role:
team: ops
role: approval
workflows: [deploy-myapp-prod]2. List the ID, name, launcher, and Git commit of the last 5 jobs.
awx jobs list --all -f json | jq -r '.results[] | [.id,.name,.summary_fields.created_by.username,.scm_revision] | @tsv' | tail -5
The security team requires: “no one (including platform administrators) should store prod SSH private keys in the controller database, and every use must be traceable to a specific job.” Provide a design.
For the prod Machine credential's ssh_key_data field, use an external lookup (Key Vault/Vault), or better: HashiCorp Vault Signed SSH, issuing a short-lived certificate per job; the lookup credential's identity uses a managed identity/workload identity (the controller is on Azure) to avoid long-lived keys; enable Key Vault/Vault audit logs, which record the caller identity and time, correlated with the controller job start time and ID (controller logs forwarded to the SIEM); prod templates go through an approval workflow; credential Admin is limited to the platform team, and credential changes appear in the activity stream and trigger alerts.
Verified instructional videos
No verified dedicated video on “AWX/AAP credentials and RBAC” was found. Jeff Geerling's “Ansible 101 - Episode 10 - Ansible Tower and AWX” (cited in Module 4) demonstrates basic credential and permission operations and can serve as a reference.
Official documentation
- AWX: Credentials · Custom Credential Types · Secret Management System (external secrets)
- AWX: Role-Based Access Controls
- AAP 2.6 documentation (access management, external secrets, EDA credentials)
The URL structure of the AWX documentation site may change with the refactoring; if a link breaks, go to the AWX docs from the docs.ansible.com home page.
Video storyboard script (about 80 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: a safe (Key Vault), with the controller holding only a “pickup slip”.
Narration: the best credential is one the controller never stores. External secret lookup keeps the private key only in Key Vault and fetches it only when a job starts.
Visual: alice clicks “Launch” successfully; clicking “View private key” is blocked by a lock; clicking “Edit template” is refused.
Narration: Execute permission lets people run jobs, but they can neither see nor change the credentials and templates.
Visual: a Git branch icon connects to the project, labeled “write access equals credential access”.
Narration: note that whoever can modify the playbooks in the project can read the credentials. The project branch must be protected.
Visual: three log lines (job, activity stream, Key Vault log) merge into a SIEM.
Narration: job records, the activity stream, and secret access logs are gathered together, so every change can be explained during an audit.
Module 7 · Scheduling, Notifications, and Self-Service
- Use iCalendar RRULE to create schedules for job templates / workflows / project syncs / inventory syncs, correctly handling time zones and daylight saving time; know that schedules can override launch-time parameters such as extra vars and limit.
- Create notification templates (Slack, Webhook, Email, PagerDuty, etc.), attach them to a template's start / success / failure / approval events, and customize the message content.
- Use Survey + workflow + RBAC + API to build a self-service catalog (for example “restart myapp”, “scale worker count”, “request a certificate”), and know how to call it from ITSM/ChatOps.
What: Schedule
The controller's schedules use the RFC 5545 RRULE string, for example:
DTSTART;TZID=America/Toronto:20261116T020000 RRULE:FREQ=DAILY;INTERVAL=1 DTSTART;TZID=America/Toronto:20261116T060000 RRULE:FREQ=WEEKLY;BYDAY=MO,WED,FRI DTSTART:20261116T000000Z RRULE:FREQ=HOURLY;INTERVAL=4;COUNT=12
- Schedules can be attached to job templates, workflows, projects (scheduled sync), inventory sources (scheduled sync of cloud hosts), and system jobs (cleanup).
- Schedules can override fields that are prompted on launch: extra vars, limit, job_type (run/check), inventory, etc. — the same template can have a “nightly check inspection” schedule and a “Sunday run remediation” schedule.
- Time zone: use
TZID=to run at local time (automatically adjusted at DST transitions); useZto indicate UTC.America/TorontoMatches the course region canadacentral.
What: Notification
A notification template defines “where to send, how to authenticate, and what the message looks like”; it is then attached to job templates / workflows / projects / organizations, with the trigger timing chosen: Started / Success / Failure / Approval. Common types: Email, Slack, Webhook, PagerDuty, Mattermost, Rocket.Chat, Grafana (annotations), IRC, Twilio, etc. (refer to the type list in your version). Microsoft Teams can be called through the Webhook type using Teams' incoming webhook / workflow URL.
Messages can be customized, using Jinja to access job fields: {{ job.id }},{{ job.name }},{{ job.status }},{{ job.created_by }},{{ job.limit }},{{ job_friendly_name }},{{ url }},{{ job_metadata }} , etc. (see the notification docs for the list of available variables).
What: Self-service
| Building block | Purpose |
|---|---|
| Survey | Forms (text, integer, float, multiple choice, single choice, password), with defaults, min/max, and required flags; the answers become extra vars |
| Workflow + approval node | Dangerous operations need approval from a designated team, with a timeout |
| RBAC Execute | Grant only the “Launch” permission to the requester |
| API / integrations | ServiceNow, Jira, ChatOps bots, and internal portals call via the /launch/ API; AAP also offers a self-service portal option for end users (refer to the official docs) |
Why
- Scheduling Replaces cron jobs scattered across servers: centrally visible, with logs, notifications, and RBAC control.
- Notifications Make automation “speak up”: know immediately when something fails; after EDA auto-remediates, let on-call know “already handled for you”.
- Self-service Reduces ticket round-trips: developers no longer wait for operations to “restart staging for me”, and operations spends its time improving automation.
How: the job path triggered by a schedule
The controller's scheduler periodically computes each schedule's next_run; when due, it creates a job as launch_type: scheduled (the creator is the schedule itself); from there it is exactly the same as a manual launch (the Module 4 path), and when it finishes, it sends messages per the attached notification templates. Runs missed during controller downtime are not made up.
When: typical schedules
| Task | Frequency | job_type | Notification |
|---|---|---|---|
| Configuration drift inspection | Nightly at 02:00 | check (diff on) | On failure or when changes are found |
| Security patching | The Saturday after the second Tuesday of each month (BYDAY=SA;BYSETPOS=… requires careful verification) | run, serial batches | Start + end |
| Cloud inventory sync | Every 30 minutes | — | On failure |
| Certificate expiry check | Daily | run (read-only) | When an upcoming expiry is found, the playbook sends the notification itself |
no_log.Architecture diagram: schedule → job → notification
Flowchart: self-service “restart myapp”
RRULE schedule previewer
Adjust the frequency, time, and weekdays to generate a controller-compatible RRULE string in real time, and preview the next 6 runs (displayed in local time of the chosen time zone). The terminal shows the equivalent awx.awx.schedule task.
Core Commands and Parameters
| Module / command | Purpose | Key parameters |
|---|---|---|
awx.awx.schedule | Create a schedule | rrule,unified_job_template,extra_data,job_type,limit,enabled |
awx schedules preview / API /api/v2/schedules/preview/ | Preview future run times for an RRULE | POST {"rrule": "…"} |
awx.awx.notification_template | Notification template | notification_type: slack|webhook|email|pagerduty…,notification_configuration,messages |
awx.awx.job_template of notification_templates_error/success/started | Attach notifications | For workflows notification_templates_approvals |
awx.awx.workflow_job_template | Workflow (with Survey, approval node) | workflow_nodes,approval_node |
awx job_templates launch … --extra_vars | API / ChatOps calls | Corresponds to the Survey fields |
---
- name: Schedules, notifications and self-service
hosts: localhost
gather_facts: false
module_defaults:
group/awx.awx.controller:
controller_host: "{{ lookup('env', 'CONTROLLER_HOST') }}"
controller_username: "{{ lookup('env', 'CONTROLLER_USERNAME') }}"
controller_password: "{{ lookup('env', 'CONTROLLER_PASSWORD') }}"
tasks:
- name: Webhook notification (to EDA hello-webhook or any HTTP receiver)
awx.awx.notification_template:
name: ops-webhook
organization: Lab
notification_type: webhook
notification_configuration:
url: "{{ lookup('env', 'NOTIFY_URL') }}"
http_method: POST
headers: { Content-Type: application/json }
messages:
error:
body: !unsafe '{"action":"notify","job":"{{ job.id }}","name":"{{ job.name }}","status":"{{ job.status }}","by":"{{ job.created_by }}","url":"{{ url }}"}'
success:
body: !unsafe '{"action":"notify","job":"{{ job.id }}","name":"{{ job.name }}","status":"{{ job.status }}"}'
- name: Slack notification (optional, needs a bot token)
awx.awx.notification_template:
name: ops-slack
organization: Lab
notification_type: slack
notification_configuration:
token: "{{ lookup('env', 'SLACK_TOKEN') }}"
channels: ["#ops-alerts"]
when: lookup('env', 'SLACK_TOKEN') | length > 0
- name: Drift-check template (check mode)
awx.awx.job_template:
name: drift-check-myapp
organization: Lab
project: ansible-lab
playbook: playbooks/deploy-myapp.yml
inventory: staging
credentials: [deploy-ssh]
job_type: check
diff_mode: true
notification_templates_error: [ops-webhook]
notification_templates_success: [ops-webhook]
- name: Nightly schedule 02:00 Toronto time
awx.awx.schedule:
name: nightly-drift
unified_job_template: drift-check-myapp
rrule: "DTSTART;TZID=America/Toronto:20261116T020000 RRULE:FREQ=DAILY;INTERVAL=1"
enabled: true
- name: Notify on remediation as well (EDA-triggered runs)
awx.awx.job_template:
name: remediate-myapp
notification_templates_success: [ops-webhook]
notification_templates_error: [ops-webhook]
# preview the schedule
curl -s -u admin:$CONTROLLER_PASSWORD -X POST $CONTROLLER_HOST/api/v2/schedules/preview/ \
-H 'Content-Type: application/json' \
-d '{"rrule":"DTSTART;TZID=America/Toronto:20261116T020000 RRULE:FREQ=DAILY;INTERVAL=1"}' | jq '.local[0:3]'
[ "2026-11-16T02:00:00-05:00", "2026-11-17T02:00:00-05:00", "2026-11-18T02:00:00-05:00" ]
How to verify:awx schedules list -f human the next_run in the output. Common errors: In an RRULE, DTSTART and RRULE must be separated by a space (not a newline); BYDAY uses two-letter abbreviations. Production use: Bring schedules and notifications into Configuration as Code as well. Notification template parameter names (such as the webhook's http_method, Slack's channels) follow ansible-doc awx.awx.notification_template .
Lab 7: nightly drift inspection + webhook notification (about 6 minutes)
ansible-rulebook -r rulebooks/hello-webhook.yml -i inventories/dev/hosts.yml --print-events &
GW=$(docker network inspect kind -f '{{(index .IPAM.Config 0).Gateway}}'); echo $GW
export NOTIFY_URL=http://$GW:5000/awx
172.18.0.1
If the gateway address returns IPv6 or is empty, use docker network inspect kind | jq '.[0].IPAM.Config' to check; the host firewall must allow port 5000 from the kind network.
ansible-playbook controller/schedules.yml awx schedules list -f human awx job_templates launch drift-check-myapp --monitor | tail -3
ssh azureuser@20.151.0.10 "sudo sed -i 's/^MYAPP_WORKERS=.*/MYAPP_WORKERS=9/' /etc/myapp/myapp.env" awx job_templates launch drift-check-myapp --monitor | grep -E "^[-+]MYAPP_WORKERS|changed="
-MYAPP_WORKERS=9 +MYAPP_WORKERS=2 vm-ansible-01 : ok=12 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
Back in the ansible-rulebook terminal, you can see the webhook events sent from AWX (meta.endpoint: awx,payload.status: successful). Note: when drift is found, the job status is still successful — this is misconception ②.
ansible_check_mode and statistics:
---
- name: Drift check wrapper
ansible.builtin.import_playbook: deploy-myapp.yml
- name: Fail if anything would change
hosts: web
gather_facts: false
tasks:
- name: Assert no drift (relies on myapp role registering myapp_changed_count)
ansible.builtin.assert:
that: (myapp_changed_count | default(0) | int) == 0
fail_msg: "drift detected on {{ inventory_hostname }}: {{ myapp_changed_count }} change(s)"
when: ansible_check_mode
Ansible has no built-in variable for “how many changed in this play”; a common approach is to register on key tasks in the role register and accumulate, or use a callback plugin / the controller API (the job's host_status_counts) to judge at the next workflow node. The approach given here requires cooperation from the role; adjust it to your role.
awx job_templates launch deploy-myapp --monitor; stop ansible-rulebook (kill %1). Keep the schedules until Module 8 for unified deletion.Case 1: monthly patching window
Problem: 300 RHEL/Ubuntu hosts need patching in a fixed monthly window; previously this was scheduled manually. Approach: Workflow: pre-checks (disk, snapshot) → approval node (change manager) → patch job (serial: 10%,max_fail_percentage: 5) → reboot → health check → report; the schedule uses TZID local time; Started/Failure/Approval notifications go to Teams and PagerDuty. Limitation: RRULEs for rules like “the Saturday after the second Tuesday” are complex; be sure to validate the dates for the whole year with the preview API.
Case 2: developers self-service “reset the staging database”
Problem: 20+ tickets per week requested test-data resets. Approach: Workflow Survey (multi-select of database names; a confirmation text box that must contain “RESET”), with Execute permission for the app team; automatic snapshot before execution; the requester is notified on completion. Ticket volume dropped to zero. Limitation: Open only to staging; prod is never put into the self-service catalog.
Case 3: ChatOps
Problem: On-call wanted to restart a service with one sentence in Slack. Approach: Slack slash command → small intermediary service (validates the Slack signature and user group) → controller API launches remediate-myapp (service account with Execute permission) → notification template posts the result back; or use an EDA webhook source to receive the command. Limitation: The caller's identity must be verified and the mapping recorded; otherwise the audit shows only the service account.
Common Errors and Fixes
Schedule shows empty next_run / schedule never runs
Cause: The RRULE has ended (COUNT/UNTIL), the schedule is disabled, the DTSTART format is wrong, or the target template needs launch-time values (such as required Survey fields) that the schedule did not provide.
awx schedules get nightly-drift -f json | jq '{enabled, next_run, rrule, extra_data}'
Fix: Validate the RRULE with the preview API; supply required Survey fields in the schedule's extra_data.
Schedule runs an hour earlier/later than expected
Cause: UTC was used (Z) while the business works in local time; or a DST switch happened.
Fix: Change it to DTSTART;TZID=America/Toronto:….
Notification not sent: Notification failed: HTTPConnectionPool(host='…', port=5000): Max retries exceeded
Cause: The notification is sent by the controller's task Pod (not the job Pod), which cannot reach the target address (in kind, reaching the host requires the gateway IP; corporate networks require a proxy).
awx notifications list -f json | jq -r '.results[-1] | {status, error}'
kubectl -n awx exec deploy/awx-demo-task -c awx-demo-task -- curl -s -m 5 -o /dev/null -w "%{http_code}\n" $NOTIFY_URLSlack: channel_not_found / not_in_channel
Cause: The Slack bot was not invited to the channel, or the channel name/ID is wrong.
Fix: Invite the bot in the channel /invite @your-bot; or use the channel ID.
1. Write the RRULE for “runs every Monday, Wednesday, and Friday at 06:30 (Toronto time)”.
DTSTART;TZID=America/Toronto:20261116T063000 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR
2. Use the API to preview the next run times of the RRULE above.
curl -s -u admin:$CONTROLLER_PASSWORD -X POST $CONTROLLER_HOST/api/v2/schedules/preview/ -H 'Content-Type: application/json' \
-d '{"rrule":"DTSTART;TZID=America/Toronto:20261116T063000 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR"}' | jq .localThe team wants to make “scale the number of myapp workers” a self-service action, but worries someone will set prod to 64 workers and overload the hosts. How would you design it?
The Survey uses an integer type with min=1, max=8; environment uses a multiple choice, where the prod option triggers the approval node in the workflow (ops approval); the playbook asserts the range again (to guard against the API bypassing the Survey — API calls are also validated by the Survey, but validation inside the playbook is defense in depth); after the change, a smoke test runs automatically, and on failure it rolls back to the original value; the requester and the ops channel are notified; all objects are managed with Configuration as Code.
Verified instructional videos
No verified dedicated video on “controller scheduling and notifications” was found.
Official documentation
- AWX: Schedules · Notifications · Surveys · Workflow Job Templates
- RFC 5545: Recurrence Rule
Video storyboard script (about 70 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: the separate crontab files on many servers are gathered into a single calendar in the controller.
Narration: scattered cron jobs are hard to manage. The controller's schedules are centrally visible, logged, and permission-controlled.
Visual: at 2 a.m., the inspection job runs, finds a file difference, and a Slack message pops up.
Narration: a nightly inspection runs in check mode and notifies when drift is found. Remember to make drift a failure, otherwise a successful job will not raise an alarm.
Visual: a developer selects an environment and hosts in a form; an approval icon appears next to the prod option; a notification arrives when the job finishes.
Narration: forms, workflows, permissions, and notifications together make up self-service. Common requests no longer queue up waiting for operations.
Module 8 · Recap, Self-Check, and Cleanup for Hours 1–5
- Using one knowledge map, restate the first five lessons: fundamentals (inventory/modules/playbooks) → production readiness (roles/Vault/idempotency/testing) → Azure → AWS (SSM) → CI/CD and platformization.
- Use the interactive troubleshooting tree to locate the four common failure types: CI, CD/OIDC, AWX, and EDA.
- Following a checklist, clean up lab resources in kind, Azure, AWS, and GitHub to avoid ongoing charges and leftover permissions.
Knowledge map for the first five hours
| Lesson | Topic | What you should now be able to do | How this lesson uses it |
|---|---|---|---|
| 1 | Core fundamentals | Write inventories, ad-hoc commands, playbooks, variables and facts, handlers | The foundation of all playbooks |
| 2 | Production readiness | Roles, collections, Vault, idempotency, check/diff, error handling | The subject of Molecule tests; check-mode dry runs |
| 3 | Azure | Create resources with azure.azcollection, dynamic inventory, deploy myapp on Azure VMs | CD target; OIDC federated credentials; Key Vault |
| 4 | AWS | amazon.aws, EC2 dynamic inventory, SSM connection plugin (no SSH) | CD's SSM variant; IAM OIDC role |
| 5 | CI/CD and platformization | CI testing, OIDC CD, AWX object modeling, EDA auto-remediation, credentials/RBAC/auditing, scheduling/notifications/self-service | — |
Remember “platformization” in one picture
- Inputs come only from Git (playbooks, inventory, rulebooks, controller configuration, EE definitions).
- Verification In CI: yamllint → ansible-lint → syntax → Molecule (idempotency).
- Execution entry points There are four: the CD pipeline (code changes), the controller (people / schedules / API), EDA (events), and ansible-pull (nodes pulling for themselves) — they all execute the same content.
- Identity: CI uses OIDC; the controller uses credentials + external secrets; people use RBAC; automation callers use dedicated accounts.
- Feedback: notifications, audit logs, and drift inspections close the loop.
Maturity self-assessment (back to Module 1)
| Question | Yes → you are at least at |
|---|---|
| Are all playbooks in Git and changed via PRs? | L2 |
| Does every PR automatically run lint + Molecule, with dependency versions pinned? | L3 (first half) |
| Are deployments executed by the pipeline/controller, with no individual holding prod credentials? | L3 |
| Can non-developers safely perform common operations through self-service, with scheduling and auditing? | L4 |
| Can known faults be auto-remediated by events, with throttling and escalation? | L5 |
Five lessons in sequence: myapp's journey
Locating failures: first see which layer
Knowledge map self-test: drag capabilities to the correct layer
Click a capability card, then click the layer it belongs to (CI / CD / controller / EDA). Pass by placing all of them correctly. The terminal explains each answer.
Cleanup command checklist
| Resource | Command | Notes |
|---|---|---|
| kind AWX cluster | kind delete cluster --name awx | Delete AWX and PostgreSQL data (export the job records you need first) |
| ansible-rulebook processes | pkill -f ansible-rulebook | — |
| Molecule containers | docker ps -a --filter name=myapp- -q | xargs -r docker rm -f | — |
| Entra app registration (including federated credentials) | az ad app delete --id $APP_ID | Also deletes the service principal and the role assignments tied to it |
| Key Vault read SP | az ad sp delete --id $AKV_CLIENT_ID | Long-lived secret created in Module 6 |
| Key Vault | az keyvault delete -n $KV && az keyvault purge -n $KV | Name remains occupied within the soft-delete retention period |
| Azure resource group | az group delete -n rg-ansible-lab --yes --no-wait | If Hour 6 keeps using the VM, you can first only stop the VM: az vm deallocate |
| AWS IAM role / OIDC provider | aws iam delete-role,aws iam delete-open-id-connect-provider | detach/delete inline policies first |
| GitHub | gh api -X DELETE repos/{owner}/ansible-lab/environments/prod; revoke the PAT | the repository can be kept for Hour 6 |
#!/usr/bin/env bash
# Hour 5 cleanup script: comment out the parts to keep until Hour 6
set -uo pipefail
pkill -f ansible-rulebook || true
docker ps -a --filter name=myapp- -q | xargs -r docker rm -f
kind delete cluster --name awx || true
[ -n "${APP_ID:-}" ] && az ad app delete --id "$APP_ID"
[ -n "${AKV_CLIENT_ID:-}" ] && az ad sp delete --id "$AKV_CLIENT_ID"
[ -n "${KV:-}" ] && az keyvault delete -n "$KV" && az keyvault purge -n "$KV"
# comment out the next line if Hour 6 still uses the VM
az group delete -n rg-ansible-lab --yes --no-wait
if aws sts get-caller-identity >/dev/null 2>&1; then
for r in gh-ansible-lab-prod gh-ansible-lab-staging; do
for p in $(aws iam list-role-policies --role-name $r --query 'PolicyNames[]' --output text 2>/dev/null); do
aws iam delete-role-policy --role-name $r --policy-name $p; done
for p in $(aws iam list-attached-role-policies --role-name $r --query 'AttachedPolicies[].PolicyArn' --output text 2>/dev/null); do
aws iam detach-role-policy --role-name $r --policy-arn $p; done
aws iam delete-role --role-name $r 2>/dev/null
done
fi
echo "done. Remaining: revoke the GitHub PAT manually under Settings → Developer settings"
# verify after cleanup kind get clusters az ad app list --display-name gh-ansible-lab-cd --query "[].appId" -o tsv az group exists -n rg-ansible-lab aws iam list-roles --query "Roles[?starts_with(RoleName,'gh-ansible-lab')].RoleName"
No kind clusters found. false []
Lab 8: timed self-test + cleanup (about 6 minutes)
permissions.id-token,environment,concurrency.cancel-in-progress: false, and SHA-pinned Actions.awx jobs list --all -f json > awx-jobs-lesson5.json awx export --job_templates --projects --inventory --credential_types > awx-export.json 2>/dev/null || true
awx export The parameters vary with the awxkit version; you already have Configuration as Code in Git, so this step can usually be skipped.
cleanup.sh (first decide which resources to keep for Hour 6), then run the verification commands. Cost reminder: After an Azure VM is stopped (deallocated), compute charges stop but disk charges continue; deleting the resource group is the only way to stop billing completely.Case 1: a 12-month roadmap for a mid-sized SaaS company
Starting point: L1: a dozen-odd people each running playbooks from their laptops. Q1: Unified Git repository, PR review, ansible-lint (basic profile). Q2: Molecule covers core roles, CD uses OIDC, and personal prod credentials were recovered. Q3: Introduced AAP, Configuration as Code for the controller, and a self-service catalog of 15 items went live. Q4: EDA handles 5 categories of known alerts, MTTR dropped from 35 minutes to 4 minutes; profile raised to production. Lesson: At each level, solve the “people” problems first (process, permissions), and only then bring in tools.
Case 2: a security incident caused by an incomplete cleanup
Problem: A service principal secret used for training (Key Vault read + subscription Contributor) was not deleted, and was found six months later in a public Gist. Approach: Immediately delete the SP, rotate all secrets in Key Vault, and review the Entra sign-in logs; from then on, tag all lab resources with a owner/expires tag, use Azure Policy and scheduled scripts to clean up expired resources; lab work prefers OIDC and short-lived credentials. Limitation: This can only reduce risk; human error still needs process as a backstop.
Interactive troubleshooting tree: common CI / CD / AWX / EDA failures
Start from the symptom and choose step by step to reach diagnostic commands and fix suggestions.
1. Use one command to confirm the AWX cluster in kind has been deleted and the Azure resource group no longer exists.
kind get clusters; az group exists -n rg-ansible-lab
2. View the logs of the failed step in the most recent failed GitHub Actions run.
gh run view $(gh run list --status failure -L 1 --json databaseId -q '.[0].databaseId') --log-failed
You take over a team that has AWX and a Git repository, but the AWX templates were all created manually in the UI, projects track each person's own branch, and credentials are a shared root private key. Give the first 5 steps of a 30-day improvement plan.
① Inventory: export the existing controller objects (awx export) into Git as the Configuration as Code baseline; ② the project tracks the protected main uniformly, and personal branches are used only for PRs; ③ credentials: create a separate non-root deployment user and key for each environment, store them in Key Vault/Vault and use external lookups, and retire the shared root private key; ④ RBAC: grant Execute/Use by team, revoke excess Admin roles, and create dedicated EDA/CI accounts; ⑤ CI: add ansible-lint + syntax-check as required checks on the repository, then gradually add Molecule; only then consider scheduled inspections and EDA. Also assess the risk of AWX's paused releases and plan the migration to AAP.
Verified review videos
Official documentation
Video storyboard script (about 60 seconds)
These materials cannot generate video/MP3 directly; the storyboard and narration script are provided for a video tool to produce.
Visual: five steps light up in turn: fundamentals, production readiness, Azure, AWS, platformization.
Narration: in five hours, we turned a playbook into a platform.
Visual: Git in the center, surrounded by four entry points: CI, CD, controller, EDA.
Narration: inputs come from Git, verification happens in CI, there are four execution entry points, identity uses OIDC and credentials, and feedback comes through notifications and auditing.
Visual: a broom sweeps across icons for kind, a resource group, and a service principal.
Narration: don't forget cleanup at the end, especially credentials and permission-type resources. In the next lesson, we use all of this to build a multi-tier architecture.
Command Cheat Sheet
CI: lint and tests
yamllint -s -f github . ansible-lint --profile production [--fix] ansible-playbook -i inventories/dev/hosts.yml playbooks/site.yml --syntax-check cd roles/myapp && molecule test molecule converge / idempotence / verify molecule test --destroy=never && molecule login -h HOST gh pr checks --watch; gh run view --log-failed
Pin Actions by SHA
git ls-remote https://github.com/OWNER/ACTION.git \
'refs/tags/vX.Y.Z^{}' 'refs/tags/vX.Y.Z' | tail -1
# uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
# uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0OIDC: Azure
OWNER_ID=$(gh api users/$OWNER -q .id); REPO_ID=$(gh api repos/$OWNER/$REPO -q .id)
# subject: repo:$OWNER@$OWNER_ID/$REPO@$REPO_ID:environment:prod
az ad app federated-credential create --id $APP_OID --parameters cred.json
az ad app federated-credential list --id $APP_OID --query "[].subject" -o tsv
# workflow: permissions: { id-token: write, contents: read }OIDC: AWS
aws iam create-open-id-connect-provider \ --url https://token.actions.githubusercontent.com --client-id-list sts.amazonaws.com # trust policy conditions: # token.actions.githubusercontent.com:aud = sts.amazonaws.com # token.actions.githubusercontent.com:sub = repo:o@id/r@id:environment:prod -e ansible_connection=amazon.aws.aws_ssm -e ansible_aws_ssm_bucket_name=BUCKET
AWX on kind
kind create cluster --config kind-awx.yaml # extraPortMappings 32000
kubectl apply -k . # awx-operator ?ref=2.19.1
kubectl apply -f awx-demo.yaml # service_type: nodeport
kubectl -n awx get secret awx-demo-admin-password -o jsonpath='{.data.password}' | base64 -d
kubectl -n awx logs -f deploy/awx-operator-controller-manager -c awx-manager
kubectl -n awx get pods | grep automation-jobawx CLI
export CONTROLLER_HOST=http://localhost:32000 CONTROLLER_USERNAME=admin CONTROLLER_PASSWORD=…
awx ping -f human
awx job_templates launch deploy-myapp --limit HOST --extra_vars '{"k":"v"}' --monitor
awx jobs stdout ID
awx schedules list -f human
awx activity_stream list -f humanEDA
ansible-galaxy collection install ansible.eda
ansible-rulebook -r rulebooks/X.yml -i INV --print-events -v \
--controller-url $EDA_CONTROLLER_URL --controller-token $EDA_CONTROLLER_TOKEN
curl -X POST localhost:5000/endpoint -H 'Content-Type: application/json' -d '{"k":"v"}'
curl -X POST localhost:5050/ -d @alertmanager-payload.json -H 'Content-Type: application/json'Rulebook skeleton
- name: rs
hosts: all
sources:
- ansible.eda.alertmanager: { host: 0.0.0.0, port: 5050 }
filters:
- eda.builtin.event_splitter: { splitter_key: payload.alerts } # for webhook sources
rules:
- name: r
condition: event.alert.labels.alertname == "MyappDown"
throttle: { once_within: 5 minutes, group_by_attributes: [event.alert.labels.instance] }
action:
run_job_template: { name: remediate-myapp, organization: Lab,
job_args: { limit: "{{ event.meta.hosts[0] }}" } }Quick troubleshooting table
| Symptom | Most likely cause | First command |
|---|---|---|
couldn't resolve module/action | Collection not installed / not in the EE | ansible-galaxy collection list |
| Molecule idempotence failure | command/shell without changed_when | molecule converge && molecule idempotence |
AADSTS700213 | Federated credential subject mismatch (immutable format) | Compare the sub from the error message federated-credential list |
Not authorized to perform sts:AssumeRoleWithWebIdentity | Trust policy sub/aud mismatch | Decode the token claims in the workflow |
Unable to get ACTIONS_ID_TOKEN_REQUEST_URL | Missing id-token: write | Check the permissions block |
| AWX job pending | Insufficient capacity / dependent sync failed | kubectl -n awx get pods | grep automation-job |
| EDA receives events but does not fire | Wrong condition path / curly braces used / throttle | ansible-rulebook … --print-events -vv |
| run_job_template 404 | Token user lacks Execute permission | curl -H "Authorization: Bearer …" …/api/v2/job_templates/?name=… |
| Notifications not sent | Task Pod cannot reach the network target | awx notifications list |
Recommended configuration snippet
version: 2
updates:
- package-ecosystem: github-actions # automatically updates SHA-pinned Actions and version comments
directory: /
schedule: { interval: weekly }
- package-ecosystem: pip
directory: /
schedule: { interval: weekly }
Capstone Lab + Final Quiz
cd ~/ansible-lab
gh repo view --json name,defaultBranchRef -q '.name + " " + .defaultBranchRef.name'
gh api repos/{owner}/{repo}/environments -q '.environments[].name'
gh variable list -e staging
kubectl --context kind-awx -n awx get pods | grep -E "web|task"
awx job_templates list -f human | grep -E "deploy-myapp|remediate-myapp"
For any item that is missing, go back to the “Lab” page of the corresponding module and complete it.
git switch -c feat/workers-3 sed -i 's/^myapp_workers: .*/myapp_workers: 3/' inventories/staging/group_vars/all.yml inventories/prod/group_vars/all.yml git commit -am "feat(myapp): 3 gunicorn workers in staging/prod" git push -u origin feat/workers-3 && gh pr create --fill gh pr checks --watch
lint pass 38s molecule (ubuntu2404, 2.21) pass 3m02s … All checks were successful
Deliberately test the guardrails: add a shell: echo x >> /tmp/f task on another branch, and confirm that ansible-lint (no-changed-when) and Molecule (idempotence) both turn the PR red and the ruleset blocks the merge.
gh pr merge --squash --delete-branch sleep 10; gh run watch $(gh run list --workflow cd -L 1 --json databaseId -q '.[0].databaseId')
On the run page, read the staging dry-run diff (you should see -MYAPP_WORKERS=2 / +MYAPP_WORKERS=3), then approve prod.
ssh azureuser@20.151.0.10 "grep WORKERS /etc/myapp/myapp.env; systemctl is-active myapp"
MYAPP_WORKERS=3 active
awx job_templates launch deploy-myapp --monitor | tail -2 awx jobs list --name deploy-myapp -f json | jq -r '.results[-1].scm_revision[0:7]' git rev-parse --short HEAD
When the two SHAs are identical, the controller is running the latest content in Git; after the CD deployment, running AWX should show changed=0.
ansible-rulebook -r rulebooks/hello-webhook.yml -i inventories/dev/hosts.yml --print-events > notify.log 2>&1 & ansible-rulebook -r rulebooks/myapp-remediate.yml -i inventories/staging/hosts.yml \ --controller-url "$EDA_CONTROLLER_URL" --controller-token "$EDA_CONTROLLER_TOKEN" -v > eda.log 2>&1 & sleep 15; tail -3 eda.log
ssh azureuser@20.151.0.10 'sudo systemctl kill -s SIGKILL myapp; sudo systemctl stop myapp' curl -s -X POST http://localhost:5050/ -H 'Content-Type: application/json' -d @alert.json # the Module 5 alert payload sleep 45 grep -E "run_job_template|launched" eda.log | tail -2 awx jobs list --name remediate-myapp -f human | tail -1 ssh azureuser@20.151.0.10 "systemctl is-active myapp; curl -s 127.0.0.1:8000/healthz" grep -c '"action": "notify"' notify.log 2>/dev/null || grep -c notify notify.log
… INFO - call_action run_job_template
… INFO - Job template remediate-myapp launched, job id 41
41 remediate-myapp successful 2026-11-15T10:32:18Z
active
{"status":"ok","redis":"ok"}
1
Send the same alert again, and confirm there is no new remediate-myapp job within 5 minutes (throttle).
# GitHub: which SHA, who approved prod
gh api repos/{owner}/{repo}/deployments -q '.[0:2][] | {environment, sha: .sha[0:7], creator: .creator.login}'
# AWX: who launched the remediation, which rule triggered it
awx jobs get 41 -f json | jq '{created_by: .summary_fields.created_by.username, scm: .scm_revision[0:7], rule: .extra_vars}'
# Entra ID: OIDC federated sign-in (portal → Enterprise applications → gh-ansible-lab-cd → Sign-in logs → Service principal sign-ins)
{"creator":"you","environment":"prod","sha":"9d41e2c"}
{"creator":"you","environment":"staging","sha":"9d41e2c"}
{
"created_by": "eda-bot",
"scm": "9d41e2c",
"rule": "{\"alert_name\": \"MyappDown\", \"ansible_eda\": {\"ruleset\": \"myapp auto-remediation\", …}}"
}pkill -f ansible-rulebook; if you are not continuing to Hour 6, run the cleanup from Module 8's cleanup.sh (kind, app registration, Key Vault, resource group, IAM roles, PAT). Hour 6 will keep using the ansible-lab repository and CI/CD workflows.Open-ended self-test (answer first on your own, then expand the reference answer)
1. Why is “promoting the same commit SHA” safer than “branch per environment”?
What gets promoted to prod is exactly the same code verified in staging; the branch model requires merging or cherry-picking between branches, which easily misses things or introduces unverified differences. Environment differences are concentrated in the inventory and easy to see. Security controls come from environment approvals and credential isolation, not from branches.
2. What does Molecule's idempotence stage check? Why does it also matter for check-mode dry runs?
It runs converge again and requires that no task reports changed. Only with idempotent roles does a “changed” in check mode accurately represent a real difference or drift; non-idempotent tasks make dry runs and drift inspections always show changes, which makes them meaningless.
3. Describe how GitHub Actions logs in to Azure via OIDC, and the 2026 subject change.
The job has id-token: write → the runner requests a JWT whose audience is api://AzureADTokenExchange from GitHub → azure/login sends the JWT as a client assertion to Entra ID → Entra validates the signature, iss, aud, and the subject against the federated credential → returns a short-lived access token. From 2026-07-15, newly created, renamed, or transferred repositories use the immutable subject: repo:owner@owner_id/repo@repo_id:…, which prevents same-named repository impersonation; federated credentials and the AWS trust policy must be updated accordingly.
4. Which components does an AWX job go through from clicking “Launch” to execution on a managed node?
REST API (RBAC, Survey validation, creating the job) → task manager (dependencies: project sync / inventory sync, capacity) → dispatcher → receptor work unit → EE job Pod created in K8s → ansible-runner injects credentials and runs ansible-playbook → SSH/SSM to managed nodes → events flow back via receptor to the callback receiver → database + websocket UI → notifications / next workflow node.
5. What is the difference in expression syntax between a rulebook's condition and its action parameters? Give examples.
The condition uses the rulebook's own expression language, written directly as event.alert.labels.alertname == "MyappDown", without curly braces; action parameters are Jinja templates, and referencing an event there must be written as "{{ event.meta.hosts[0] }}".
6. What ways might a user who has only Execute permission on a job template gain access to the plaintext of the template's credential? How do you guard against this?
① modifying a playbook on the branch the project tracks (printing variables or environment variables) → the project tracks a protected branch and changes are reviewed; ② modifying the template (requires Admin) → do not grant it; ③ secrets debugged into job output → no_log; ④ prompting for extra vars at launch can inject malicious variables (for example, pointing the connection target at your own host to intercept SSH authentication) → enable it cautiously ask_variables_on_launch, and restrict it with a Survey.
Final quiz (12 questions, covering all modules)
Sources and Version Notes
| Topic | Verified conclusion | Sources (accessed 2026-11-15) |
|---|---|---|
| ansible-core / community package | core 2.21 (2026-05 GA, patch about 2.21.5, EOL 2027-11), 2.20, 2.19 (EOL 2026-11); the community package 14.x is based on core 2.21; control node Python 3.12–3.14 | Course specification facts verified;Release and maintenance |
| ansible-lint | latest v26.11.0 (2026-11-05); profiles min/basic/moderate/safety/shared/production | ansible-lint releases · Documentation |
| Molecule | latest v26.11.0 (2026-11-05); recommends ansible-native configuration; the official Docker example uses community.docker to create containers and write a temporary inventory in create.yml; the default test sequence includes idempotence | Molecule releases · Configuration · Docker example |
| ansible-rulebook | latest v1.3.2; installation requires Python ≥ 3.10, JDK ≥ 17; pip install ansible-rulebook ansible ansible-runner; CLI options --controller-url/--controller-token/--controller-username/--controller-password/--controller-ssl-verify (environment variables EDA_CONTROLLER_*) | releases · Installation · Usage |
| EDA filters | eda.builtin.event_splitter (splitter_key required; attributes_key_map, extras, raise_error optional), insert_hosts_to_meta, json_filter, dashes_to_underscores, normalize_keys | Event Filters |
| ansible.eda collection | latest v2.13.0; alertmanager source parameters (host, port default 5000, data_alerts_path default alerts, data_host_path default labels.instance, skip_original_data) and event format (alert + meta.hosts, with the port removed); the Kafka source adds Avro/Schema Registry, feedback queues, and multiple topics; 2.11 deprecated aws_sqs_queue, azure_service_bus, file, file_watch, journald, tick, url_check, and other sources | releases · alertmanager.py |
| AAP 2.6 | EDA supports external secret management (HashiCorp Vault, CyberArk, Azure Key Vault, AWS Secrets Manager); event_splitter filter; 2.6 is the last version supporting RPM installation (RHEL 9 only), containerized-only from 2.7 | Course specification facts verified;AAP 2.6 Release notes(WebFetch returned 403; cross-checked with search summaries) |
| AWX | latest 24.6.1 (2024-07-02); README: “Releases of this project are now paused during a large scale refactoring” | github.com/ansible/awx · releases |
| AWX Operator | latest 2.19.1; kind installation: extraPortMappings 32000, kustomize config/default?ref=…, AWX CR service_type: nodeport,nodeport_port: 32000, accessing http://localhost:32000/ | releases · kind-install.md |
| GitHub Action SHA | Queried on 2026-11-15 with git ls-remote actions/checkout v7.0.1 = 3d3c42e5…; actions/setup-python v7.1.0 = 6d4fd22b…; actions/cache v6.1.0 = 55cc8345…; azure/login v3.1.0 = a641126d… (commit after dereferencing the annotated tag); aws-actions/configure-aws-credentials v6.3.0 = e1253824… | Repository tags |
| azure/login | v3 is the supported major version (v2 maintained, v1 EOL); OIDC requires id-token: write, client-id/tenant-id/subscription-id; branch references are not supported | Azure/login |
| configure-aws-credentials | v6.3.0; trust policy conditions aud=sts.amazonaws.com, sub; repositories created after 2026-07-15 use the immutable sub, and a legacy-format trust policy will fail with AccessDenied | README |
| OIDC immutable subject | format repo:<owner>@<owner_id>/<repo>@<repo_id>:…; effective automatically from 2026-07-15 for newly created, renamed, or transferred repositories; existing repositories must opt in; Entra flexible federated credentials need to match repository_id / repository_owner_id | GitHub Changelog · Microsoft Learn (2026-07-28) |
| amazon.aws.aws_ssm | The connection plugin is in amazon.aws (the docs page corresponds to 11.5.1, originally introduced in community.aws 1.0.0); bucket_name and region options | aws_ssm connection |
Video verification notes
The following videos were verified for title and channel through the YouTube oEmbed endpoint (2026-11-15): Jeff Geerling's “Ansible 101 - Episode 7 - Molecule Testing and Linting and Ansible Galaxy” (FaXVZ60o8L8), “Ansible 101 - Episode 8 - Playbook testing with Molecule and GitHub Actions CI” (CYghlf-6Opc), “Ansible 101 - Episode 10 - Ansible Tower and AWX” (iKmY4jEiy_A), “Ansible 101 - Episode 1 - Introduction to Ansible” (goclfp6a2IQ); The Ansible Playbook (official Ansible channel) “Event-Driven Ansible Rulebooks” (PtevBKX1SYI), “Event-driven Ansible + Gitops” (Bb51DftLbPE); TechWorld with Nana “GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker” (R8_veQiYBjI), “What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners” (1id6ERvfozo); Fireship “Ansible in 100 Seconds” (xRMPKQweySE). oEmbed does not return durations or dates, so the recording years on the cards are inferred. No verified dedicated videos were found for Modules 1, 6, and 7; storyboard scripts are provided instead. All videos are in English and were recorded before the versions used in this lesson; for new features, follow this lesson and the official docs.
Narration notes
The “Audio” page uses the browser's Web Speech API (speechSynthesis, en-US) to read the script aloud in real time; English terms are pronounced with en-US; results depend on the voices installed on the system. The environment that generated this material cannot call a TTS service, so no MP3 is embedded; for offline audio, pass the script to a TTS service such as Azure AI Speech.
Known limitations
- None of the lab commands in this lesson were actually executed in the generating environment; the IPs (such as 20.151.0.10), IDs (owner/repo IDs, job IDs, SHAs), times, and counts in the “expected output” are sample values.
- AWX releases are paused, and the compatibility of AWX Operator 2.19.1 with Kubernetes 1.37 / kind v0.33 has no official statement; if you hit problems, switch to an older kind node image. AWX documentation site links may change with the refactoring.
- The Red Hat documentation page for AAP 2.6 returned 403 at verification time; the related facts come from the course specification and search summaries. For AAP's UI, API paths (platform gateway prefix), role names, and component list, refer to the official docs.
- awx.awx module parameters (survey_spec, notification_configuration, credential_input_source metadata, etc.) and awxkit subcommands (roles grant, teams associate, export) vary by version; the syntax used here should be checked with
ansible-doc/awx --help. - The Molecule example uses a community image
geerlingguy/docker-*-ansible(not official) with privileged containers, for test environments only; keys such as platforms/provisioner in molecule.yml belong to what the official docs call the pre-ansible-native style, and their behavior in newer versions follows the official docs. requirements.ymlThe collection version ranges inansible-core==2.21.5and are examples; query Galaxy/PyPI and pin exact versions.- Times and flows in the animations are illustrative, used to explain mechanisms; log wording follows the actual version.