# Very Basic Module

**URL:** <https://forum.ansible.com/t/very-basic-module/14891>\
**Category:** Ansible Developer\
**Created:** [March 29, 2014, 3:07pm UTC](https://forum.ansible.com/t/very-basic-module/14891 "2014-03-29T15:07:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Craig\_Mason-Jones](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@Craig\_Mason-Jones](https://forum.ansible.com/u/Craig_Mason-Jones)\
**Post date:** [March 29, 2014, 3:07pm UTC](https://forum.ansible.com/t/very-basic-module/14891/1 "2014-03-29T15:07:41Z")

</div>

Hi all,

I’m a module developer newbie, so have started trying to write a very small module that will decrypt a file onto a target machine. I began by copying the ‘copy’ module:

#!/usr/bin/python

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

import os

def main():  
module = AnsibleModule(  
argument\_spec = dict(  
src = dict(required=False),  
),  
)  
src = os.path.expanduser(module.params[‘src’])

if not os.path.exists(src):  
module.fail\_json(msg=“Source %s failed to transfer” % (src))

module.exit\_json(changed=True)

from ansible.module\_utils.basic import \*  
main()

This immediately fails in my playbook: msg: Source mytest.des3 failed to transfer

Further digging in the Ansible source suggests that _copy_ is an action\_plugin, and this somehow makes the copy module work.

Is there somewhere that I can read more about this, or am I missing something very basic?

All the best,  
Craig

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 29, 2014, 3:43pm UTC](https://forum.ansible.com/t/very-basic-module/14891/2 "2014-03-29T15:43:42Z")

</div>

> Further digging in the Ansible source suggests that\* copy\* is an  
> action\_plugin, and this somehow makes the copy module work.

"​copy" is actually both an action\_plugin​ and a module

Is there somewhere that I can read more about this, or am I missing

> something very basic?

​Not really, except the source itself. (\*Seems like action\_plugins are not  
covered in [http://docs.ansible.com/developing\_modules.html](http://docs.ansible.com/developing_modules.html))

\* Modules and action plugins always ​work in pair.  
\* Most modules do not have a specific action plugin and are handled by the  
normal (or async) action plugin.  
\* Some action modules do not have a module counterpart (e.g. the pause,  
debug, group\_by module, ..)  
\* And some modules have their own specific action plugin, like synchronize,  
or copy.

I guess your best optiojns are to have a look at the code in the various  
action plugins, and possibly the code in Runner.\_executor\_internal\_inner()  
that drives them.

HTH,

&nbsp;&nbsp;Serge

---

<div class="post-metadata">

**Author:** ![Craig\_Mason-Jones](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@Craig\_Mason-Jones](https://forum.ansible.com/u/Craig_Mason-Jones)\
**Post date:** [March 29, 2014, 3:55pm UTC](https://forum.ansible.com/t/very-basic-module/14891/3 "2014-03-29T15:55:56Z")

</div>

Thank you - that helps a lot. Ah, some digging to be done!

All the best,  
Craig
