Ansible Core
Browse A–ZAtomic lessons on Ansible language, playbooks, inventory, and engine.
Highlighted guide
More in this track
Ansible Core ·
Use list to loop over dictionary keys
Pipe dict.keys() through the list filter so a loop works on Python 3.
Ansible Core ·
Use now to get the current time in a template
Use now() when you need the current time, not the time facts were gathered.
Ansible Core ·
Use query to get lookup results as a list
Use query (or q) when a lookup must return a list you can loop over.
Ansible Core ·
Use truthy to test whether a value is true
Use the truthy test in when to treat a non-empty or true-like value as true.
Ansible Core ·
Use notify and handlers to run a task after a change
Use notify with a handler so Ansible restarts a service only after a config file changes.
Ansible Core ·
Use loop to run a task for each item in a list
Use loop to install each RHEL package name in a list with one package task.
Ansible Core ·
Use run_once to run a task on a single host
Use run_once so Ansible prints a cluster-wide message once instead of on every host.
Ansible Core ·
Use block rescue always to handle a failed task
Use block, rescue, and always to recover from a failed task and still run cleanup.
Ansible Core ·
Use search to match a pattern anywhere in a string
Use the Jinja search test in when to match a regex pattern anywhere in a string.
Ansible Core ·
Use until to retry a task until a condition is met
Use until with retries and delay to poll a task until a condition is true.
Ansible Core ·
Use when to run a task only if a condition is true
Use when to skip a task unless a condition evaluates to true.
Ansible Core ·
Use changed_when to mark when a task changes the system
Use changed_when to report changed only when the task actually changed the system.
Ansible Core ·
Use failed_when to control when a task fails
Use failed_when to decide failure from the registered result instead of the default return code alone.