# Random inclusion of irrelevant hosts

**URL:** <https://forum.ansible.com/t/random-inclusion-of-irrelevant-hosts/22083>\
**Category:** Ansible Project\
**Created:** [July 22, 2016, 8:39am UTC](https://forum.ansible.com/t/random-inclusion-of-irrelevant-hosts/22083 "2016-07-22T08:39:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodion\_Zudin](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Rodion\_Zudin](https://forum.ansible.com/u/Rodion_Zudin)\
**Post date:** [July 22, 2016, 8:39am UTC](https://forum.ansible.com/t/random-inclusion-of-irrelevant-hosts/22083/1 "2016-07-22T08:39:23Z")

</div>

I have a question related to random inclusion of irrelevant hosts. Below is a part of my playbook:

**- hosts: machine01 machine02 machine03 machine04**  
**gather\_facts: no**  
**connection: docker**  
**tasks:**  
**- include: common/setup3.yml**

**- hosts: machine05 machine06**  
**gather\_facts: no**  
**connection: docker**  
**tasks:**  
**- include: common/setup2.yml**

setup3.yml includes following lines:

**- name: restart sshd**  
**command: service ssh restar** t

setup2.yml:

**- name: restart sshd**  
**service: name=sshd state=restarted**

However, what sometimes happens is when I run the playbook, eventually I get the following output and crash:

_TASK [INCLUDE] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_  
_Friday 22 July 2016 15:00:01_  
_included: /opt/info/ansible/common/setup2.yml for machine05 machine06, machine03_

_TASK [restart sshd] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_  
_Friday 22 July 2016 15:00:02_  
_changed: [machine 05]_  
_fatal: [machine03]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “no service or tool found for: sshd”}_  
_changed: [machine 06]_

So what happens, is for whatever reason setup2.yml includes machine03 (or some other random machine) to it’s hosts and crashes, because the play is not applicable for the machine in question.

What might be the reason for this random inclusion of irrelevant hosts? This seems to happen completely randomly in about 20% of cases.

Thank you in advance

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 3, 2017, 7:42pm UTC](https://forum.ansible.com/t/random-inclusion-of-irrelevant-hosts/22083/2 "2017-03-03T19:42:02Z")

</div>

So I tried to reproduce this and examined the code step by step, I don’t see how this can happen, much less randomly.

The only things i can think of is that you have overlapping host/group names and are using group\_by to add the machine to a ‘group with host name’, but this should happen every run, not at random.

If you can create a reproducer please open a ticket at [https://github.com/ansible/ansible](https://github.com/ansible/ansible)
