# How can i get hosts variable value from ansible yaml file for a particular playbook to custom python module?

**URL:** <https://forum.ansible.com/t/how-can-i-get-hosts-variable-value-from-ansible-yaml-file-for-a-particular-playbook-to-custom-python-module/31247>\
**Category:** Ansible Developer\
**Created:** [September 10, 2019, 6:06am UTC](https://forum.ansible.com/t/how-can-i-get-hosts-variable-value-from-ansible-yaml-file-for-a-particular-playbook-to-custom-python-module/31247 "2019-09-10T06:06:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thameem\_ansari](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@thameem\_ansari](https://forum.ansible.com/u/thameem_ansari)\
**Post date:** [September 10, 2019, 6:06am UTC](https://forum.ansible.com/t/how-can-i-get-hosts-variable-value-from-ansible-yaml-file-for-a-particular-playbook-to-custom-python-module/31247/1 "2019-09-10T06:06:33Z")

</div>

How can i get hosts variable value from ansible yaml file for a particular playbook to custom python module?

---

<div class="post-metadata">

**Author:** ![td784](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@td784](https://forum.ansible.com/u/td784)\
**Post date:** [September 10, 2019, 10:52pm UTC](https://forum.ansible.com/t/how-can-i-get-hosts-variable-value-from-ansible-yaml-file-for-a-particular-playbook-to-custom-python-module/31247/2 "2019-09-10T22:52:49Z")

</div>

Would the custom module be apart of the same playbook that the host variable is in? Or separate?

If it apart of the same playbook My first thought is to pass the j2 host variable nto the custom python module as a parameter, if it is an Ansible module that is. Otherwise you should be able to pass it into the module as a sys.argv as well and let the custom module perform its logic from there.
