When you execute an Ansible playbook, all actions are run top-down, in the order they are written. There are cases when you need more control: You want to check a host that a certain software is installed, or you want to validate a certain condition and stop following actions when this condition is not fulfilled. In this article, I will cover the following options of influencing action execution: defining when to execute an action, defining when to stop an action, branching the control flow, and controlling action results.
Here is an example to install and configure the text editor nano if the variable software_package is defined and when it equals nano.
And finally, you can determine when an action is considered to have changed or failed.