# Ansible quoting

**URL:** <https://forum.ansible.com/t/ansible-quoting/16559>\
**Category:** Ansible Project\
**Created:** [October 20, 2014, 4:21pm UTC](https://forum.ansible.com/t/ansible-quoting/16559 "2014-10-20T16:21:55Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Michael\_Perzel](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Michael\_Perzel](https://forum.ansible.com/u/Michael_Perzel)\
**Post date:** [February 23, 2015, 9:54pm UTC](https://forum.ansible.com/t/ansible-quoting/16559/21 "2015-02-23T21:54:12Z")

</div>

Victory! I’ll add a few tests for invalid data and send in a pull request.

TEST\_FLAGS=“-t test\_powershell\_filter -i /etc/ansible/hosts” make test\_winrm  
ansible-playbook test\_winrm.yml -i inventory.winrm -e @integration\_config.yml -v -t test\_powershell\_filter -i /etc/ansible/hosts  
[WARNING]: The version of gmp you have installed has a known issue regarding  
timing vulnerabilities when used with pycrypto. If possible, you should update  
it (i.e. yum update gmp).

PLAY [windows] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [test\_powershell\_filter | Convert yaml dict to powershell hash] \*\*\*\*\*\*\*\*\*  
changed: [mdm-wsrv98.surescripts-dev.qa → 127.0.0.1] =\> {“changed”: true, “cmd”: “echo ‘@{‘This’=‘THIS’;‘Other’=‘OTHER’;‘That’=‘THAT’;}’”, “delta”: “0:00:00.003494”, “end”: “2015-02-23 15:52:47.477128”, “rc”: 0, “start”: “2015-02-23 15:52:47.473634”, “stderr”: “”, “stdout”: “@{This=THIS;Other=OTHER;That=THAT;}”, “warnings”: }

TASK: [test\_powershell\_filter | Check that actual equals expected] \*\*\*\*\*\*\*\*\*\*\*\*  
ok: [mdm-wsrv98.surescripts-dev.qa] =\> {“msg”: “all assertions passed”}

---

<div class="post-metadata">

**Author:** ![Michael\_Perzel](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Michael\_Perzel](https://forum.ansible.com/u/Michael_Perzel)\
**Post date:** [February 24, 2015, 6:29pm UTC](https://forum.ansible.com/t/ansible-quoting/16559/22 "2015-02-24T18:29:23Z")

</div>

I updated the test\_win\_script role in my fork to use the filter and confirm the output matches the expected results.

---

<div class="post-metadata">

**Author:** ![Michael\_Perzel](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Michael\_Perzel](https://forum.ansible.com/u/Michael_Perzel)\
**Post date:** [August 3, 2015, 7:43pm UTC](https://forum.ansible.com/t/ansible-quoting/16559/23 "2015-08-03T19:43:25Z")

</div>

I recently upgrade to ansible 1.9.2 and am now having issues with the splatting. I looked at [https://github.com/cchurch/ansible/blob/e9b6aaf5d8836ce7ffdca855e006c2131fe19632/lib/ansible/runner/shell\_plugins/powershell.py](https://github.com/cchurch/ansible/blob/e9b6aaf5d8836ce7ffdca855e006c2131fe19632/lib/ansible/runner/shell_plugins/powershell.py) since that fixed it last time. THe only change that wasn’t still there was in powershell.py. I made the following change and it works now. I haven’t gone back to debug closer to see what the difference is.

def \_build\_file\_cmd(cmd\_parts, quote\_args=True):  
‘’‘Build command line to run a file, given list of file name plus args.’‘’  
if quote\_args:  
cmd\_parts = [‘“%s”’ % x for x in cmd\_parts]  
#return ’ ‘.join(\_common\_args + [’-ExecutionPolicy’, ‘Unrestricted’, ‘-File’] + cmd\_parts)  
return ’ ‘.join([’&'] + cmd\_parts)

Before the change this was the output:  
TASK: [windowsDeploy | Call deploy.ps1] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* changed: [hostname] =\> {“changed”: true, “rc”: 0, “stderr”: “C:\Users\l\_ansible\AppData\Local\Temp\ansible-tmp-1438627351.4-181936062454137\\r\nwrapper.ps1 : Cannot process argument transformation on parameter \r\n’installArguments’. Cannot convert the "System.Collections.Hashtable" value of \r\ntype "System.String" to type "System.Collections.Hashtable".\r\n + CategoryInfo : InvalidData: (🙂 [wrapper.ps1], ParentContainsEr \r\n rorRecordException\r\n + FullyQualifiedErrorId : ParameterArgumentTransformationError,wrapper.ps1\r\n \r\n”, “stdout”: “”}

I set the debug higher to see the splatted argument and verified it is a correct powershell array/hash. I can fill out an issue at github but thought this would be a good start.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 3, 2015, 9:56pm UTC](https://forum.ansible.com/t/ansible-quoting/16559/24 "2015-08-03T21:56:55Z")

</div>

Worth trying current dev if you can as I think the way parameters are passed has changed.

All the best, Jon

---

<div class="post-metadata">

**Author:** ![Ard-Jan\_Barnas](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@Ard-Jan\_Barnas](https://forum.ansible.com/u/Ard-Jan_Barnas)\
**Post date:** [August 5, 2015, 2:28am UTC](https://forum.ansible.com/t/ansible-quoting/16559/25 "2015-08-05T02:28:25Z")

</div>

I had the same problem and made the change below to fix the issue.

---

<div class="post-metadata">

**Author:** ![Michael\_Perzel](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@Michael\_Perzel](https://forum.ansible.com/u/Michael_Perzel)\
**Post date:** [August 5, 2015, 10:07pm UTC](https://forum.ansible.com/t/ansible-quoting/16559/26 "2015-08-05T22:07:34Z")

</div>

How did you solve the issue (what did you mean by below)? I haven't had time to look into the root cause of this yet.

[Previous page](https://forum.ansible.com/t/ansible-quoting/16559.md?page=1)
