# Obtain --limit parameter in playbook

**URL:** <https://forum.ansible.com/t/obtain-limit-parameter-in-playbook/24657>\
**Category:** Ansible Project\
**Created:** [June 6, 2017, 10:25am UTC](https://forum.ansible.com/t/obtain-limit-parameter-in-playbook/24657 "2017-06-06T10:25:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thirsch.epages](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thirsch.epages](https://forum.ansible.com/u/thirsch.epages)\
**Post date:** [June 6, 2017, 10:25am UTC](https://forum.ansible.com/t/obtain-limit-parameter-in-playbook/24657/1 "2017-06-06T10:25:04Z")

</div>

Hi, I have had twice now the use case of needing to access host vars of a specific host, without knowing the inventory hostname.

I would like to suggest to be able to read the value of the --limit parameter from inside a playbook.  
Maybe something like an ansible\_limit magic variable, which has as value an array of the “:” (colon) separated parts.

Then one could use jinja2 tests to figure out the target-host from that.

The use case for this is a playbook to configure a development environment for a specific developer, without having to edit any files at all, so the target host needs to be supplied as a parameter.  
At the same time, I would like to avoid --extra\_vars “target\_host=”, because right now, I need both:

ansible-playbook setup-and-deploy-development -i inventory/vsphere --limit [my-developer-vm.example.com](http://my-developer-vm.example.com):localhost --extra-vars “target\_host=[my-developer-vm.example.com](http://my-developer-vm.example.com)”

I know in this case I could get rid of the “–limit” and put “{{ target\_host }}” everywhere, but like I said, would like to avoid that…

---

<div class="post-metadata">

**Author:** ![thirsch.epages](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thirsch.epages](https://forum.ansible.com/u/thirsch.epages)\
**Post date:** [June 26, 2017, 3:05pm UTC](https://forum.ansible.com/t/obtain-limit-parameter-in-playbook/24657/2 "2017-06-26T15:05:56Z")

</div>

Can anybody help me with this?

I want to know from inside the playbook, what was passed to the --limit parameter (e.g. “[my-vm.my-domain.com](http://my-vm.my-domain.com):localhost”)

The reason I cannot just connect to the “my-domain” machine, is that I want to read an inventory variable, (the MAC address) before the machine even gets created, so creative usage of set facts and delegation does not help me much I am afraid.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 1, 2017, 7:09am UTC](https://forum.ansible.com/t/obtain-limit-parameter-in-playbook/24657/3 "2017-07-01T07:09:37Z")

</div>

To my knowledge you can't.  
But you have ansible\_play\_batch variable that contains all the host in the play, maybe that helps you.
