# Ansible Acton Plugins

**URL:** <https://forum.ansible.com/t/ansible-acton-plugins/21163>\
**Category:** Ansible Project\
**Created:** [April 15, 2016, 3:14am UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163 "2016-04-15T03:14:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monty1](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@Monty1](https://forum.ansible.com/u/Monty1)\
**Post date:** [April 15, 2016, 3:14am UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/1 "2016-04-15T03:14:16Z")

</div>

I am trying to write a ansible action plugin. The reason i am doing this is, I want to access my variables available in playbook (modules can only deal with args as far i understand, please correct me if i am wrong )

Now writing this plugin, what is the directory structure i should have? i tried (action\_plugins/, library/, tests/ ) , library/action\_plugins, tests/ ) they don’t work.  
The moment i start using the 2nd dir structure all the imports fail, first one does not work at all.

I found a few examples, like this [http://jpmens.net/2012/11/03/an-action-plugin-for-ansible-to-handle-ssh-host-keys/](http://jpmens.net/2012/11/03/an-action-plugin-for-ansible-to-handle-ssh-host-keys/)  
But does not discuss about the dir structure.

I am planning to use this plugin by putting this into requirements.yml and installing it in the playbook. Can any one suggest what i am doing wrong.  
(Ansible versions 1.9, i cannot really upgrade it.)

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [April 15, 2016, 1:46pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/2 "2016-04-15T13:46:22Z")

</div>

Action plugins need to be in the action\_plugins/ dir (can be either a subdir of the playbook\_dir or of a role that you include), however, ansible won’t recognize the plugin uless you also have a file of the same name in the library/ dir. All you _ **need** _ to do is ‘touch’ the library file, but you should at least use this to store the module documentation. Remember, though, that action\_plugins are executed on **_localhost_** , so action\_plugin is often used for local preprocessing before calling the module to do the remote work.

All of that being said, why can’t you just pass the module the args that you need?

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [July 21, 2016, 10:15am UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/3 "2016-07-21T10:15:28Z")

</div>

Mike,

I think, I have similar issue.

Mine local lookup plugins from playbook\_dir/lookup\_plugins are loaded and executed fine, but the same manner implemented action plugins are not loaded from file like playbook\_dir/action\_plugins/action.py

Is there additional magic linked to library too ? Is there way I can distribute local action plugin with playbook?

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [July 21, 2016, 2:06pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/4 "2016-07-21T14:06:33Z")

</div>

Vyacheslav, I’m not sure I understand your question?

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [July 21, 2016, 2:24pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/5 "2016-07-21T14:24:26Z")

</div>

in my case actions plugins are not picked up from action\_plugins/ folder, but lookup one do from lookup\_plugins/ folder. Perhaps I missing smth obvious.

i.e. I have set of lookup plugins:

/deployment/boxes/lookup\_plugins  
➜ lookup\_plugins git:(feature-standalone-gl-ee) ls \*.py  
aws\_ec2\_allocation\_id\_from\_eip.py aws\_secgroup\_ids\_from\_names.py aws\_subnet\_ids\_from\_names.py aws\_vpc\_id\_from\_name.py sa\_hashi\_vault.py

and lookup plugins are picked just fine, I am able to use them in playbook

But the action plugins from /deployment/boxes/action\_plugins are not loaded or detected by ansible.

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [July 22, 2016, 3:02pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/6 "2016-07-22T15:02:16Z")

</div>

action\_plugins/ will not be picked up by ansible unless there is a file in library/ with the same name. This file in library/ can be empty, but it must exist.

---

<div class="post-metadata">

**Author:** ![slavko](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/slavko/32/8869_2.png) [@slavko](https://forum.ansible.com/u/slavko)\
**Post date:** [July 22, 2016, 3:14pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/7 "2016-07-22T15:14:00Z")

</div>

Where should the library/ be present? Could it be also directory under playbook?

---

<div class="post-metadata">

**Author:** ![Mike\_Biancaniello](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Mike\_Biancaniello](https://forum.ansible.com/u/Mike_Biancaniello)\
**Post date:** [July 22, 2016, 3:25pm UTC](https://forum.ansible.com/t/ansible-acton-plugins/21163/8 "2016-07-22T15:25:38Z")

</div>

try creating /deployment/boxes/library/  
and placing your files there.

Usually, unless you change your ansible.cfg, the plugins, roles, libraries, etc are all subdirs of your playbook dir.
