# Syntax error after ansible update (latest)

**URL:** <https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384>\
**Category:** Ansible Project\
**Created:** [April 26, 2018, 11:47am UTC](https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384 "2018-04-26T11:47:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbmprivat](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nbmprivat](https://forum.ansible.com/u/nbmprivat)\
**Post date:** [April 26, 2018, 11:47am UTC](https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384/1 "2018-04-26T11:47:25Z")

</div>

Hi,

My playbook is not working anymore after updating ansible to latest version.

For example:

- Vault file containing variable with value  
`vault_win_password: foo20"`

- Variable with value

`location: C:\Program files (x86)\bar`

Task:

`

- name: Test login  
script: “{{ role\_path }}/files/portal.ps1 {{ dbuser }} {{ vault\_win\_password }}”

`

Error:

`

The full traceback is:  
Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/ansible-2.5.1-py2.7.egg/ansible/executor/task\_executor.py”, line 138, in run  
res = self.\_execute()  
File “/usr/local/lib/python2.7/dist-packages/ansible-2.5.1-py2.7.egg/ansible/executor/task\_executor.py”, line 558, in \_execute  
result = self.\_handler.run(task\_vars=variables)  
File “/usr/local/lib/python2.7/dist-packages/ansible-2.5.1-py2.7.egg/ansible/plugins/action/script.py”, line 79, in run  
parts = [to\_text(s, errors=‘surrogate\_or\_strict’) for s in shlex.split(raw\_params.strip())]  
File “/usr/lib/python2.7/shlex.py”, line 279, in split  
return list(lex)  
File “/usr/lib/python2.7/shlex.py”, line 269, in next  
token = self.get\_token()  
File “/usr/lib/python2.7/shlex.py”, line 96, in get\_token  
raw = self.read\_token()  
File “/usr/lib/python2.7/shlex.py”, line 172, in read\_token  
raise ValueError, “No closing quotation”  
ValueError: No closing quotation

fatal: [sj-aio01]: FAILED! =\> {  
“msg”: “Unexpected failure during module execution.”,  
“stdout”: “”  
}

`

`

- name: Test location  
script: “{{ role\_path }}/files/file.ps1 {{ location}}”

`

`

fatal: [sj-can02]: FAILED! =\> {  
“changed”: true,  
“msg”: “non-zero return code”,  
“rc”: 1,  
“stderr”: “x86 : The term ‘x86’ is not recognized as the name of a cmdlet, function, \r\nscript file, or operable program. Check the spelling of the name, or if a path \r\nwas included, verify that the path is correct and try again.\r\nAt line:1 char:122\r\n+ … 42148.17-152711404220483\cannister.ps1’ C:\Program Files (x86)\IBM\IB …\r\n+ ~~~\r\n + CategoryInfo : ObjectNotFound: (x86:String) , CommandNotFound \r\n Exception\r\n + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\n\r\n”,  
“stdout”: “”,  
“stdout\_lines”:   
}

`

Before updating this worked.

`

- name: Test location  
script: “{{ role\_path }}/files/file.ps1 '{{ location}}'”

`

Now says:

`

ERROR! Syntax Error while loading YAML.  
found unknown escape character “'”

`

How am I supposed to pass along parameters when ansible does not understand the values anymore?

---

<div class="post-metadata">

**Author:** ![nbmprivat](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nbmprivat](https://forum.ansible.com/u/nbmprivat)\
**Post date:** [April 26, 2018, 11:56am UTC](https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384/2 "2018-04-26T11:56:17Z")

</div>

Also tried using single quotes but get this error:

`  
fatal: [sj-aio01]: FAILED! =\> {“msg”: “template error while templating string: unexpected char u’"’ at 10. String: {{foo20"}}”}

`

Super annoying.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [April 26, 2018, 8:38pm UTC](https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384/3 "2018-04-26T20:38:42Z")

</div>

Your issue is that one of your arguments contains a " and when shlex tries to split the arguments as a list it fails to find the end ". E.g the value of script you set is

` `  
script: “{{ role\_path }}/files/portal.ps1 {{ dbuser }} {{ vault\_win\_password }}”

# when taking away Jinja2 this becomes

script: /some/path/files/portal.ps1 user foo20"

` `  
`When trying to turn the string to a list of arguments ([portal.ps1", "user", "foo20\""]), it fails to find the end quote for the password quote. What you need to do is use the quote filter to automatically quote each argument, e.g.`

` `  
script: “{{ role\_path }}/files/portal.ps1 {{ dbuser|quote }} {{ vault\_win\_password|quote }}”

# if you wanted to do it manually without the quote filter (please don’t)

script: “{{ role\_path }}/files/portal.ps1 ‘{{ dbuser }}’ ‘{{ vault\_win\_password }}’”

# when taking away Jinja2 this become

script: /some/path/files/portal.ps1 “user” “foo20"”

` `  
`This means each argument is quoted so shlex can split them into a list without any issues.`

`You second issue also comes down to quotes, when interpreting this`

` `  
script: “{{ role\_path }}/files/file.ps1 {{ location }}”

# this is seen by Ansible as

script: /some/path/files/portal.ps1 C:\Program Files (x86)\bar

` `  
`When running in Windows, it sees this as 3 different arguments; ["C:\Program", "Files", "(x86)\bar"] as it is not quoted. PowerShell makes this a bit more complex, the 3rd argument (x86)\bar, PowerShell see the brackets and things the value inside is a command and so tries to run it which in turn leads to the error x86 is not recognized as the name of a cmdlet, function... The fix for this is the same as your previous issue, use the quote filter to quote the values`

` `  
script: “{{ role\_path }}/files/file.ps1 {{ location }}”

# without using the quote filter this is how it can be done (once again please don’t this is just to illustrate how it could be done)

script: “{{ role\_path }}/files/file.ps1 "{{ location }}"”

# or

script: “{{ role\_path }}/files/file.ps1 ‘{{ location }}’”

# this is seen by Ansible as

script: /some/path/files/portal.ps1 “C:\Program Files (x86)\bar”

` `  
`Now because the path is quoted, it is seen as 1 argument instead of 3.`

`Thanks`

`Jordan`

---

<div class="post-metadata">

**Author:** ![nbmprivat](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nbmprivat](https://forum.ansible.com/u/nbmprivat)\
**Post date:** [April 30, 2018, 7:23am UTC](https://forum.ansible.com/t/syntax-error-after-ansible-update-latest/27384/4 "2018-04-30T07:23:14Z")

</div>

Thank you very much Jordan. That helped!

Much appreciated!!!
