# win\_shell failing since Ansible 2.5 (?)

**URL:** <https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [March 26, 2018, 11:25am UTC](https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115 "2018-03-26T11:25:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [March 26, 2018, 11:25am UTC](https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115/1 "2018-03-26T11:25:26Z")

</div>

My playbook is broken since i upgraded to v2.5

Here is the simplest example i have:

The code from my playbook:

`

- name: Install Winzip Package  
win\_shell: ‘cmd /C C:\Users\ansible\Downloads\install\_winzip.cmd’  
args:  
creates: ‘C:\Program Files\WinZip\WINZIP64.EXE’

`

Here is the output:

`

TASK [common : Install Winzip Package] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /ansible/scripts/roles/common/tasks/winzip.yml:11  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win\_shell.ps1  
\<hasgqba011.DOMAIN\> ESTABLISH WINRM CONNECTION FOR USER: ansible@DOMAIN on PORT 5986 TO hasgqba011.DOMAIN  
checking if winrm\_host hasgqba011.DOMAIN is an IPv6 address  
creating Kerberos CC at /tmp/tmpg3ejrJ  
calling kinit with subprocess for principal ansible@DOMAIN  
kinit succeeded for principal ansible@DOMAIN  
\<hasgqba011.DOMAIN\> WINRM CONNECT: transport=kerberos endpoint=[https://hasgqba011.DOMAIN:5986/wsman](https://hasgqba011.DOMAIN:5986/wsman)  
\<hasgqba011.DOMAIN\> WINRM OPEN SHELL: CCE2248A-9096-4242-B51C-9A1911DBBEE9  
EXEC (via pipeline wrapper)  
\<hasgqba011.DOMAIN\> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-ExecutionPolicy’, ‘Unrestricted’, ‘-’]  
\<hasgqba011.DOMAIN\> WINRM RESULT u’\<Response code 1, out “”, err “Test-AnsiblePath : E”\>’  
\<hasgqba011.DOMAIN\> WINRM CLOSE SHELL: CCE2248A-9096-4242-B51C-9A1911DBBEE9  
fatal: [hasgqba011.DOMAIN]: FAILED! =\> {  
“changed”: false,  
“module\_stderr”: “Test-AnsiblePath : Exception calling "GetAttributes" with "1" argument(s): "Could not find a part of the path \r\n’C:\Program Files\WinZip\WINZIP64.EXE’."\r\nAt line:59 char:21\r\n+ if ($creates -and $(Test-AnsiblePath -Path $creates)) {\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \r\n + CategoryInfo : NotSpecified: (🙂 [Test-AnsiblePath], MethodInvocationException\r\n + FullyQualifiedErrorId : DirectoryNotFoundException,Test-AnsiblePath\r\n \r\n\r\n”,  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE”,  
“rc”: 1  
}

`

I want to install winzip if the file winzip64.exe is not found, and it fails because it’s not found.  
Removing the args/creates lines → works like a charm.

Thanks.

---

<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:** [March 26, 2018, 11:03pm UTC](https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115/2 "2018-03-26T23:03:23Z")

</div>

Thanks for the report, I am able to replicate this on 2.5 and have raised a Github issue for it [https://github.com/ansible/ansible/issues/37967](https://github.com/ansible/ansible/issues/37967).

The issue is the path `C:\Program Files\WinZip` does not exist and the Test-AnsiblePath method is throwing a different exception in this case which we should be catching. If ‘C:\Program Files\WinZip’ did exist, then this would still continue to work but alas it isn’t.

I know how to fix it but unfortunately we don’t have a workaround apart either

- Creating the parent directory in a previous task
- Using a custom win\_shell module that did not use Ansible.ModuleUtils.FileUtil or stay on the previous version until this is fixed.

Thanks

Jordan

---

<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:** [March 26, 2018, 11:50pm UTC](https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115/3 "2018-03-26T23:50:04Z")

</div>

Sidenote: here is the PR to fix this issue [https://github.com/ansible/ansible/pull/37968](https://github.com/ansible/ansible/pull/37968)

---

<div class="post-metadata">

**Author:** ![Jeremie\_Levy](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jeremie\_Levy](https://forum.ansible.com/u/Jeremie_Levy)\
**Post date:** [March 27, 2018, 10:01am UTC](https://forum.ansible.com/t/win-shell-failing-since-ansible-2-5/27115/4 "2018-03-27T10:01:33Z")

</div>

Thanks Jordan!  
I am able to bypass this issue by checking the directory with win\_stat and use a register as a condition for the win\_shell.  
I noticed the handlers are now working which is great 🙂

Thanks again!
