# Action plugins.

**URL:** <https://forum.ansible.com/t/action-plugins/12594>\
**Category:** Ansible Project\
**Created:** [March 27, 2013, 5:41pm UTC](https://forum.ansible.com/t/action-plugins/12594 "2013-03-27T17:41:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [March 27, 2013, 5:41pm UTC](https://forum.ansible.com/t/action-plugins/12594/1 "2013-03-27T17:41:33Z")

</div>

A quick question:

Is it possible for a user-made action plugin to be called with the  
shorthand task syntax (module: arg=argval ...)?

The built-in action plugins (like fail, debug, etc.) are able to be  
called this way, but I think figuring out how that's managed will take  
longer than asking the list.

I can call my action plugin with the regular 'action: module args...'  
syntax if necessary, but consistency is a fun thing.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 27, 2013, 5:46pm UTC](https://forum.ansible.com/t/action-plugins/12594/2 "2013-03-27T17:46:22Z")

</div>

> A quick question:
> 
> Is it possible for a user-made action plugin to be called with the  
> shorthand task syntax (module: arg=argval ...)?

Yes.

> The built-in action plugins (like fail, debug, etc.) are able to be  
> called this way, but I think figuring out how that's managed will take  
> longer than asking the list.
> 
> I can call my action plugin with the regular 'action: module args...'  
> syntax if necessary, but consistency is a fun thing.

Is there a reason it didn't seem to work for you?

---

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [March 27, 2013, 5:58pm UTC](https://forum.ansible.com/t/action-plugins/12594/3 "2013-03-27T17:58:31Z")

</div>

Excerpts from Michael DeHaan's message of 2013-03-27 13:46:22 -0400:

> Is there a reason it didn't seem to work for you?

ansible.cfg includes:

&nbsp;&nbsp;&nbsp;&nbsp;action\_plugins = ansible\_plugins/action\_plugins

I've got a mock action plugin in:  
&nbsp;&nbsp;&nbsp;&nbsp;$PWD/ansible\_plugins/action\_plugins/testaction.py

It's a tiny mock module:

&nbsp;&nbsp;&nbsp;&nbsp;from ansible.runner.return\_data import ReturnData

&nbsp;&nbsp;&nbsp;&nbsp;class ActionModule(object):

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def \_\_init\_\_(self, runner):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.runner = runner

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def run(self, conn, tmp, module\_name, module\_args, inject,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;complex\_args=None, \*\*kwargs):

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return ReturnData(conn=conn, result={'failed': False,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'msg': 'foo'})

A playbook, test.yml:

&nbsp;&nbsp;&nbsp;&nbsp;- hosts: testhost  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- testaction: hi=foo

Then I run:

&nbsp;&nbsp;&nbsp;&nbsp;$ ansible-playbook -i test\_hosts test.yml -u root -v  
&nbsp;&nbsp;&nbsp;&nbsp;ERROR: testaction is not a legal parameter in an Ansible task or handler

I'm running devel from git as of 15 minutes ago or so.

Perhaps I'm missing something?

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 27, 2013, 6:28pm UTC](https://forum.ansible.com/t/action-plugins/12594/4 "2013-03-27T18:28:39Z")

</div>

IIRC, you need documentation stub in the ansible library directory.

---

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [March 27, 2013, 6:47pm UTC](https://forum.ansible.com/t/action-plugins/12594/5 "2013-03-27T18:47:47Z")

</div>

Excerpts from Michael DeHaan's message of 2013-03-27 14:28:39 -0400:

> IIRC, you need documentation stub in the ansible library directory.

Ahh, there we go.

Thank you very much.
