Checking for multiple conditions using “when” on single task in ansible

Question:

I want to evaluate multiple condition in ansible using when, here is my playbook:

here is my var file for reference:

When I try to execute this playbook, I am getting this error:

Can somebody point me out that how we can use multiple conditions with ansible on single task.

Thanks

Answer:

You can use like this.

Link to official docs: The When Statement.

Also Please refer to this gist:
https://gist.github.com/marcusphi/6791404

Leave a Reply