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)

211 views
Skip to first unread message

Ian Clegg

unread,
Feb 11, 2015, 1:15:42 PM2/11/15
to ansible...@googlegroups.com
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





Chris Church

unread,
Feb 12, 2015, 3:09:46 AM2/12/15
to ansible...@googlegroups.com
Create an empty mymodule.py file alongside mymodule.ps1; that should allow the playbook to determine that mymodule is a valid module name.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b2446014-4606-49e5-b667-21c980cce5ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ian Clegg

unread,
Feb 12, 2015, 11:38:00 AM2/12/15
to ansible...@googlegroups.com
Chris,

You nailed it in one!! thanks for heads up!
Reply all
Reply to author
Forward
0 new messages