# $ENV() returns array

**URL:** <https://forum.ansible.com/t/env-returns-array/12420>\
**Category:** Ansible Project\
**Created:** [February 25, 2013, 1:29pm UTC](https://forum.ansible.com/t/env-returns-array/12420 "2013-02-25T13:29:24Z")\
**Posts on this page:** 5\
**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, 1:29pm UTC](https://forum.ansible.com/t/env-returns-array/12420/1 "2013-02-25T13:29:24Z")

</div>

Hi,

By default, reading an environment variable using $ENV(NAME) appears to return an array of strings. Is there a way to coerce $ENV(NAME) into a simple string?

Cheers,

Ben

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 25, 2013, 1:37pm UTC](https://forum.ansible.com/t/env-returns-array/12420/2 "2013-02-25T13:37:12Z")

</div>

This is fixed on 1.1

80%+ of everyone runs the development branch out of checkout (I know,  
it's strange! But it works!) so you're free to do the same if you  
want.

---

<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:49pm UTC](https://forum.ansible.com/t/env-returns-array/12420/3 "2013-02-25T13:49:48Z")

</div>

My clone of the ansible upstream is at 50c1c06088 on the devel branch and I am still getting the array behavior doing the following:

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

When this is executed, the env vars are correctly read out of the current shell into the remote shell, albeit as arrays.

You mentioned a 1.1 - is this just the name of the milestone that you will cut when it is ready, or is there actually a HEAD on Github that I am missing?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 25, 2013, 2:15pm UTC](https://forum.ansible.com/t/env-returns-array/12420/4 "2013-02-25T14:15:38Z")

</div>

This happens to work fine:

&nbsp;&nbsp;&nbsp;- shell: echo $ENV(HOME)

So it's more of a case of using the macro within the environment  
keyword that we need to fix, which is this:

&nbsp;&nbsp;- shell: echo $FOO  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;environment:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FOO: $ENV(HOME)

I'll file a ticket.

I'm referring to HEAD in git, yes.

---

<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, 3:03pm UTC](https://forum.ansible.com/t/env-returns-array/12420/5 "2013-02-25T15:03:25Z")

</div>

Thanks for looking into this. For now, I think I can probably hack something together to get this going.
