# why the playbook does not run as many times as there are entries in the hosts file ?

**URL:** <https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328>\
**Category:** Ansible Project\
**Created:** [May 2, 2016, 11:13am UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328 "2016-05-02T11:13:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [May 2, 2016, 11:13am UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328/1 "2016-05-02T11:13:58Z")

</div>

Hello,

I did param 2 entries in my hosts file:  
[server]

localhost ansible\_connection=local ansible\_user=fvaltat PARAM=“[‘tomweb’, ‘’, ‘Y’,‘1’]”  
localhost ansible\_connection=local ansible\_user=fvaltat PARAM=“[‘openhr’, ‘7.30.060’, ‘Y’,‘2’]”

In my playbook, I did set the hosts to server:

- hosts: server  
become: False  
become\_user: root  
roles:
- listparam

and I do display the variables using the debug module in the main.yml of the listparam/tasks directory:

- debug: msg=“DISPLAY variables from an array PARAM {{ param }} - param[0]-module {{ param[0] }} - param[1]-release {{ param[1] }} - param[2]-tomtools {{ param[2] }} - param[3]-instance {{ param[3] }}”

But when I run the playbook, I only display the 2nd entry of the hosts file, why doesn’t it run the playbook for the 1st entry ?

ansible-playbook -i ./hosts test\_host.yml

PLAY [server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [listparam : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “DISPLAY variables from an array PARAM [‘openhr’, ‘7.30.060’, ‘Y’, ‘2’] - param[0]-module openhr - param[1]-release 7.30.060 - param[2]-tomtools Y - param[3]-instance 2”  
}

I do expect to have this display too :

TASK [listparam : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “DISPLAY variables from an array PARAM [‘tomweb’, ‘’, ‘Y’, ‘1’] - param[0]-module tomweb - param[1]-release - param[2]-tomtools Y - param[3]-instance 1”  
}

---

<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:** [May 2, 2016, 12:52pm UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328/2 "2016-05-02T12:52:04Z")

</div>

hostnames are unique, so multiple entries are merged.

---

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [May 2, 2016, 12:57pm UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328/3 "2016-05-02T12:57:44Z")

</div>

Thank you but do you mean if I want to deploy on the same hostnames for different ansible\_user, this will merge too ?

Example:

[server]

localhost ansible\_connection=local ansible\_user=fvaltat  
localhost ansible\_connection=local ansible\_user=greg

regards

---

<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:** [May 2, 2016, 1:18pm UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328/4 "2016-05-02T13:18:18Z")

</div>

only 1 of them will be visible, i recommend using the ‘inventory\_hostname’ as an alias:

[server]  
localhost\_fvaltat ansible\_connection=local ansible\_user=fvaltat  
localhost\_greg ansible\_connection=local ansible\_user=greg

---

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [May 3, 2016, 7:40am UTC](https://forum.ansible.com/t/why-the-playbook-does-not-run-as-many-times-as-there-are-entries-in-the-hosts-file/21328/5 "2016-05-03T07:40:56Z")

</div>

thank you we did use an alias this way:  
[server]

alias1 ansible\_host=localhost ansible\_connection=local ansible\_user=fvaltat  
alias2 ansible\_host=localhost ansible\_connection=local ansible\_user=greg

regards
