# when "partial" DOES NOT match

**URL:** <https://forum.ansible.com/t/when-partial-does-not-match/17528>\
**Category:** Ansible Project\
**Created:** [February 16, 2015, 8:23pm UTC](https://forum.ansible.com/t/when-partial-does-not-match/17528 "2015-02-16T20:23:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [February 16, 2015, 8:23pm UTC](https://forum.ansible.com/t/when-partial-does-not-match/17528/1 "2015-02-16T20:23:28Z")

</div>

I have a task that runs when there is a partial match on the inventory\_hostname:

when: ‘“lab” in inventory\_hostname’

I need to figure out a way to do the opposite, meaning, when ‘lab’ is not in inventory\_hostname the task will run. Any advice?

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 16, 2015, 8:32pm UTC](https://forum.ansible.com/t/when-partial-does-not-match/17528/2 "2015-02-16T20:32:39Z")

</div>

when: '"lab" not in inventory\_hostname'

Giovanni

---

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [February 16, 2015, 8:35pm UTC](https://forum.ansible.com/t/when-partial-does-not-match/17528/3 "2015-02-16T20:35:28Z")

</div>

You can slap me in the back of the head should we ever meet. I can’t believe I didn’t try that.
