# ERROR: win\_file is not a legal parameter in an Ansible task or handler

**URL:** <https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455>\
**Category:** Ansible Project\
**Tags:** windows, aws\
**Created:** [June 10, 2015, 3:58am UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455 "2015-06-10T03:58:02Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 10, 2015, 3:58am UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/1 "2015-06-10T03:58:02Z")

</div>

Running Ansible v1.9.1 under MacOSX 10.10.3

Trying to use Ansible to configure Windows Server 2008 and am having some basic problem.  
The server is running on Amazon AWS. I’ve got all the connection stuff working fine.  
This (mostly empty) Ansible playbook runs fine:

`

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [June 10, 2015, 4:12am UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/2 "2015-06-10T04:12:08Z")

</div>

Hi,

How did you install ansible, if it is a checkout did you --recursive to add the submodules ? seems like ansible is not able to see the modules in the modules path.

---

<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:** [June 10, 2015, 5:54am UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/3 "2015-06-10T05:54:07Z")

</div>

Actually win\_copy and win\_file were not included in 1.9.1. They are in 1.9.2 rc1 but there were a couple of issues with win\_copy for which I have made fixes. I hope these will be incorporated into 1.9.2 rc2.

Jon

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 10, 2015, 12:19pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/4 "2015-06-10T12:19:31Z")

</div>

I’ve been installing Ansible using pip, e.g. “sudo pip install --upgrade ansible”

By the way, if the only task I have is this one:

`  
tasks:

- win\_chocolatey:  
name: PSWindowsUpdate  
state: present  
`

I get this error:

ERROR: state is not a legal parameter in an Ansible task or handler

I can’t get any of the Windows tasks to work, but the Linux stuff works fine.

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 10, 2015, 12:23pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/5 "2015-06-10T12:23:53Z")

</div>

I think these might be the relevant module directories on my Mac:

`$ ls /Library/Python/2.7/site-packages/ansible/modules/core/windows __init__.py win_feature.ps1 win_get_url.py win_group.pyc win_ping.ps1 win_service.py win_stat.pyc __init__.pyc win_feature.py win_get_url.pyc win_msi.ps1 win_ping.py win_service.pyc win_user.ps1 setup.ps1 win_feature.pyc win_group.ps1 win_msi.py win_ping.pyc win_stat.ps1 win_user.py slurp.ps1 win_get_url.ps1 win_group.py win_msi.pyc win_service.ps1 win_stat.py win_user.pyc`

AND

`$ ls /Library/Python/2.7/site-packages/ansible/modules/extras/windows __init__.py win_chocolatey.ps1 win_chocolatey.pyc win_updates.py __init__.pyc win_chocolatey.py win_updates.ps1 win_updates.pyc`

---

<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:** [June 10, 2015, 12:43pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/6 "2015-06-10T12:43:33Z")

</div>

I don’t have a mac to try this out on but it seems you aren’t picking up your modules.

I did a quick search and I found a couple of threads that might be relevant:

[https://github.com/ansible/ansible/issues/5412](https://github.com/ansible/ansible/issues/5412)

[https://groups.google.com/forum/#!topic/ansible-project/Px4DyaHwD3I](https://groups.google.com/forum/#!topic/ansible-project/Px4DyaHwD3I)

I suggest

1/ trying a clean ansible installation, if possible  
2/ checking your playbook for invalid yaml (use a yaml-aware text editor like notepad++ or [www.yamllint.com](http://www.yamllint.com))

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 10, 2015, 1:51pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/7 "2015-06-10T13:51:05Z")

</div>

I did “sudo pip uninstall ansible” and then “sudo pip install ansible”. Made no difference.

[yamllint.com](http://yamllint.com) says that my ansible script is valid.

I’m stumped.

J

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 10, 2015, 4:22pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/8 "2015-06-10T16:22:45Z")

</div>

Ok. I filed a documentation bug on the two windows modules which are not in Ansible 1.9.1 (but the docs don’t mention that):  
[https://github.com/ansible/ansible/issues/11220](https://github.com/ansible/ansible/issues/11220)

After some further testing, it appears that the windows modules in the “core/windows” directory  
work ok. However, the windows modules in the “extras/windows” directory don’t seem to be loading.

Is my search path correct?

`$ ansible --version ansible 1.9.1 configured module search path = /Library/Python/2.7/site-packages/ansible/modules/core:/Library/Python/2.7/site-packages/ansible/modules/extras`

-J

---

<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:** [June 10, 2015, 8:29pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/9 "2015-06-10T20:29:45Z")

</div>

Have you set the module search path by modifying your ansible.cfg?

My 1.9.1 install shows

configured module search path = None

unless I set a library= value in my ansible.cfg (maybe cos I originally installed from yum though).

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 11, 2015, 2:14am UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/10 "2015-06-11T02:14:15Z")

</div>

It originally said “path = None” but I then explicitly set the path. It didn’t make  
a difference. Still broken. Are you able to access update and chocolatey?

J

---

<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:** [June 11, 2015, 4:02pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/11 "2015-06-11T16:02:59Z")

</div>

I haven’t tried chocolatey but I can get win\_updates to execute. But my ansible was installed via yum and I’m not on a mac.

It does feel like something is stopping ansible from finding parts of itself. Have you upgraded from an older ansible version (or did you start with a fresh 1.9.1 install the first time)? Have you ever also pulled directly from github?

Jon

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 11, 2015, 4:27pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/12 "2015-06-11T16:27:51Z")

</div>

If you look back through this thread, you’ll see that I unistalled and then reinstalled Ansible. It didn’t change anything.  
The core windows modules work, but not the windows modules in extras.

J

---

<div class="post-metadata">

**Author:** ![Jake\_Dupuy](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@Jake\_Dupuy](https://forum.ansible.com/u/Jake_Dupuy)\
**Post date:** [June 11, 2015, 4:37pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/13 "2015-06-11T16:37:59Z")

</div>

I’ve got a similar issue, I need to get win\_file working for one of my plays. Sounds like upgrade to 1.9.2 should do the trick?

---

<div class="post-metadata">

**Author:** ![Jason\_Levitt](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@Jason\_Levitt](https://forum.ansible.com/u/Jason_Levitt)\
**Post date:** [June 11, 2015, 4:40pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/14 "2015-06-11T16:40:38Z")

</div>

Since v1.9.2 is not released yet, is there a way to use pip to upgrade to the latest development version of 1.9.2?

J

---

<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:** [June 11, 2015, 5:35pm UTC](https://forum.ansible.com/t/error-win-file-is-not-a-legal-parameter-in-an-ansible-task-or-handler/18455/15 "2015-06-11T17:35:23Z")

</div>

I think latest devel is only available by cloning from github.

I am hoping there will be a 1.9.2 release candidate 2 soon which might include these modules.

Jon
