# how to set the --limit parameter to a variable ?

**URL:** <https://forum.ansible.com/t/how-to-set-the-limit-parameter-to-a-variable/23318>\
**Category:** Ansible Project\
**Created:** [December 22, 2016, 1:37pm UTC](https://forum.ansible.com/t/how-to-set-the-limit-parameter-to-a-variable/23318 "2016-12-22T13:37:13Z")\
**Posts on this page:** 3\
**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:** [December 22, 2016, 1:37pm UTC](https://forum.ansible.com/t/how-to-set-the-limit-parameter-to-a-variable/23318/1 "2016-12-22T13:37:13Z")

</div>

Hello,

I do run a playbook by setting a limit: ansible-playbook -i pilote.ini --limit DV70

My inventory file contains the following:

[DV70:chlidren]  
DV70\_DEV  
DV70\_REC  
…  
[DV70\_DEV]  
ansible\_host=server1 ansible\_user=usertest PARAM=WEB  
ansible\_host=server2 ansible\_user=usertest PARAM=DATABASE

Is there a way in the playbook to gather in a variale the limit value , I would like to have a variable limit: DV70\_DEV when I run the playbook on that host, hostvars would list all hosts.  
In the same order, is there a way to have a variable with the name of the .ini file passed has a parameter with the -i option ?

Thanks for helping

---

<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:** [December 22, 2016, 1:51pm UTC](https://forum.ansible.com/t/how-to-set-the-limit-parameter-to-a-variable/23318/2 "2016-12-22T13:51:02Z")

</div>

I found inventory\_file for the inventory variable.  
About the groups, I tried without any success the following variables:  
hostvars[inventory\_hostname]  
group\_names  
group

but i have the liste of al hosts, I want them separetly

---

<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:** [December 22, 2016, 2:01pm UTC](https://forum.ansible.com/t/how-to-set-the-limit-parameter-to-a-variable/23318/3 "2016-12-22T14:01:39Z")

</div>

inventory\_hostname is the variable.
