# variable isn't expanded correctly?

**URL:** <https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934>\
**Category:** Ansible Project\
**Created:** [April 3, 2014, 4:42pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934 "2014-04-03T16:42:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dario\_Bertini](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dario\_Bertini](https://forum.ansible.com/u/Dario_Bertini)\
**Post date:** [April 3, 2014, 4:42pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/1 "2014-04-03T16:42:29Z")

</div>

Hi, I have a variable set up like this:

ansible\_ssh\_user: “{{ lookup(‘env’, ‘USER’) }}”

all the commands execute fine, until I get to the point where I want to use the synchronize module, where it fails with:

failed: [vmArServer] =\> {“failed”: true, “item”: “”}  
msg: this module requires key=value arguments ([‘src=…/…/frontEnd/\*’, ‘private\_key=/home/dario/.vagrant.d/insecure\_private\_key’, ‘dest\_port=22’, ‘recursive=yes’, ‘dest={{lookup(env,’, ‘USER)}}@10.0.46.164:/var/www/nginx’, ‘delete=yes’, ‘archive=yes’, ‘rsync\_path=sudo rsync’])

If I change ansible\_ssh\_user, hardcoding it with my user, it works fine… but “”“{{lookup(env,', 'USER)}}”“” seems really weird: it almost looks like there would be some extra quotes around my lookup, but I reckon that would trigger an error much earlier

Has anyone seen something like this?

Thanks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [April 4, 2014, 4:51am UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/2 "2014-04-04T04:51:06Z")

</div>

i don’t think the connection module templates that value, also USER would already be the default if you don’t specify anything.

---

<div class="post-metadata">

**Author:** ![Dario\_Bertini](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dario\_Bertini](https://forum.ansible.com/u/Dario_Bertini)\
**Post date:** [April 4, 2014, 8:56am UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/3 "2014-04-04T08:56:52Z")

</div>

You’re right, anyhow this is a regression introduced with ansible 1.5.0

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 4, 2014, 3:13pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/4 "2014-04-04T15:13:22Z")

</div>

“You’re right, anyhow this is a regression introduced with ansible 1.5.0”

(A) I don’t think we can say any possible behavior where something strange used to work and doesn’t is a regression, unless that behavior was either documented or had a unit test for it.

(B) This variable really ought to be templated at an earlier level anyway.

---

<div class="post-metadata">

**Author:** ![Dario\_Bertini](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dario\_Bertini](https://forum.ansible.com/u/Dario_Bertini)\
**Post date:** [April 4, 2014, 3:23pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/5 "2014-04-04T15:23:37Z")

</div>

Agree, is there something I could to do force the templating early, or  
is it something that can be done only inside ansible itself?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 4, 2014, 3:24pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/6 "2014-04-04T15:24:29Z")

</div>

Not without modifying the source to fix the root cause of the problem.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 4, 2014, 3:24pm UTC](https://forum.ansible.com/t/variable-isnt-expanded-correctly/14934/7 "2014-04-04T15:24:42Z")

</div>

BTW, please make sure there’s a ticket filed for this.

Thanks!
