# Passing variable to hosts as extra value doesn't work in Tower

**URL:** <https://forum.ansible.com/t/passing-variable-to-hosts-as-extra-value-doesnt-work-in-tower/17268>\
**Category:** Ansible Project\
**Created:** [January 14, 2015, 5:32pm UTC](https://forum.ansible.com/t/passing-variable-to-hosts-as-extra-value-doesnt-work-in-tower/17268 "2015-01-14T17:32:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Goodall](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@David\_Goodall](https://forum.ansible.com/u/David_Goodall)\
**Post date:** [January 14, 2015, 5:32pm UTC](https://forum.ansible.com/t/passing-variable-to-hosts-as-extra-value-doesnt-work-in-tower/17268/1 "2015-01-14T17:32:04Z")

</div>

Hi,

I am trying to select hosts for a play based on a variable passed at job launch time in Tower:

hosts: “{{ project\_name }}-masters:{{ project\_name }}-slaves”

This will allow me to create and administer different stacks separately within the same Rackspace account.

I have read elsewhere that inventory variables are different to variables created in the playbook, but that a variable passed on the command-line with -e should be available to use with hosts: in a play.  
I have project\_name set up as an extra variable in the job template in Tower but this doesn’t have the desired effect.  
The plays with hosts referenced in this way all skip through with “no hosts matched”.  
I can see in the std-out that the project\_name variable is correctly formed.

Is there a way I can define my hosts based on a variable like this?  
If not the only workaround I can think of is to have to have a new playbook for each project with the project name hard-coded.

Best regards,  
David

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 14, 2015, 7:41pm UTC](https://forum.ansible.com/t/passing-variable-to-hosts-as-extra-value-doesnt-work-in-tower/17268/2 "2015-01-14T19:41:52Z")

</div>

For tower related inquiries you will want to reach out to [support@ansible.com](mailto:support@ansible.com)
