# How to set environment dynamically

**URL:** <https://forum.ansible.com/t/how-to-set-environment-dynamically/27616>\
**Category:** Ansible Project\
**Created:** [May 24, 2018, 5:35pm UTC](https://forum.ansible.com/t/how-to-set-environment-dynamically/27616 "2018-05-24T17:35:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Villasmil](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@David\_Villasmil](https://forum.ansible.com/u/David_Villasmil)\
**Post date:** [May 24, 2018, 5:35pm UTC](https://forum.ansible.com/t/how-to-set-environment-dynamically/27616/1 "2018-05-24T17:35:35Z")

</div>

Hello Guys,

So, i have a vars file with something like this:

`

---

<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:** [May 24, 2018, 5:40pm UTC](https://forum.ansible.com/t/how-to-set-environment-dynamically/27616/2 "2018-05-24T17:40:50Z")

</div>

The easiest thing for you to do would be to nest aws\_740 and aws\_756 under a parent key, maybe called “aws\_env”.

Then you can use: environment: “{{ aws\_env[account] }}”
