# Making environment variables visible in the remote session

**URL:** <https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419>\
**Category:** Ansible Project\
**Created:** [February 25, 2013, 12:58pm UTC](https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419 "2013-02-25T12:58:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Hood](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Ben\_Hood](https://forum.ansible.com/u/Ben_Hood)\
**Post date:** [February 25, 2013, 12:58pm UTC](https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419/1 "2013-02-25T12:58:49Z")

</div>

Hi,

I’m trying to invoke the route53 command as part of a playbook - this requires access to the AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY environment variables.

Is there a way to tell ansible to take the exported variables from the local shell and export them to the remote shell when the playbook is run?

Thanks,

Ben

---

<div class="post-metadata">

**Author:** ![Ben\_Hood](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Ben\_Hood](https://forum.ansible.com/u/Ben_Hood)\
**Post date:** [February 25, 2013, 1:07pm UTC](https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419/2 "2013-02-25T13:07:16Z")

</div>

For note, I’ve tried to set the environment explicitly, e.g.

- name: Update DNS  
action: shell change\_record $r53\_zone graphite.$domain CNAME $inventory\_hostname  
environment:  
AWS\_ACCESS\_KEY\_ID: $ENV(AWS\_ACCESS\_KEY\_ID)

But I’m not sure that I’m using the environment keyword in the correct stanza, as this error indicates:

ERROR: environment is not a legal parameter in an Ansible task or handler

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![Daniel\_Hokka\_Zakriss](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Daniel\_Hokka\_Zakriss](https://forum.ansible.com/u/Daniel_Hokka_Zakriss)\
**Post date:** [February 25, 2013, 1:12pm UTC](https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419/3 "2013-02-25T13:12:56Z")

</div>

Ben Hood wrote:

> > I'm trying to invoke the route53 command as part of a playbook - this  
> > requires access to the AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY  
> > environment variables.
> > 
> > Is there a way to tell ansible to take the exported variables from the  
> > local shell and export them to the remote shell when the playbook is  
> > run?
> 
> For note, I've tried to set the environment explicitly, e.g.
> 
> - name: Update DNS  
> &nbsp;&nbsp;action: shell change\_record $r53\_zone graphite.$domain CNAME  
> $inventory\_hostname  
> &nbsp;&nbsp;environment:  
> AWS\_ACCESS\_KEY\_ID: $ENV(AWS\_ACCESS\_KEY\_ID)
> 
> But I'm not sure that I'm using the environment keyword in the correct  
> stanza, as this error indicates:
> 
> ERROR: environment is not a legal parameter in an Ansible task or handler
> 
> What am I doing wrong here?

Looks correct. Are you sure you are using a recent version of ansible, i.e.  
devel? environment: is new in 1.1.

Daniel

---

<div class="post-metadata">

**Author:** ![Ben\_Hood](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Ben\_Hood](https://forum.ansible.com/u/Ben_Hood)\
**Post date:** [February 25, 2013, 1:19pm UTC](https://forum.ansible.com/t/making-environment-variables-visible-in-the-remote-session/12419/4 "2013-02-25T13:19:52Z")

</div>

Daniel,
