# Playbook templating done before loading group\_vars contents?

**URL:** <https://forum.ansible.com/t/playbook-templating-done-before-loading-group-vars-contents/19994>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 11, 2015, 10:48pm UTC](https://forum.ansible.com/t/playbook-templating-done-before-loading-group-vars-contents/19994 "2015-12-11T22:48:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandr\_Kurilin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Alexandr\_Kurilin](https://forum.ansible.com/u/Alexandr_Kurilin)\
**Post date:** [December 11, 2015, 10:48pm UTC](https://forum.ansible.com/t/playbook-templating-done-before-loading-group-vars-contents/19994/1 "2015-12-11T22:48:03Z")

</div>

Hey folks,

Ansible 1.9.2 here. I’ve been recently working on moving us over from static inventories to using the ec2 script. One constraint I have is that I separate different environments within the same AWS account by the Environment tag. In this case I’m working on Environment=dev, which in my file tree has its own folder (see tree at the bottom). The problem I’m having is that I can’t figure out how to set {{ env }} in my **- hosts:** from my all.yml file in group\_vars. It looks like group\_vars as NOT read at the time of the playbook yml file templating, but only afterwards. As an example, assuming this all.yml:

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [December 11, 2015, 10:58pm UTC](https://forum.ansible.com/t/playbook-templating-done-before-loading-group-vars-contents/19994/2 "2015-12-11T22:58:55Z")

</div>

group\_vars are applied to individual hosts and is not available globally without a host context. To use a variable for hosts it must be global and provided before parsing the play. Such as providing it via --extra-vars on the command line.

---

<div class="post-metadata">

**Author:** ![Alexandr\_Kurilin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Alexandr\_Kurilin](https://forum.ansible.com/u/Alexandr_Kurilin)\
**Post date:** [December 11, 2015, 11:02pm UTC](https://forum.ansible.com/t/playbook-templating-done-before-loading-group-vars-contents/19994/3 "2015-12-11T23:02:07Z")

</div>

Great, makes sense, thank you.
