# Variable defined in main play is not passed to included playbook

**URL:** <https://forum.ansible.com/t/variable-defined-in-main-play-is-not-passed-to-included-playbook/24176>\
**Category:** Ansible Project\
**Created:** [April 10, 2017, 2:22am UTC](https://forum.ansible.com/t/variable-defined-in-main-play-is-not-passed-to-included-playbook/24176 "2017-04-10T02:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![0lai.mariano](https://avatars.discourse-cdn.com/v4/letter/0/51bf81/32.png) [@0lai.mariano](https://forum.ansible.com/u/0lai.mariano)\
**Post date:** [April 10, 2017, 2:22am UTC](https://forum.ansible.com/t/variable-defined-in-main-play-is-not-passed-to-included-playbook/24176/1 "2017-04-10T02:22:06Z")

</div>

I posted an issue recently on github ([https://github.com/ansible/ansible/issues/23394](https://github.com/ansible/ansible/issues/23394)) and was advised to post here on the user list since the issue I am encountering is not a bug. I am re-posting the content here with the response I received.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 11, 2017, 7:13am UTC](https://forum.ansible.com/t/variable-defined-in-main-play-is-not-passed-to-included-playbook/24176/2 "2017-04-11T07:13:03Z")

</div>

You could experiment with passing vars to a role.

roles:

- role: do\_things\_with\_ticket  
ticket\_number\_to\_process: “{{ticket\_number}}”

If you have lots of vars you need to set and don’t want to set -e command line for each of them, write them to a file and use the -e @/path/to/some/file.yml to load the extra vars in.  
This is pretty much what I do for our nightly integration build. I run one playbook to generate a yaml file containing all the versions of all the software components and then pass the output .yml file to a second playbook that deploys any updates.

You might also be able to use include\_vars if you have the vars in a file.

Hope this helps.

Jon
