Ansible provides a nice integrated way of performing conditional operations. That is to say, a task can be executed when a given condition is met. Some examples of this type of requirement might be to only execute a task if the target system is Ubuntu or only execute a task if the target system has a specific processor architecture.
Ansible supports conditionals through the implementation of the when operator. In this section, we will take a look at how Ansible manages conditionals and tour through an example of managing tasks through a condition. Let's start with this code:
# Reboot Debian Flavored Linux Systems using the WHEN operator tasks:
- name: "Reboot all Debian flavored Linux systems"
command: /sbin/reboot -t now
when: Ansible_os_family == "Debian"
In this example, we conditionally specify the Debian...