# manually define an inventory var when there is no inventory file

**URL:** <https://forum.ansible.com/t/manually-define-an-inventory-var-when-there-is-no-inventory-file/19263>\
**Category:** Ansible Project\
**Created:** [September 14, 2015, 7:49pm UTC](https://forum.ansible.com/t/manually-define-an-inventory-var-when-there-is-no-inventory-file/19263 "2015-09-14T19:49:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [September 14, 2015, 7:49pm UTC](https://forum.ansible.com/t/manually-define-an-inventory-var-when-there-is-no-inventory-file/19263/1 "2015-09-14T19:49:35Z")

</div>

Hi All,

I have the following template :

**# web\_cconfig.j2 :**

**web\_servers={% for host in groups[‘web’] %} {{ host }}, {% endfor %}**

This file is deployed in a role and using the server list from the inventory web group and working OK, the problem is when there are cases I need to use the same role but without specifying an inventory file , as for example when launching a new ec2 instacne and using using **add\_host** module to configure this will throw an error the web group was not found…

Is it possible to manually set a inventory host var so I can use the same playbook ?
