Ansible & Configuration
changed_when guards
Explain how changed_when and failed_when turn a command's exit code or output into Ansible's changed and failed outcomes. Correct guards stop handlers from firing on read-only checks.
What you will be able to do
- Explain how a changed_when condition reads a registered result.
- Decide which exit codes or output lines mean changed, ok or failed for a given tool.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Ansible & Configuration
- Host variablesIntermediate · 4 min
Explain how host variables and host_vars files set one host's values above its group. A host file gives an exception without copying the group's default into every host.
- Idempotent modulesIntermediate · 4 min
Explain why a good Ansible playbook reports no changes on a second run. Modules check state before acting, while raw commands run each time unless a guard stops them.
- Handler notificationsIntermediate · 4 min
Explain how handler notifications work. A task that changes something notifies a handler by name, and the handler runs once per play at a defined point. Renames can…
- Template renderingIntermediate · 4 min
Explain how the template module renders a Jinja2 file per host and reports changed only when the rendered text differs. Validate and diff steps keep a broken or…
- Jinja escapingIntermediate · 4 min
Explain how Jinja2 decides what to render, and how to write template text that contains braces or percent signs without Jinja changing it. Escape once, at one stage…
- Vault secretsIntermediate · 5 min
Explain how Ansible Vault encrypts files and single values so they can live in version control. Vault protects data at rest, and it stops protecting once a run decrypts…