# Wrapping action\_plugins in an action\_plugin

**URL:** <https://forum.ansible.com/t/wrapping-action-plugins-in-an-action-plugin/17860>\
**Category:** Ansible Developer\
**Created:** [March 27, 2015, 3:42pm UTC](https://forum.ansible.com/t/wrapping-action-plugins-in-an-action-plugin/17860 "2015-03-27T15:42:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Schwarz](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Christian\_Schwarz](https://forum.ansible.com/u/Christian_Schwarz)\
**Post date:** [March 27, 2015, 3:42pm UTC](https://forum.ansible.com/t/wrapping-action-plugins-in-an-action-plugin/17860/1 "2015-03-27T15:42:22Z")

</div>

Hi,

I am writing an _action\_plugin_ that gets a list of files to transfer, their mode and if they are a template.

The _action\_plugin_ shall check the _template_ flag (boolean) and depending on its value either

- (false) run the _copy_ action\_plugin (and hence the copy module) with parameters
- (true) run the _template_ action\_plugin (and hence the copy module) with parameters  
After digging into the Ansible source code, I came up with the following solution: [https://gist.github.com/6478f921d94423be92ac.git](https://gist.github.com/6478f921d94423be92ac.git)

However, this approach only works for the first item to be transferred, as you can see in the console output in the gist.  
After the first run of the plugin (no matter which one), the transferred modules are deleted by some code in Ansible, I think it is the code of the action\_plugins I am calling.  
In the example, the _file_ module has been deleted on the remote host which is required by the _template_ module.

Do you see any way to stop the plugins from deleting transferred modules?  
Or do you have an alternative idea on how I could approach my problem?

(I need to execute Python code to gather the list of transfers, hence, I will need to write an action\_plugin. So: I appreciate tips on how to do this in a playbook but this is not what I am looking for).

Thanks,

Chris
