# run a task when a play gets skipped by all hosts

**URL:** <https://forum.ansible.com/t/run-a-task-when-a-play-gets-skipped-by-all-hosts/30200>\
**Category:** Ansible Project\
**Created:** [April 26, 2019, 12:09pm UTC](https://forum.ansible.com/t/run-a-task-when-a-play-gets-skipped-by-all-hosts/30200 "2019-04-26T12:09:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IP\_Freely](https://avatars.discourse-cdn.com/v4/letter/i/e19adc/32.png) [@IP\_Freely](https://forum.ansible.com/u/IP_Freely)\
**Post date:** [April 26, 2019, 12:09pm UTC](https://forum.ansible.com/t/run-a-task-when-a-play-gets-skipped-by-all-hosts/30200/1 "2019-04-26T12:09:01Z")

</div>

Hi all

I have a playbook that checks 2 servers for log entrys, below is what is expected when it runs correctly: (part of the playbook below)

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [May 8, 2019, 6:49pm UTC](https://forum.ansible.com/t/run-a-task-when-a-play-gets-skipped-by-all-hosts/30200/2 "2019-05-08T18:49:10Z")

</div>

You would need to check them both with something like(list in when is the same as logical AND)

when:  
&nbsp;&nbsp;- hostvars['10.\*.0.137'].command\_output.stdout | length \> 0  
&nbsp;&nbsp;- hostvars['10.\*.0.138'].command\_output.stdout | length \> 0
