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!
Deprecation warning is an ansible syntax, but here you get a YAML syntax
error. You need to write it as such;
with_fileglob:
- "{{ inventory_hostname }}/*.conf"
otherwise yaml expects a dict when it sees something starting with a {
Serge
Thank You!
I’ts working much better now
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.
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!
"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.
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!
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!
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.