# import\_playbook and variables

**URL:** <https://forum.ansible.com/t/import-playbook-and-variables/24999>\
**Category:** Ansible Project\
**Created:** [July 17, 2017, 1:34am UTC](https://forum.ansible.com/t/import-playbook-and-variables/24999 "2017-07-17T01:34:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Kakouros](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@Nick\_Kakouros](https://forum.ansible.com/u/Nick_Kakouros)\
**Post date:** [July 17, 2017, 1:34am UTC](https://forum.ansible.com/t/import-playbook-and-variables/24999/1 "2017-07-17T01:34:57Z")

</div>

I have a playbook.yml that has several import\_playbook statements, like this

- import\_playbook: plays/prepare.yml

- import\_playbook: plays/vpn\_server.yml

- import\_playbook: plays/web\_server.yml

and so on.

I want the first playbook to load some project configuration/facts//variables that should be available to all other playbooks.

I noticed however that the variable set is unique to each playbook. Unless I am doing sth wrong.

Can I somehow have this organization in my playbook.yml? Some ‘hacky’ thoughts I had about this were to “return” an all\_vars hash/dict from the first playbook that then I would pass to the others. Or before all the import\_playbook statements, actually have a play that will produce the variables and then pass them to the next ones. Note that the variables are a lot and passing them all one by one to each playbook would be ugly and not viable.

---

<div class="post-metadata">

**Author:** ![Nick\_Kakouros](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@Nick\_Kakouros](https://forum.ansible.com/u/Nick_Kakouros)\
**Post date:** [July 17, 2017, 6:41pm UTC](https://forum.ansible.com/t/import-playbook-and-variables/24999/2 "2017-07-17T18:41:58Z")

</div>

This was my misunderstanding of how Ansible uses variables. The variables are not unique to each playbook as I wrote, but to each host.
