# Writing Modules without AnsibleModule

**URL:** <https://forum.ansible.com/t/writing-modules-without-ansiblemodule/20299>\
**Category:** Ansible Developer\
**Created:** [January 20, 2016, 10:59pm UTC](https://forum.ansible.com/t/writing-modules-without-ansiblemodule/20299 "2016-01-20T22:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Edelman](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@Jason\_Edelman](https://forum.ansible.com/u/Jason_Edelman)\
**Post date:** [January 20, 2016, 10:59pm UTC](https://forum.ansible.com/t/writing-modules-without-ansiblemodule/20299/1 "2016-01-20T22:59:49Z")

</div>

Hi, does anyone have sample code on how to write a module not using the AnsibleModule object?

I’m trying to see how to access the params in a custom module in Python without AnsibleModule as preparation for writing modules in another language.

The only example I found is below which is reading in args from a file, which I don’t want, and I’m trying to pass params in as normal, i.e. test\_module: a=5 b=5 and read them with sys.argv, argparse, etc. Is this possible?

`

# read the argument string from the arguments file

args\_file = sys.argv[1]  
args\_data = file(args\_file).read()

# for this module, we’re going to do key=value style arguments

# this is up to each module to decide what it wants, but all

# core modules besides ‘command’ and ‘shell’ take key=value

# so this is highly recommended

arguments = shlex.split(args\_data)  
`  
[http://docs.ansible.com/ansible/developing\_modules.html](http://docs.ansible.com/ansible/developing_modules.html)

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 20, 2016, 11:03pm UTC](https://forum.ansible.com/t/writing-modules-without-ansiblemodule/20299/2 "2016-01-20T23:03:50Z")

</div>

Modules read their arguments from a file, this file is in JSON format  
and how Ansible passes the options to it. That is what key=val get  
transformed into.

---

<div class="post-metadata">

**Author:** ![Jason\_Edelman](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@Jason\_Edelman](https://forum.ansible.com/u/Jason_Edelman)\
**Post date:** [January 20, 2016, 11:10pm UTC](https://forum.ansible.com/t/writing-modules-without-ansiblemodule/20299/3 "2016-01-20T23:10:14Z")

</div>

Ahh, I mis-interpreted that example. Just tested with that chunk of code and all is good for key=value params.

THANKS!
