Throughout the module you've used register several times without stopping to look at it: to reload nginx only if its configuration changed, to re-read the local facts or to wait for the Aurora Store website to respond. In this final lesson of the module you'll study it in depth: exactly what a registered result contains, how it behaves in loops and how to use it to make decisions. You'll learn to control when a task counts as changed or failed (changed_when, failed_when) and you'll equip yourself with all of Ansible's diagnostic tools: the debug module, verbosity levels, per-task simulation, step-by-step execution, the interactive debugger and assertions with assert. You'll apply it by adding a complete verification of the store website to webservers.yml.
Contents
register: storing a task's result- The structure of a result
- Loop results:
results - Using results in conditions
changed_whenandfailed_when- The
debugmodule:msg,varandverbosity - Verbosity levels: from
-vto-vvvv - Per-task simulation and differences:
check_modeanddiff - Running in parts:
--stepand--start-at-task - The task debugger
- Checking assumptions with
assert - Practice: verifying the Aurora Store website
- Diagnostic strategy
register: storing a task's result
register: storing a task's resultEvery module returns a result in JSON (Lesson 2.5). The register task keyword stores it in a host variable, available to the following tasks (and to later plays in the same run):
- name: Get the nginx version
ansible.builtin.command:
cmd: nginx -v
register: nginx_version_cmd
- name: Show the full result
ansible.builtin.debug:
var: nginx_version_cmdEach host has its own value: nginx_version_cmd on web1 contains web1's result. That's why you can use registered results in per-host conditions, as you did with nginx_site_config.changed in Lesson 3.3.
As a convention in Aurora, the names of registered variables describe what they contain and carry the component's prefix: nginx_site_config, postgresql_hba, aurora_web_check.
- The structure of a result
Run the two previous tasks in a test playbook on web1. With the YAML output from ansible.cfg (Lesson 2.3), you'll see something like this:
TASK [Show the full result] ****************************************************
ok: [web1] =>
nginx_version_cmd:
changed: true
cmd:
- nginx
- -v
delta: '0:00:00.004812'
end: '2026-11-26 10:15:02.731905'
failed: false
msg: ''
rc: 0
start: '2026-11-26 10:15:02.727093'
stderr: 'nginx version: nginx/1.24.0 (Ubuntu)'
stderr_lines:
- 'nginx version: nginx/1.24.0 (Ubuntu)'
stdout: ''
stdout_lines: []Notice a curiosity: nginx -v writes the version to standard error (stderr), not to standard output. Inspecting the full result is the only way to discover things like this.
Fields common to almost every module:
| Field | Type | Meaning |
|---|---|---|
changed |
boolean | Whether the task modified something |
failed |
boolean | Whether the task failed |
skipped |
boolean | Whether the task was skipped (because of when or check mode) |
msg |
text | The module's message (often the explanation of an error) |
Fields of the modules that run commands (command, shell, script, raw):
| Field | Type | Meaning |
|---|---|---|
rc |
integer | The command's exit code (0 = success) |
stdout / stderr |
text | Full standard output / standard error |
stdout_lines / stderr_lines |
list | The same output, split into lines |
cmd, start, end, delta |
various | The command that was run and timings |
In addition, each module adds its own return values, documented in the RETURN VALUES section of ansible-doc (Lesson 2.5). For example, ansible.builtin.uri returns status (HTTP code), content (the body, if return_content: true), json (if the response is JSON) and the headers; ansible.builtin.stat returns stat.exists, stat.mode…
If a task is skipped, the registered variable still exists, but only with skipped: true and little else: it has no rc, no stdout and no status. It's a common source of errors, as you'll see in section 8.
- Loop results:
results
resultsIf the task has a loop, the registered variable doesn't contain one result but a list of them in results, one per iteration. Each element includes the item field with the loop item that produced it.
This example checks which team users exist (getent returns 0 if the user exists and 2 if not):
- name: Check which team users exist
ansible.builtin.command:
cmd: "getent passwd {{ item.name }}"
loop: "{{ aurora_team_users }}"
loop_control:
label: "{{ item.name }}"
register: aurora_team_check
changed_when: false
failed_when: aurora_team_check.rc not in [0, 2]
- name: Report the status of each user
ansible.builtin.debug:
msg: "{{ item.item.name }}: {{ 'exists' if item.rc == 0 else 'does not exist' }}"
loop: "{{ aurora_team_check.results }}"
loop_control:
label: "{{ item.item.name }}"Structure of aurora_team_check:
aurora_team_check:
changed: false
msg: All items completed
results:
- item: {name: deploy, comment: Aurora Store deployments}
rc: 0
stdout: "deploy:x:1001:1001:Aurora Store deployments:/home/deploy:/bin/bash"
changed: false
# ...
- item: {name: laura, comment: Laura Gómez - Development, admin: true}
rc: 0
# ...
- item: {name: jordi, comment: Former contributor, state: absent}
rc: 2
# ...Key points:
- In the second task,
itemis each result, anditem.itemis the original user. It's a double indirection that's confusing at first. - Inside
changed_whenandfailed_whenof a task with a loop, the registered variable refers to the result of the current iteration (that's whyaurora_team_check.rcworks in the example). - At the task level,
changedis true if any iteration changed something. That's whypostgresql_hba.changedworked in Lesson 3.6.
- Using results in conditions
Registered results are used in when like any other variable:
when: nginx_version_cmd.rc == 0
when: "'1.24' in nginx_version_cmd.stderr"
when: aurora_web_check.status == 200
when: nginx_site_config.changedAnsible also offers result-specific tests, which are more readable and more robust, because they work even if a field is missing:
| Test | True if the task… |
|---|---|
result is changed |
changed something |
result is failed |
failed (useful with ignore_errors, Lesson 5.5) |
result is succeeded (or is success) |
finished without failing |
result is skipped |
was skipped |
- name: Reload nginx if its configuration has changed (temporary)
ansible.builtin.systemd_service:
name: nginx
state: reloaded
when: nginx_site_config is changed or nginx_site_enabled is changed or nginx_default_site is changedThis form is equivalent to the one you wrote in Lesson 3.3. You can leave yours as it is; in Lesson 5.1 this whole pattern will disappear in favor of handlers.
changed_when and failed_when
changed_when and failed_whenBy default, each module decides whether it changed something and whether it failed. With two task keywords you can redefine that criterion.
changed_when sets when the task counts as changed. The most frequent case: query commands with command, which are always marked as changed (Lesson 1.4) even though they don't modify anything:
- name: Get the nginx version
ansible.builtin.command:
cmd: nginx -v
register: nginx_version_cmd
changed_when: falseWith changed_when: false, the task always shows ok and the playbook remains idempotent (changed=0 on the second run). It also accepts an expression based on the result, for commands that do change something but only sometimes:
- name: Purge the store cache
ansible.builtin.command:
cmd: /usr/local/bin/aurora-cache-purge
register: aurora_cache_purge
changed_when: "'0 entries removed' not in aurora_cache_purge.stdout"(It's an illustrative example: that script doesn't exist in the lab.)
failed_when sets when the task counts as failed. It's useful when a command's exit code doesn't mean the same as it does for Ansible. You've already seen it with getent (code 2 = "doesn't exist", which isn't an error for us). Another example: grep returns 1 if it finds nothing:
- name: Check whether the default site is still enabled
ansible.builtin.command:
cmd: grep -rl default_server /etc/nginx/sites-enabled/
register: nginx_default_check
changed_when: false
failed_when: nginx_default_check.rc > 1 # 0 = found, 1 = not found, 2 = real errorBoth accept a list of conditions (all must be met), just like when. Full error handling (ignore_errors, block/rescue/always blocks, any_errors_fatal…) is covered in Lesson 5.5.
- The
debug module: msg, var and verbosity
debug module: msg, var and verbosityansible.builtin.debug shows information during the run, without touching the host. It has two mutually exclusive forms:
| Parameter | What it shows | Example |
|---|---|---|
msg |
A message (text, list or dictionary), with {{ }} variables |
msg: "Port: {{ nginx_port }}" |
var |
The value of a variable or expression, without {{ }} |
var: nginx_version_cmd.stderr |
And a third, very useful parameter, verbosity: the task only shows its message if you run with that level of detail or higher. That way you can leave diagnostic tasks in the playbook without cluttering the normal output:
- name: Show the computed connection details (diagnostics)
ansible.builtin.debug:
var: aurora_db_dsn
verbosity: 1Without -v, it appears as skipping; with -v (or more), it shows the value.
var accepts expressions: var: hostvars[inventory_hostname]['group_names'] or var: ansible_facts['default_ipv4']. To explore all of a host's variables, var: hostvars[inventory_hostname] is the most complete option (and the longest).
- Verbosity levels: from
-v to -vvvv
-v to -vvvvYou already used -v and -vvv in Lesson 1.5. Each v adds detail:
| Level | What it adds | When to use it |
|---|---|---|
| (none) | Each task's name and status per host | Normal use |
-v |
Each task's result (as if you registered and displayed everything) and the configuration file used | See what a task returned |
-vv |
Task file paths, include information, loaded callbacks | Projects with roles and includes |
-vvv |
The connection: SSH commands, user, temporary files, become |
Connection or permission problems |
-vvvv |
Even more connection detail (SSH debugging, connection plugins) | Hard SSH errors |
Tips:
- Always start with
-vand go up only if it isn't enough:-vvvvgenerates hundreds of lines per task. - Combine it with
--limitto see the output of one host. - You can also set it with the
ANSIBLE_VERBOSITY=1environment variable (useful in CI).
- Per-task simulation and differences:
check_mode and diff
check_mode and diff--check and --diff affect the whole playbook (Lesson 3.3). The check_mode and diff task keywords let you adjust it task by task:
| Keyword | Value | Effect |
|---|---|---|
check_mode: false |
— | The task runs for real even if the playbook is in --check |
check_mode: true |
— | The task is always simulated, even if the playbook isn't in --check |
diff: false |
— | Doesn't show differences even when --diff is used (sensitive or huge content) |
diff: true |
— | Shows differences even when --diff isn't used |
check_mode: false solves a very real problem. In check mode, the command and shell modules are skipped (they can't know what an arbitrary command would change). If a later task uses their registered result, it fails:
fatal: [web1]: FAILED! =>
msg: 'The task includes an option with an undefined variable. The error was: ''dict object'' has no attribute ''stderr'''The solution, for read-only commands such as nginx -v, is to always run them:
- name: Get the nginx version
ansible.builtin.command:
cmd: nginx -v
register: nginx_version_cmd
changed_when: false
check_mode: falseUse it only on tasks that don't modify anything. Marking a task that changes the system with check_mode: false breaks the promise of --check. The ansible_check_mode magic variable (Lesson 3.5) also lets you know in a condition whether you're simulating.
- Running in parts:
--step and --start-at-task
--step and --start-at-task--step asks for confirmation before each task:
Perform task: TASK: Gathering Facts (N)o/(y)es/(c)ontinue: y
...
Perform task: TASK: Install nginx (N)o/(y)es/(c)ontinue: n
...
Perform task: TASK: Create the web root directory (N)o/(y)es/(c)ontinue: cy runs the task, n skips it and c continues without asking again. It's useful for calmly walking through someone else's playbook or one you've just written.
--start-at-task starts the run at the task with that name, skipping the previous ones. You already used it in Lesson 3.6 to see the until retries:
It's very handy when a long playbook fails near the end and you want to repeat it from that point only. But be careful: skipped tasks don't register their variables or run their set_fact. If a later task depends on them, it will fail (for example, starting at Publish the database connection details fails because aurora_db_dsn is computed by the previous task). Use --list-tasks to copy the exact name.
- The task debugger
When a task fails, Ansible can open an interactive debugger instead of aborting. From it you can inspect the task and its variables, fix them and run the task again without relaunching the playbook. It's enabled with the debugger keyword (on a play or on a task):
| Value | Opens the debugger when the task… |
|---|---|
on_failed |
fails |
on_unreachable |
can't connect to the host |
on_skipped |
is skipped |
always |
always |
never |
never (default) |
Or, without touching the playbook, for every task that fails or is unreachable:
Try it with a test playbook, debug-test.yml, with a deliberate typo:
---
- name: Try out the debugger
hosts: web1
gather_facts: false
debugger: on_failed
tasks:
- name: Show the nginx port
ansible.builtin.debug:
msg: "nginx port: {{ nginx_prot }}"TASK [Show the nginx port] *****************************************************
fatal: [web1]: FAILED! =>
msg: 'The task includes an option with an undefined variable. The error was: ''nginx_prot'' is undefined. ...'
[web1] TASK: Show the nginx port (debug)> p task.args
{'msg': 'nginx port: {{ nginx_prot }}'}
[web1] TASK: Show the nginx port (debug)> p task_vars['nginx_port']
80
[web1] TASK: Show the nginx port (debug)> task.args['msg'] = 'nginx port: {{ nginx_port }}'
[web1] TASK: Show the nginx port (debug)> redo
ok: [web1] =>
msg: 'nginx port: 80'Debugger commands:
| Command | Shortcut | What it does |
|---|---|---|
print <expr> |
p |
Shows a value: p task, p task.args, p task_vars, p host, p result._result |
task.args[key] = value |
— | Changes a module parameter |
task_vars[key] = value |
— | Changes a variable (then use update_task) |
update_task |
u |
Regenerates the task with the modified variables |
redo |
r |
Runs the task again |
continue |
c |
Carries on with the playbook (the task remains failed) |
quit |
q |
Aborts the playbook |
help |
h |
Help |
Remember that changes made in the debugger are temporary: fix the playbook afterwards (here, nginx_prot → nginx_port). Delete debug-test.yml when you're done.
- Checking assumptions with
assert
assertThe ansible.builtin.assert module checks one or more conditions and fails if any of them isn't met. It's used to validate that the system has ended up as you expected, or that variables have reasonable values before using them:
- name: Validate the PostgreSQL variables
ansible.builtin.assert:
that:
- postgresql_port | int > 0
- postgresql_port | int < 65536
- postgresql_max_connections | int >= 20
fail_msg: "Check the PostgreSQL variables of {{ inventory_hostname }}"
success_msg: "PostgreSQL variables are correct"| Parameter | Meaning |
|---|---|
that |
Condition or list of conditions (when syntax: no {{ }}) |
fail_msg |
Message if any of them fails |
success_msg |
Message if all of them are met |
quiet |
true to show nothing when everything is fine |
assert versus debug and fail: debug only reports; ansible.builtin.fail always fails (it's usually combined with when); assert expresses the intent more clearly: "this must be true". Assertions are also the basis of the infrastructure tests you'll see with Molecule in Lesson 9.5.
- Practice: verifying the Aurora Store website
Bring everything together in the post_tasks of webservers.yml. Replace the post_tasks section from Lesson 3.6 with this complete version:
post_tasks:
- name: Wait for the store website to respond
ansible.builtin.uri:
url: "http://localhost:{{ nginx_port }}/"
return_content: true
register: aurora_web_check
until: aurora_web_check.status == 200
retries: 5
delay: 3
check_mode: false
- name: Get the nginx version
ansible.builtin.command:
cmd: nginx -v
register: nginx_version_cmd
changed_when: false
check_mode: false
- name: Show the nginx version
ansible.builtin.debug:
msg: "{{ inventory_hostname }}: {{ nginx_version_cmd.stderr }}"
- name: Check that the store website works
ansible.builtin.assert:
that:
- aurora_web_check.status == 200
- "'Aurora Store' in aurora_web_check.content"
fail_msg: "The website on {{ inventory_hostname }} does not show the Aurora Store page"
success_msg: "The website on {{ inventory_hostname }} responds correctly (HTTP {{ aurora_web_check.status }})"- The wait now requests the content (
return_content: true) so it can be checked afterwards, and it hascheck_mode: falsebecauseuridoesn't run in check mode and it's a read-only request. nginx -vis a query:changed_when: falsekeeps idempotency andcheck_mode: falseguarantees that the result also exists during a simulation. The version is read fromstderr, as you discovered in section 2.assertchecks the HTTP code and that the page contains the textAurora Store: a server that responded 200 with nginx's default page wouldn't pass the verification.
Run the whole infrastructure:
TASK [Show the nginx version] **************************************************
ok: [web1] =>
msg: 'web1: nginx version: nginx/1.24.0 (Ubuntu)'
ok: [web2] =>
msg: 'web2: nginx version: nginx/1.24.0 (Ubuntu)'
TASK [Check that the store website works] **************************************
ok: [web1] =>
changed: false
msg: The website on web1 responds correctly (HTTP 200)
ok: [web2] =>
changed: false
msg: The website on web2 responds correctly (HTTP 200)
PLAY RECAP *********************************************************************
db1 : ok=... changed=0 unreachable=0 failed=0 ...
web1 : ok=... changed=0 unreachable=0 failed=0 ...
web2 : ok=... changed=0 unreachable=0 failed=0 ...Also check that the simulation works from start to finish:
It must finish without errors and with changed=0. Now cause a failure to see the assertion in action: change the page title on the server and run only the web servers in check mode (so that Ansible doesn't fix it before verifying):
ansible web1 -m ansible.builtin.replace -a 'path=/var/www/aurora/index.html regexp="Aurora Store" replace="Store"' -b
ansible-playbook webservers.yml --check --limit web1TASK [Check that the store website works] **************************************
fatal: [web1]: FAILED! =>
assertion: '''Aurora Store'' in aurora_web_check.content'
changed: false
evaluated_to: false
msg: The website on web1 does not show the Aurora Store pageRun ansible-playbook webservers.yml --limit web1 (without --check) to restore the page: the Publish the store home page task shows changed and the verification passes again. Ansible has just detected and fixed configuration drift, the problem this course started with in Lesson 1.1.
Commit the work:
This is the web servers' task list at the end of the module:
play #1 (webservers): Configure the Aurora Store web servers TAGS: []
tasks:
Update the package cache if it is older than one hour TAGS: []
Install nginx TAGS: []
Create the web root directory TAGS: []
Publish the store home page TAGS: []
Publish the store static pages TAGS: []
Configure the Aurora site in nginx TAGS: []
Enable the Aurora site TAGS: []
Disable the default nginx site TAGS: []
Ensure nginx is started and enabled TAGS: []
Reload nginx if its configuration has changed (temporary) TAGS: []
Allow SSH through the firewall TAGS: []
Allow HTTP through the firewall TAGS: []
Enable the firewall TAGS: []
Compute the database connection string TAGS: []
Create the Aurora configuration directory TAGS: []
Publish the database connection details TAGS: []
Wait for the store website to respond TAGS: []
Get the nginx version TAGS: []
Show the nginx version TAGS: []
Check that the store website works TAGS: []
- Diagnostic strategy
When a playbook doesn't do what you expect, follow an order. Going from the cheapest to the most expensive check saves a lot of time:
flowchart TD
A["The playbook fails or doesn't do what's expected"] --> B{"Syntax error?"}
B -- Yes --> B1["--syntax-check<br/>read line and column (Lesson 3.2)"]
B -- No --> C{"Unreachable host?"}
C -- Yes --> C1["ansible host -m ansible.builtin.ping<br/>-vvv to see SSH"]
C -- No --> D{"Undefined variable<br/>or unexpected value?"}
D -- Yes --> D1["ansible-inventory --host<br/>debug var=...<br/>precedence table (3.5)"]
D -- No --> E{"Does a module fail?"}
E -- Yes --> E1["Read msg with -v<br/>the module's ansible-doc<br/>on_failed debugger"]
E -- No --> F["Unexpected result:<br/>register + debug, --check --diff,<br/>--step, assert"]
Practical tips:
- Read the whole message: most errors explain the cause in
msg. With-vyou'll see the entire result. - Narrow down the problem:
--limitto one host,--start-at-taskup to the failing task, or a minimal test playbook with only that task. - Ask the system, don't assume: an ad hoc command (
ansible web1 -a 'cat /etc/nginx/sites-enabled/aurora') ordebugclarifies more than rereading the playbook. - Check the data before the logic: many "Ansible errors" are variables with the wrong value.
- Verify in the playbook itself:
assertanduriinpost_tasksturn your manual checks into part of the code. - Leave a trail:
debugtasks withverbosity: 1document computed values without cluttering the normal output.
Common Mistakes and Tips
'dict object' has no attribute 'stdout'(orrc,status…): the registered task was skipped (because ofwhenor check mode) and doesn't have those fields. Usecheck_mode: falseon read-only queries or guard the condition withis skipped/is defined.- Looking for
stdoutin a loop registration: it's invariable.results[n].stdout, not invariable.stdout. - Using
{{ }}indebug'svar::varreceives the variable name or an expression without braces;var: "{{ x }}"shows the value of a variable whose name is the contents ofx. changed_when: falseon tasks that do change the system: it hides real changes. Reserve it for queries.- Leaving
debugger: alwaysor--stepin CI scripts: the process sits waiting for an answer that never comes. - Forgetting to fix the playbook after fixing something in the debugger: the change only lives in that run.
- Tip: when a new module returns something you're going to use, register it and display it in full with
debug: var=...once before writing the condition; that way you'll know exactly which fields it has.
Exercises
Exercise 1: Verifying the static pages
Add a task to the post_tasks of webservers.yml that checks, with uri and a loop over aurora_static_pages | dict2items, that each static page responds with code 200. Register the result and use debug to show the code of each page.
Exercise 2: Disk space with failed_when
Write a test playbook that gets the usage percentage of the root disk on each Aurora server with df --output=pcent / | tail -1 (use ansible.builtin.shell, because there's a pipe) and that fails if it exceeds 80%. The task must never count as changed. Hint: stdout will be something like " 23%"; the replace('%', '') filter followed by int turns it into a number.
Exercise 3: Debugging a condition
This snippet never reloads nginx, not even when the configuration changes. Find the error using debug and explain it:
- name: Configure the Aurora site in nginx
ansible.builtin.copy:
dest: /etc/nginx/sites-available/aurora
content: "..."
register: nginx_site
- name: Reload nginx
ansible.builtin.systemd_service:
name: nginx
state: reloaded
when: nginx_site.changed == 'true'Solutions
Exercise 1.
- name: Check the static pages
ansible.builtin.uri:
url: "http://localhost:{{ nginx_port }}/{{ item.key }}"
loop: "{{ aurora_static_pages | dict2items }}"
loop_control:
label: "{{ item.key }}"
register: aurora_static_check
check_mode: false
- name: Show the HTTP code of each page
ansible.builtin.debug:
msg: "{{ item.item.key }}: HTTP {{ item.status }}"
loop: "{{ aurora_static_check.results }}"
loop_control:
label: "{{ item.item.key }}"uri fails on its own if the code isn't 200 (its status_code parameter defaults to 200), so the first task is already a verification. In the second, item is each result and item.item is the original dictionary entry (with key and value).
Exercise 2.
---
- name: Check Aurora's disk space
hosts: aurora
gather_facts: false
tasks:
- name: Get the root disk usage
ansible.builtin.shell:
cmd: df --output=pcent / | tail -1
register: aurora_disk
changed_when: false
failed_when: aurora_disk.stdout | replace('%', '') | int > 80
- name: Show the disk usage
ansible.builtin.debug:
msg: "{{ inventory_hostname }}: {{ aurora_disk.stdout | trim }} used"In the lab they'll all be below 80%; try changing the threshold to > 5 to see the failure. Watch out: if df failed, failed_when replaces the default criterion and the error could go unnoticed; a more robust version would be failed_when: aurora_disk.rc != 0 or (aurora_disk.stdout | replace('%', '') | int > 80).
Exercise 3. Add ansible.builtin.debug: var=nginx_site.changed after the first task: it shows true, a boolean, not the text 'true'. The comparison true == 'true' is false, so the task never runs. The correct condition is when: nginx_site.changed or, better, when: nginx_site is changed.
Conclusion
You've closed Module 3 with the tools to understand and control what your playbooks do: register and the structure of its results (rc, stdout, stderr, changed, failed, each module's own values and results in loops), the is changed/is failed tests, changed_when and failed_when, the debug module with verbosity, the -v to -vvvv levels, per-task check_mode and diff, --step, --start-at-task, the task debugger and assert. webservers.yml now verifies its own work: it waits for the website, checks the nginx version and makes sure the Aurora Store page is being served. Looking back over the module, Aurora is fully configured with ansible-playbook site.yml, which imports common.yml, dbservers.yml and webservers.yml, with variables, facts, conditionals and loops. But those files have grown a lot: webservers.yml already has about twenty tasks, the common configuration is lumped into a single file and none of this could be reused in another project or environment without copying and pasting. In Module 4: Roles you'll start with the Introduction to Roles lesson, where you'll discover how to package tasks, variables, files and templates into reusable, well-organized units, and how to turn Aurora's playbooks into the common, nginx and postgresql roles.
Ansible Course: From Beginner to Advanced
Module 1: Introduction to Ansible
- What Is Ansible?
- Installing Ansible
- Setting Up the Practice Lab
- Ansible Architecture
- Basic Ansible Commands
Module 2: Ansible Fundamentals
- Inventory Files
- Inventory Variables: group_vars and host_vars
- Configuring Ansible (ansible.cfg)
- Ad Hoc Commands
- Ansible Modules
- Collections and Fully Qualified Names (FQCN)
Module 3: Playbooks
- Introduction to Playbooks
- Essential YAML for Ansible
- Writing Your First Playbook
- Playbook Structure
- Variables and Facts
- Conditionals and Loops
- Registering Results and Debugging Playbooks
Module 4: Roles
- Introduction to Roles
- Creating Roles
- Role Directory Structure
- Using Roles in Playbooks
- Reusing Tasks: include and import
- Role Dependencies and Argument Validation
Module 5: Advanced Playbook Techniques
- Handlers
- Jinja2 Templates
- Filters and Lookups
- Ansible Vault
- Error Handling
- Tags and Selective Execution
- Rolling Deployments and Delegation
- Optimizing Playbooks
Module 6: Ansible Galaxy
- What Is Ansible Galaxy?
- Using Ansible Galaxy
- Managing Dependencies with requirements.yml
- Creating and Sharing Roles
- Creating Your Own Collections
Module 7: Ansible Tower, AWX and Automation Platform
- Introduction to Ansible Tower and AWX
- Installing AWX
- Using AWX: Job Templates and Jobs
- Managing Projects and Inventories
- Credentials, Permissions (RBAC) and Workflows
- Execution Environments and ansible-navigator
Module 8: Ansible for DevOps
- Ansible and Docker
- Ansible and Kubernetes
- CI/CD with Ansible
- Ansible in Cloud Environments
- Ansible and Terraform
Module 9: Ansible Best Practices
- Code Organization
- Security Best Practices
- Performance Tuning
- Code Quality: ansible-lint and yamllint
- Testing Ansible Code with Molecule
Module 10: Advanced Ansible Topics
- Custom Modules
- Dynamic Inventory
- Ansible Plugins
- The Ansible API and ansible-runner
- Event-Driven Ansible
