# Logical 'OR' in when statement?

**URL:** <https://forum.ansible.com/t/logical-or-in-when-statement/15947>\
**Category:** Ansible Project\
**Created:** [August 14, 2014, 5:32pm UTC](https://forum.ansible.com/t/logical-or-in-when-statement/15947 "2014-08-14T17:32:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [August 14, 2014, 5:32pm UTC](https://forum.ansible.com/t/logical-or-in-when-statement/15947/1 "2014-08-14T17:32:59Z")

</div>

Can I execute an action when variable1=x OR variable2=y?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 14, 2014, 5:51pm UTC](https://forum.ansible.com/t/logical-or-in-when-statement/15947/2 "2014-08-14T17:51:46Z")

</div>

Yep!

- shell: echo hi  
when: variable1 == x and variable2 == y
