# LIMIT as extra\_vars

**URL:** <https://forum.ansible.com/t/limit-as-extra-vars/33742>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [September 3, 2020, 11:54pm UTC](https://forum.ansible.com/t/limit-as-extra-vars/33742 "2020-09-03T23:54:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry\_Hwang](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Jerry\_Hwang](https://forum.ansible.com/u/Jerry_Hwang)\
**Post date:** [September 3, 2020, 11:54pm UTC](https://forum.ansible.com/t/limit-as-extra-vars/33742/1 "2020-09-03T23:54:40Z")

</div>

In AWX, you can pop-up ‘LIMIT’ option to limit the host list for playbook run.

Is it possible to take the value of LIMIT like --extra-vars

I have a python script to take the value from --extra-vars on playbook running and want to use the value of ‘LIMIT’ as well.

Thanks,  
Jerry

---

<div class="post-metadata">

**Author:** ![sdmorel](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sdmorel](https://forum.ansible.com/u/sdmorel)\
**Post date:** [September 4, 2020, 8:03am UTC](https://forum.ansible.com/t/limit-as-extra-vars/33742/2 "2020-09-04T08:03:16Z")

</div>

Hi,

You may want to take a look at [https://docs.ansible.com/ansible/latest/reference\_appendices/special\_variables.html](https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html)  
I think what you want is to use the **ansible\_limit** variable.

Cheers!

---

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [September 4, 2020, 8:12am UTC](https://forum.ansible.com/t/limit-as-extra-vars/33742/3 "2020-09-04T08:12:50Z")

</div>

Hi Jerry,

We do precisely this by setting an arbitrary variable with the ‘—limit’ value and using that variable in the ‘hosts’ field. It works just fine.

Rod

---

<div class="post-metadata">

**Author:** ![Jerry\_Hwang](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@Jerry\_Hwang](https://forum.ansible.com/u/Jerry_Hwang)\
**Post date:** [September 4, 2020, 1:22pm UTC](https://forum.ansible.com/t/limit-as-extra-vars/33742/4 "2020-09-04T13:22:30Z")

</div>

Hi Rod,

The python script I mentioned is ansible callback plugin  
[https://docs.ansible.com/ansible/latest/plugins/callback.html](https://docs.ansible.com/ansible/latest/plugins/callback.html)

When I use --extra-vars “host\_limit=linux1”  
the callback plugin takes the value like this

vm = play.get\_variable\_manager()  
self.hosts = vm.extra\_vars[“host\_limit”]

In AWX, we would like to use the ‘LIMIT’ option instead of --extra-vars.

Do you know how the callback plugin can take the value of ‘LIMIT’?

Thanks,  
Jerry
