# how does Ansible find my first hand made module? I put it in ./library

**URL:** <https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787>\
**Category:** Ansible Project\
**Created:** [November 17, 2015, 7:23pm UTC](https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787 "2015-11-17T19:23:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://forum.ansible.com/u/Larry_Fast)\
**Post date:** [November 17, 2015, 7:23pm UTC](https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787/1 "2015-11-17T19:23:43Z")

</div>

I created my first module using your python boilerplates. How do I get my Ansible Playbook to find it? According to the docs, I placed it in ./library/env\_checks.py but I still get “ERROR: enviro\_checks\_ansmodule is not a legal parameter in an Ansible task or handler” What steps am I missing?

Playbook code

- hosts: myhosts  
tasks:
- env\_checks:

Module Code:

def main():  
module = AnsibleModule(  
argument\_spec = dict(  
state = dict(default=‘present’, choices=[‘present’, ‘absent’])  
)  
)  
module.exit\_json(changed=True, otherthing=False)

from ansible.module\_utils.basic import \*  
if **name** == ‘ **main** ’:  
main()

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [November 17, 2015, 8:22pm UTC](https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787/2 "2015-11-17T20:22:34Z")

</div>

You could try explicitly setting the ANSIBLE\_LIBRARY environment  
variable.to the path to you library directory

-Toshio

---

<div class="post-metadata">

**Author:** ![Larry\_Fast](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Larry\_Fast](https://forum.ansible.com/u/Larry_Fast)\
**Post date:** [November 17, 2015, 11:42pm UTC](https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787/3 "2015-11-17T23:42:10Z")

</div>

Turns out it requires the #! at the start. Don’t know if the 2nd line is required.

#!/usr/bin/python

# -_- coding: utf-8 -_-

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [November 18, 2015, 4:23am UTC](https://forum.ansible.com/t/how-does-ansible-find-my-first-hand-made-module-i-put-it-in-library/19787/4 "2015-11-18T04:23:14Z")

</div>

Ah, yeah that’s needed so that ansible can tell this is a module written in python vs ruby or perl or another language. The second line is nice boilerplate but not strictly needed. It tells python what encoding to use when it reads the file. It’s usually only needed when you embed a non-ascii literal in the file. (For instance, someone puts their name in a comment and their name has accents)

-Toshio
