Chapter 5. Controlling Execution Flow – Conditionals

Control structures refer to anything and everything that have an effect on a program's execution flow. Control structures are mainly of the following two types:

  • Conditional
  • Iterative

At times, we need to execute code conditionally based on a value of a variable, type of platform, or even a result of some other command. There are times when we also need to iterate multiple objects, such as list hashes or multilevel variables.

Most programming languages and tools use powerful but machine-friendly constructs, such as if else, for, unless, do while, and so on. However, Ansible stays true to its design tenet of being a human-friendly automation language and manages to achieve the same with the omnipotent ...

Get Ansible Playbook Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.