# Syntax Error when using "new" variable substitution

**URL:** <https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690>\
**Category:** Ansible Project\
**Created:** [October 16, 2013, 9:38am UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690 "2013-10-16T09:38:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patric\_Buskas](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Patric\_Buskas](https://forum.ansible.com/u/Patric_Buskas)\
**Post date:** [October 16, 2013, 9:38am UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/1 "2013-10-16T09:38:18Z")

</div>

Hi,

I’m trying to copy files with “with\_fileglob” and using variable substitution.  
With this syntax it works but I get the “DEPRICATION WARNING”:

- name: copy configurations  
copy: src={{ item }} dest=/etc/app  
with\_fileglob:
- ${inventory\_hostname}/\*.conf

With this syntax I’m getting syntax error:

- name: copy configurations  
copy: src={{ item }} dest=/etc/app  
with\_fileglob:
- {{ inventory\_hostname }}/\*.conf

The message is:

ERROR: Syntax Error while loading YAML script, /path/to/ansible\_play/roles/client/tasks/main.yml  
Note: The error may actually appear before this position: line 9, column 31

with\_fileglob:

- {{ inventory\_hostname }}/\*.conf

What’s wrong?  
The deprication warning tells me to use {{ foo }} instead of ${foo} but I think something else is missing.

Thank You!

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [October 16, 2013, 9:49am UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/2 "2013-10-16T09:49:07Z")

</div>

​Deprecation warning is an ansible syntax, but here you get a YAML syntax  
error​. You need to write it as such;

&nbsp;&nbsp;with\_fileglob:  
&nbsp;&nbsp;&nbsp;&nbsp;- "{{ inventory\_hostname }}/\*.conf"

otherwise yaml expects a dict when it sees something starting with a {

Serge

---

<div class="post-metadata">

**Author:** ![Patric\_Buskas](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Patric\_Buskas](https://forum.ansible.com/u/Patric_Buskas)\
**Post date:** [October 16, 2013, 10:30am UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/3 "2013-10-16T10:30:32Z")

</div>

Thank You!  
I’ts working much better now 🙂

---

<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:** [October 16, 2013, 12:55pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/4 "2013-10-16T12:55:21Z")

</div>

Yeah, like Serge says, this is also not a deprecation warning.

If you are running 1.4, it does share some very nice new deprecation warnings, but this is a syntax error.

1.4 will suggest ways to address the problem in most cases which help make it more clear.

---

<div class="post-metadata">

**Author:** ![Patric\_Buskas](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Patric\_Buskas](https://forum.ansible.com/u/Patric_Buskas)\
**Post date:** [October 16, 2013, 1:49pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/5 "2013-10-16T13:49:55Z")

</div>

Yeah, I’m using 1.4 and the deprecation warning told me that I should use {{ foo }} instead of ${foo}.  
That’s great and if I’d know more about YAML syntax the problem wouldn’t appear.

Thank You!

---

<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:** [October 16, 2013, 2:07pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/6 "2013-10-16T14:07:16Z")

</div>

"The message is:

ERROR: Syntax Error while loading YAML script, /path/to/ansible\_play/roles/client/tasks/main.yml  
Note: The error may actually appear before this position: line 9, column 31"

Is that the full message?

Because the lines after that should suggest how to fix the problem if you scroll down.

Let me know if that is not there.

---

<div class="post-metadata">

**Author:** ![Patric\_Buskas](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Patric\_Buskas](https://forum.ansible.com/u/Patric_Buskas)\
**Post date:** [October 16, 2013, 3:15pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/7 "2013-10-16T15:15:04Z")

</div>

That together with the two next lines was the error message.  
I left out the ^-sign on the last line because of mail-format issues.

The ^-sign was located under the slash in

- {{ inventory\_hostname }}/\*.conf

When you don’t know YAML syntax til some extent, like me, that message doesn’t say much.

Thankfully, Serge could help me within minutes. 🙂

This is a wonderful community.

Cheers!

---

<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:** [October 16, 2013, 3:18pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/8 "2013-10-16T15:18:00Z")

</div>

Can you maybe share the output on pastebin and gist?

Would like to take a look to see if I can make that better.

Thanks!

---

<div class="post-metadata">

**Author:** ![Patric\_Buskas](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@Patric\_Buskas](https://forum.ansible.com/u/Patric_Buskas)\
**Post date:** [October 16, 2013, 3:24pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/9 "2013-10-16T15:24:18Z")

</div>

Sure,  
[http://pastebin.com/nPjLwXSh](http://pastebin.com/nPjLwXSh)

Thank You!

---

<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:** [October 16, 2013, 7:52pm UTC](https://forum.ansible.com/t/syntax-error-when-using-new-variable-substitution/13690/10 "2013-10-16T19:52:30Z")

</div>

I see, this is the case of a list item needing to be warned about, not a regular item.

Can you please file a github ticket?

I may not get to this but it would be nice to track the suggestion.
