From 2451b5ced341e37fe004b4f36b040a55a97ce03e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 4 Mar 2021 13:38:44 +0100 Subject: Fixed stupid ansible python sucks silent name collision --- action_plugins/borg_init.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 action_plugins/borg_init.py (limited to 'action_plugins/borg_init.py') diff --git a/action_plugins/borg_init.py b/action_plugins/borg_init.py new file mode 100644 index 0000000..1775271 --- /dev/null +++ b/action_plugins/borg_init.py @@ -0,0 +1,25 @@ +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['changed'] = False + result['failed'] = False + + is_server = False + + for hostname, hostvars in task_vars['hostvars'].items() : + if 'borg_server' in hostvars.keys() and hostvars['borg_server'] == task_vars['ansible_host']: + is_server = True + + result['ansible_facts'] = { + 'borg': { + 'is_server': is_server, + } + } + + return result + -- cgit v1.2.3