Posted by: terryhowe | May 2, 2016

Ansible 2.0 Action Plugins

Ansible action plugins are by far the most arcane plugins.  Finding documentation on 1.x plugins is hard enough to find and 2.0 is even more difficult.  When I tried to write my first 2.x action plugin, I got:


Unexpected Exception: No module named runner.return_data

A sample Ansible 2.0 action plugin does not use the runner return_data, it derives off ActionBase:


from ansible.plugins.action import ActionBase


class ActionModule(ActionBase):

    def run(self, tmp=None, task_vars=None):

        if task_vars is None:
            task_vars = dict()
        result = super(ActionModule, self).run(tmp, task_vars)
        result['msg'] = 'woot'
        return result

Advertisements

Responses

  1. […] posted yesterday about Action Plugins for Ansible 2.0 and I’d like to expand on that a little with the associated sample Ansible 2.0 module. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: