# 1.2.2 variable reference syntax

**URL:** <https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310>\
**Category:** Ansible Project\
**Created:** [August 15, 2013, 2:34am UTC](https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310 "2013-08-15T02:34:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Armit](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Scott\_Armit](https://forum.ansible.com/u/Scott_Armit)\
**Post date:** [August 15, 2013, 2:34am UTC](https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310/1 "2013-08-15T02:34:46Z")

</div>

Hello. I’m running Ansible 1.2.2 (seeing the below behavior on OSX and CentOS 6.4). My understanding is that in 1.2+, I can use {{ var }} syntax _everywhere_. In a role task I have this:

- copy:  
src=“jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”  
dest=“{{ tmp\_dir }}/jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”

The vars are specified in main.yml inside the same role. However, I get an error:

msg: Destination directory {{tmp\_dir}} does not exist

If I change the “copy:” action to:

- copy:  
src=“jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”  
dest=“${tmp\_dir}/jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”

… the error goes away and all is well. Maybe this is a bug, okay, but I’m looking to find out if I’ve misunderstood the new syntax.

Thank you for any information.  
-Scott

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 12:35pm UTC](https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310/2 "2013-08-15T12:35:07Z")

</div>

This is not how you do multiline copies. I’m not sure where you picked this up, but it looks like this if you want a line continuation.

- copy: \>  
src=“jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”  
dest=“{{ tmp\_dir }}/jdk-{{ oraclejdk\_version }}-linux-amd64.rpm”

Furthermore, the failure of your variable to evaluate is probably because the other variable didn’t substitute. Ansible probably couldn’t template something else on the line.

---

<div class="post-metadata">

**Author:** ![Scott\_Armit](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Scott\_Armit](https://forum.ansible.com/u/Scott_Armit)\
**Post date:** [August 15, 2013, 2:01pm UTC](https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310/3 "2013-08-15T14:01:56Z")

</div>

Thank you Michael. It was indeed the multi-line syntax error. Once I properly added the “copy: \>” for multi-line, I was able to use the new variable syntax successfully.

It’s a little surprising that with incorrect multi-line syntax using the old variable syntax ${} masked the actual error. Regardless, I have a fix. Thanks for the fast reply.

---

<div class="post-metadata">

**Author:** ![Andy1](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Andy1](https://forum.ansible.com/u/Andy1)\
**Post date:** [August 15, 2013, 2:43pm UTC](https://forum.ansible.com/t/1-2-2-variable-reference-syntax/13310/4 "2013-08-15T14:43:16Z")

</div>

> This is not how you do multiline copies. I’m not sure where you picked this up, but it looks like this if you want a line continuation.

It was suggested in this thread:  
[https://groups.google.com/d/msg/ansible-project/EDXIk3WM7vk/Rx6mibjQvrcJ](https://groups.google.com/d/msg/ansible-project/EDXIk3WM7vk/Rx6mibjQvrcJ)

I think some more documentation on this would be great.
