# How can i specify the same target host twice or more in my playbook ?

**URL:** <https://forum.ansible.com/t/how-can-i-specify-the-same-target-host-twice-or-more-in-my-playbook/22888>\
**Category:** Ansible Project\
**Created:** [October 26, 2016, 9:05am UTC](https://forum.ansible.com/t/how-can-i-specify-the-same-target-host-twice-or-more-in-my-playbook/22888 "2016-10-26T09:05:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [October 26, 2016, 9:05am UTC](https://forum.ansible.com/t/how-can-i-specify-the-same-target-host-twice-or-more-in-my-playbook/22888/1 "2016-10-26T09:05:18Z")

</div>

I have a situation for which we have decided to allow multiple instances of the same app to run on same host machines. I do not want to modify my playbook or inventory to incorporate this temporary hack and was wondering if i can do that simply by modifying host list and some of the variables.  
So i need to know two main things:

1. Is there a way i can repeat a target host in my playbook ? I have tried repeating the hostname in the comma separated list but that doesn’t work

2. How can i override some variables for this repeated host ?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [October 26, 2016, 1:31pm UTC](https://forum.ansible.com/t/how-can-i-specify-the-same-target-host-twice-or-more-in-my-playbook/22888/2 "2016-10-26T13:31:47Z")

</div>

I think you are going to have to change, or at least add something to do this.

I would do this by adding a temporary inventory file and group vars.

If you have inventory with groups like

`  
[webservers]  
host1 app\_folder=/opt/instance1

[database]  
host1 app\_folder=/opt/instance2  
`

then you can have a playbook that does something like the following:

`  
hosts: webservers:  
roles:

- install\_app

hosts: database  
roles:

- install\_app  
`

if install\_app uses app\_folder  
as the installation dir for app then you can get 2

Don’t forget you can set defaults in your role so that you only have to provide an override for the hosts that need it.

I have an inventory file which has all the same group names as my test and production inventories, but only 1 actual host, which points at a virtual machine which I can revert back to a ‘blank’ snapshot. I use this a lot for developing my provisioning playbooks.

Hope this helps,

Jon
