# Ansible 1.8.2 custom windows powershell module defined in roles/myrole/library is not found (ERROR: mymodule is not a legal parameter in an Ansible task or handler)

**URL:** <https://forum.ansible.com/t/ansible-1-8-2-custom-windows-powershell-module-defined-in-roles-myrole-library-is-not-found-error-mymodule-is-not-a-legal-parameter-in-an-ansible-task-or-handler/17504>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 11, 2015, 6:15pm UTC](https://forum.ansible.com/t/ansible-1-8-2-custom-windows-powershell-module-defined-in-roles-myrole-library-is-not-found-error-mymodule-is-not-a-legal-parameter-in-an-ansible-task-or-handler/17504 "2015-02-11T18:15:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_Clegg](https://avatars.discourse-cdn.com/v4/letter/i/6bbea6/32.png) [@Ian\_Clegg](https://forum.ansible.com/u/Ian_Clegg)\
**Post date:** [February 11, 2015, 6:15pm UTC](https://forum.ansible.com/t/ansible-1-8-2-custom-windows-powershell-module-defined-in-roles-myrole-library-is-not-found-error-mymodule-is-not-a-legal-parameter-in-an-ansible-task-or-handler/17504/1 "2015-02-11T18:15:35Z")

</div>

Hi everyone,

I wonder if anyone has hit this issue. I just upgraded to ansible 1.8.2 and a set of windows playbooks is no longer working. These playbooks _do_ work with the previous version we had; there seem to be some issues around this at the moment.

The problem appears to be related to how ansible locates custom powershell modules defined in a roles library.

Lets look at how the play is laid out, its quite simple:

**/roles/myrole/tasks/main.yml**

- name: Run my custom module  
mymodule: myparam=‘hello world’

**/roles/myrole/library/mymodule.ps1**  
… a custom powershell module

**/myplay.yml**

- name: MYROLE  
hosts: my-servers  
gather\_facts: no  
vars\_files:
- “{{versions\_vars\_file}}”
- “{{environment\_vars\_file}}”  
roles:
- myrole

lets invoke ansible:  
ansible-playbook -i inventory myplay.yml -c winrm

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

This worked in 1.7.x

I should point out that I am setting both ‘ansible\_connection’ to winrm and passing ‘-c winrm’ in the command line. I would expect powershell modules to be found.

This seems to be a bug in how find\_plugin() in /ansible/utils/plugins.py is invoked. When I patched the function to log the value of transport parameter I got:

transport: [‘.py’]  
transport: [‘.py’, ‘’]  
transport: [‘.py’, ‘’]

So it was an empty string and the suffix was always ‘.py’.

If I patch the 1.8.2 find\_plugin() function to add ‘.ps1’ to the suffix list (even when transport is empty) then my problem goes away - I guess, that transport should probably not be empty?

Thanks  
Ian

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [February 12, 2015, 8:09am UTC](https://forum.ansible.com/t/ansible-1-8-2-custom-windows-powershell-module-defined-in-roles-myrole-library-is-not-found-error-mymodule-is-not-a-legal-parameter-in-an-ansible-task-or-handler/17504/2 "2015-02-12T08:09:21Z")

</div>

Create an empty mymodule.py file alongside mymodule.ps1; that should allow the playbook to determine that mymodule is a valid module name.

---

<div class="post-metadata">

**Author:** ![Ian\_Clegg](https://avatars.discourse-cdn.com/v4/letter/i/6bbea6/32.png) [@Ian\_Clegg](https://forum.ansible.com/u/Ian_Clegg)\
**Post date:** [February 12, 2015, 4:38pm UTC](https://forum.ansible.com/t/ansible-1-8-2-custom-windows-powershell-module-defined-in-roles-myrole-library-is-not-found-error-mymodule-is-not-a-legal-parameter-in-an-ansible-task-or-handler/17504/3 "2015-02-12T16:38:00Z")

</div>

Chris,

You nailed it in one!! thanks for heads up!
