# Action Plugins and Async Support

**URL:** <https://forum.ansible.com/t/action-plugins-and-async-support/23223>\
**Category:** Ansible Developer\
**Created:** [December 10, 2016, 6:46pm UTC](https://forum.ansible.com/t/action-plugins-and-async-support/23223 "2016-12-10T18:46:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mumshad\_Mannambeth](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Mumshad\_Mannambeth](https://forum.ansible.com/u/Mumshad_Mannambeth)\
**Post date:** [December 10, 2016, 6:46pm UTC](https://forum.ansible.com/t/action-plugins-and-async-support/23223/1 "2016-12-10T18:46:40Z")

</div>

I have two questions about action\_plugins:

1. I wrote a custom ansible module that by default has async support. I wrote an action plugin for it like below. Now I get error - async mode is not supported for this module. Anything else I should be doing to support this?

```auto
class ActionModule(ActionBase):

    def run(self, tmp=None, task_vars=None):
        print("Hi from action plugin")

        result = super(ActionModule, self).run(tmp, task_vars)

        killFlag = os.getenv('KILL_FLAG')

        print("Kill Flag = %s" % killFlag)

        if killFlag == "KILL_JOB":
            result['skipped'] = True
            result['msg'] = 'Skipped from action plugin due to Stop Request'
        else:
            result.update(self._execute_module())

        print("Bye from action plugin")

        return result

```

1. Can we have a global action plugin or something similar to check a variable and skip all remaining tasks in the Ansible execution?

Appreciate any advise on a better way to accomplish gracefully stopping the playbook execution.

---

<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:** [February 28, 2017, 4:41pm UTC](https://forum.ansible.com/t/action-plugins-and-async-support/23223/2 "2017-02-28T16:41:59Z")

</div>

So async was handled by using a specific 'async' action plugin up to  
and including version 2.2, this precluded action plugins from being  
compatible with async (as this required a specific one)

In 2.3 we have changed how this works so it happens when you call  
execute\_module, for the action plugin you just need to add a property  
`self._supports_async = True` and then deal with running the  
module with the async setting (see service/package for examples).

As for the 'skip' module/action, there has been that feature request  
for a while, currently we only have the ability to 'fail' using that  
module or 'assert', a workaround is using a block with conditionals to  
apply to the 'rest of the tasks' in the play.
