Conditional statements – making decisions in Ansible code

In a playbook or in a role sometimes we want to run different tasks based on different conditions. In most cases it depends on a fact (detail about the managed host) or some data collected during the playbook run. Ansible conditionals are there to make it possible to run different tasks based on different conditions, or skip executing tasks entirely.

Continue reading “Conditional statements – making decisions in Ansible code”

Loops in the Ansible code – the basics of iteration

Ansible loops and conditional statements are very cool inventions, but they are a double edged sword as well. The limitless freedom they give us can turn our roles into horrible mess. It is our responsibility to balance on the edge and use just the right amount of them in our code while we keep in mind that YAML is not a programming language.

Continue reading “Loops in the Ansible code – the basics of iteration”