# Ansible Conditionals

In 
Published 2022-12-03

This tutorial explains to you how to use conditionals in Ansible. This tutorial has an example as well.

Ansible loops are used in Ansible playbooks and are very similar to using loops in any programming language. It helps you to loop through a list of variable in the playbook and do a task for each value.

Sometimes we need to filter the loop list. This is done using Ansible conditionals.

Here it is an example of using a simple Ansible conditionals:

As you can see we can use when condition in order to filter the loop list.

Here it is the result of execution:

You can inverse the condition by using not in front of the condition: