O'Reilly logo

Learning Ansible by Ramesh Raithatha, Madhurranjan Mohaan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with conditionals

Till now, we saw how playbooks work and how tasks are executed. We also saw that Ansible executes all these tasks sequentially. However, this would not help you while writing an advanced playbook that contains tens of tasks and you have to execute only a subset of these tasks. For example, let's say you have a playbook that will install Apache HTTPD Server on the remote host. Now, the Apache HTTPD Server has a different package name for a Debian-based operating system, and it's called apache2; for a Red-Hat-based operating system, it's called httpd.

Having two tasks, one for the httpd package (for Red-Hat-based systems) and the other for the apache2 package (for Debian-based systems) in a playbook, will make Ansible install ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required