Ansible in a Minute
Learn one useful Ansible thing at a time, quickly.
A growing library of small, practical Ansible lessons. Each guide teaches one key concept, operator task, or Certified Collection use case.
Tracks
Browse A–ZRecent guides
Ansible Core ·
Use changed_when so a task can notify a handler
Handlers run only when a task reports changed. Use changed_when to control whether notify fires.
Ansible Core ·
Use contains to test if a list has a value
Use the contains test with selectattr to find a list item whose field includes a value.
Ansible Core ·
Use ignore_errors to continue after a failed command
Set ignore_errors so Ansible continues the play on a host after a task returns failed.
Ansible Core ·
Use query in loop instead of lookup
Use query with loop so lookup plugin results are a list. lookup returns a comma-joined string by default.
Ansible Core ·
Use ternary to choose a value for true or false
Use the ternary filter to return one value when a test is true and another when it is false.
Ansible Core ·
Use default omit to skip an optional module argument
Use default(omit) so Ansible omits a module argument when the variable is undefined instead of sending a value.
Ansible Core ·
Use delegate_facts to assign facts to the delegated host
Use delegate_facts true so facts gathered with delegate_to are stored on the delegated host, not the play host.
Ansible Core ·
Use environment to set remote environment variables
Use the environment keyword on a task so the remote action runs with specific environment variables.
Ansible Core ·
Use loop over a list of hashes
Use loop with a list of dictionaries and reference item keys such as item.name in the task.
Ansible Core ·
Use notify in a loop to target dynamic handlers
Use notify with item in a loop so each changed template can notify a matching handler name.
Ansible Core ·
Use shell or true to accept a non-zero exit
Append || /bin/true to a shell command when a non-zero exit code should still count as success.
Ansible Core ·
Use undef to clear a variable for a block
Use undef() to undefine a variable of lesser precedence so a block must supply its own value.
Ansible Core ·
Use version to compare version numbers
Use the version test in when to compare version strings with operators such as greater-than.
Ansible Core ·
Use when with ansible_facts to skip a task by OS
Use when with ansible_facts so a task runs only on hosts that match an OS family or distribution.
AAP 2.7 ·
Create a survey on a job template in AAP 2.7
Add a survey question to a job template in AAP 2.7 so launch prompts the operator for input.
Ansible Core ·
Debug a when condition before you skip a task
Print the values in a when expression so you can see why Ansible skips a task.
AAP 2.7 ·
Review job output in AAP 2.7
Open a job Output view in AAP 2.7 and filter the playbook log by keyword or event.
AAP 2.7 ·
Review job status in AAP 2.7
Open Jobs in AAP 2.7 to see whether a run is successful, failed, or still running.
Ansible Core ·
Use default to handle an undefined variable
Use the default filter so a task still runs when a variable is undefined.
Ansible Core ·
Use delegate_to to run a task on another host
Use delegate_to so a task runs on localhost (or another host) while the play still targets the current inventory host.
Subscribe for updates
Get an email whenever we publish new guides and blog posts. Unsubscribe anytime.
By subscribing you agree we may email you about Ansible in a Minute and related Level Up Labs updates. We store your address in the same lead sheet as our contact form.