ansible and yaml syntax - There appears to be both 'k=v' shorthand syntax and YAML in this task. Only one syntax may be used.

4,635 views
Skip to first unread message

Nicolas Wright

unread,
Feb 25, 2020, 9:07:52 AM2/25/20
to Ansible Project

Hello,

any clues what is a workaround for the syntax issue below? This variable is defined in a group among other variables. My playbook won't run because of this error. I may have to escape the =.. I m hoping to keep the string as human friendly as possible though. I am using quote so I can replace the password with a shared password variable.


here is the variable definition:

db_connectionstring: "User ID=myuser;Initial Catalog=mycatalog;Data Source=db\\instance;persist security info=True;password=mypass;Pooling=True"

The error

2020-02-25T14:01:13.6121920Z ##[error]ERROR! Syntax Error while loading YAML.
2020-02-25T14:01:13.6122859Z did not find expected key
2020-02-25T14:01:13.6123034Z
2020-02-25T14:01:13.6123401Z The error appears to be in '/var/lib/rundeck/ansible/inventories/vin_qa01/group_vars/all/vars.yml': line 66, column 42, but may
2020-02-25T14:01:13.6123829Z be elsewhere in the file depending on the exact syntax problem.
2020-02-25T14:01:13.6124028Z
2020-02-25T14:01:13.6124275Z The offending line appears to be:
2020-02-25T14:01:13.6124480Z
2020-02-25T14:01:13.6124871Z db_connectionstring_contentuser: "User ID=myuser;Initial Catalog=mycatalog;Data Source=db\\instance;persist security info=True;password=mypass;Pooling=True"
2020-02-25T14:01:13.6125323Z ^ here
2020-02-25T14:01:13.6125516Z
2020-02-25T14:01:13.6125847Z There appears to be both 'k=v' shorthand syntax and YAML in this task. Only one syntax may be used.
2020-02-25T14:01:13.6126232Z This one looks easy to fix. It seems that there is a value started
2020-02-25T14:01:13.6126600Z with a quote, and the YAML parser is expecting to see the line ended
2020-02-25T14:01:13.6126925Z with the same kind of quote. For instance:
2020-02-25T14:01:13.6127100Z
2020-02-25T14:01:13.6127359Z when: "ok" in result.stdout

any guidance vm appreciated!
-nic

Dick Visser

unread,
Feb 25, 2020, 9:44:32 AM2/25/20
to ansible...@googlegroups.com
There is nothing wrong with that variable.
As the error says, it may be elsewhere in the file depending on the
exact syntax problem.
In fact, it might not even be in
/var/lib/rundeck/ansible/inventories/vin_qa01/group_vars/all/vars.yml
(which you didn't post).
A clue is found here: 'There appears to be both 'k=v' shorthand syntax
and YAML in this task."
Tasks sit in a playbook - which you also didn't post.

There is nothing else to do with the information you provided.
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9e7de103-3a49-412c-bf07-b4fdee46ef87%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Vladimir Botka

unread,
Feb 25, 2020, 9:48:49 AM2/25/20
to Nicolas Wright, ansible...@googlegroups.com
On Tue, 25 Feb 2020 06:07:52 -0800 (PST)
Nicolas Wright <me.nicol...@gmail.com> wrote:

> db_connectionstring: "User ID=myuser;Initial Catalog=mycatalog;Data
> Source=db\\instance;persist security info=True;password=mypass;Pooling=True"
> [...]
> 2020-02-25T14:01:13.6121920Z ##[error]ERROR! Syntax Error while loading YAML.
> 2020-02-25T14:01:13.6122859Z did not find expected key
> [...]
> 2020-02-25T14:01:13.6123401Z The error appears to be in
> '/var/lib/rundeck/ansible/inventories/vin_qa01/group_vars/all/vars.yml':
> line 66, column 42,

It's not clear why and what key is YAML expecting. A review of complete
'group_vars/all/vars.yml' will be needed.

-vlado

Nicolas W

unread,
Feb 25, 2020, 10:15:16 AM2/25/20
to Ansible Project
Thanks for confirming the syntax looks ok. 
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages