# \[WIN\] Howto built custom Powershell module. Read docs, but not getting it.

**URL:** <https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [June 23, 2015, 8:34am UTC](https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571 "2015-06-23T08:34:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![acropia](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@acropia](https://forum.ansible.com/u/acropia)\
**Post date:** [June 23, 2015, 8:34am UTC](https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571/1 "2015-06-23T08:34:07Z")

</div>

Hi,

I want to built some custom modules for Windows. But I ran into some problems:

When I read the docs about developing modules, the part about test-module (git clone, source, chmod) is breaking my Ansible installation. I can’t find out on which path I have to execute those commands

When I copy a module like the win\_ping module inside /usr/lib/python2.7/site-packages/ansible/modules/core/ I can execute it with:

`

# ansible windows -m my\_test

`

But when I try to use the modul inside a playbook, like:

`

- name: Testmodule  
my\_test: var=value

`

I get an error “my\_test is not a legal parameter in an Ansible task or handler”.

I have read about a subdictory ‘./library’ which I creates in /etc/ansible/library. But placing my module over there doesn’t work.

Any clues?

---

<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 23, 2015, 2:03pm UTC](https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571/2 "2015-06-23T14:03:35Z")

</div>

I have a custom library path defined in the [defaults] section in my /etc/ansible/ansible.cfg file, like this:

library = /etc/ansible/library

Not sure if this is required but I use a few custom modules which are in this folder.

What ansible version are you using?

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 23, 2015, 2:11pm UTC](https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571/3 "2015-06-23T14:11:02Z")

</div>

Hi,  
A good way to start is just like you’re doing, copying the win\_ping file. I’d recommend using a custom library path like J H describes above.

A module consists of two files, a .ps1 file which is the actual script and a corresponding .py file. On Windows the py file is only used for documentation, but it still needs to be available.  
Looking at the documentation for win\_ping that module only lists “data” as an acceptable parameter, so passing “var” to it won’t work without modification.

One thing that can easily throw you when getting started with ansible is the yml syntax. Yml uses indenting to organize stuff into arrays/lists, so if your indentation is wrong you’ll get strange errors.

In your example, this should work:

---

<div class="post-metadata">

**Author:** ![acropia](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@acropia](https://forum.ansible.com/u/acropia)\
**Post date:** [June 24, 2015, 8:32am UTC](https://forum.ansible.com/t/win-howto-built-custom-powershell-module-read-docs-but-not-getting-it/18571/4 "2015-06-24T08:32:48Z")

</div>

I use Ansible 1.9.1 on CentOS Linux 7.1.

I just added a win\_test.py file with DOCUMENTATION and EXAMPLES. And now I can use the module like:

`

- name: Win test module  
win\_test:  
var: value

`

I did not put the library option inside my ansible.cfg, because the documentation states the subdir ‘library’ is automatically searched by Ansible.

The one thing that doesn’t for now is the test-module command.

Trond, I read your work for different Windows modules, so how did you get the test-module command to work? At which path you execute the commands in the docs (git clone, source, chmod)?
