There is surprisingly (and sometime frustratingly) little documentation on Ansible action_plugins. I am trying to write an action plugin for a module that uses delegation. Is there a way to accomplish this? Would greatly appreciate any input
This is an example of a module I have:-
- name: “create database user”
db_user:
host: “{{ groups[‘servers’].0 }}”
user: “{{ root_user }}”
password: “{{ root_password }}”
delegate_to: “{{ groups[‘servers’].0 }}”
And my action plugin is:-
class ActionModule(object):
def init(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):
parsed_args = parse_kv(module_args)
options = {
key: parsed_args.get(key) for key in [“host”, “user”, “password”]
}
args = " ".join(
“{}=‘{}’”.format(key, value) for key, value in options.items()
)
return self.runner._execute_module( conn, tmp, ‘db_user’, args, inject=inject,)
Thanks