# How to pass variables into modules in Ansible

**URL:** <https://forum.ansible.com/t/how-to-pass-variables-into-modules-in-ansible/21594>\
**Category:** Ansible Project\
**Created:** [May 29, 2016, 1:19am UTC](https://forum.ansible.com/t/how-to-pass-variables-into-modules-in-ansible/21594 "2016-05-29T01:19:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZaVaZaVa](https://avatars.discourse-cdn.com/v4/letter/z/13edae/32.png) [@ZaVaZaVa](https://forum.ansible.com/u/ZaVaZaVa)\
**Post date:** [May 29, 2016, 1:19am UTC](https://forum.ansible.com/t/how-to-pass-variables-into-modules-in-ansible/21594/1 "2016-05-29T01:19:42Z")

</div>

Hello

I am new into ansible and I would appreciate some help here…

I am working on a new Project to automatic our Infrastructure Network Deployment and Configuration.

Question: How do I pass parameters to a YML file or, assuming it is the same, how do I pass variables into modules defined within Playbook.

All help is highly appreciated.

Regards

ZaVaZaVa

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 29, 2016, 7:32pm UTC](https://forum.ansible.com/t/how-to-pass-variables-into-modules-in-ansible/21594/2 "2016-05-29T19:32:40Z")

</div>

I fear your question is too wide to get really good answers. Why don't  
you give an example of what you are trying to achieve? Or which code  
works/does not work for you?

Generally, variables set in host\_vars, group\_vars, vars-sections of  
plays and similar are set and can be used within a play or role or task.

[https://docs.ansible.com/ansible/playbooks\_variables.html](https://docs.ansible.com/ansible/playbooks_variables.html)

Johannes

---

<div class="post-metadata">

**Author:** ![ZaVaZaVa](https://avatars.discourse-cdn.com/v4/letter/z/13edae/32.png) [@ZaVaZaVa](https://forum.ansible.com/u/ZaVaZaVa)\
**Post date:** [May 30, 2016, 2:49am UTC](https://forum.ansible.com/t/how-to-pass-variables-into-modules-in-ansible/21594/3 "2016-05-30T02:49:48Z")

</div>

Thanks Johannes.

What I really wanted to understand it is just the **generic method or methods of defining and passing variables to a module in a playbook.** I am at the beginning of learning ansible and that is one of the questions I would like to have clarified.

Zava
