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

**URL:** <https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323>\
**Category:** Ansible Project\
**Created:** [February 25, 2020, 2:07pm UTC](https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323 "2020-02-25T14:07:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_W](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@Nicolas\_W](https://forum.ansible.com/u/Nicolas_W)\
**Post date:** [February 25, 2020, 2:07pm UTC](https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323/1 "2020-02-25T14:07:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 25, 2020, 2:44pm UTC](https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323/2 "2020-02-25T14:44:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 25, 2020, 2:48pm UTC](https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323/3 "2020-02-25T14:48:31Z")

</div>

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

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Nicolas\_W](https://avatars.discourse-cdn.com/v4/letter/n/7993a0/32.png) [@Nicolas\_W](https://forum.ansible.com/u/Nicolas_W)\
**Post date:** [February 25, 2020, 3:15pm UTC](https://forum.ansible.com/t/ansible-and-yaml-syntax-there-appears-to-be-both-k-v-shorthand-syntax-and-yaml-in-this-task-only-one-syntax-may-be-used/32323/4 "2020-02-25T15:15:15Z")

</div>

Thanks for confirming the syntax looks ok.
