aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2021-03-04 12:51:16 +0100
committerJulien Dessaux2021-03-04 12:53:57 +0100
commite19baa85fabaa5bccbebda6dcf334dcfae2bede9 (patch)
tree0e4f1b04781b34df93d439aba9e5d1420a5373d7
parentSimplified and fixed borg role (diff)
downloadborg-ansible-role-e19baa85fabaa5bccbebda6dcf334dcfae2bede9.tar.gz
borg-ansible-role-e19baa85fabaa5bccbebda6dcf334dcfae2bede9.tar.bz2
borg-ansible-role-e19baa85fabaa5bccbebda6dcf334dcfae2bede9.zip
Moved borg action plugin into its own role
-rw-r--r--action_plugins/init.py23
-rw-r--r--tasks/main.yml6
2 files changed, 27 insertions, 2 deletions
diff --git a/action_plugins/init.py b/action_plugins/init.py
new file mode 100644
index 0000000..a37b109
--- /dev/null
+++ b/action_plugins/init.py
@@ -0,0 +1,23 @@
+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_borg_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_borg_server = True
+
+ result['ansible_facts'] = {
+ 'is_borg_server': is_borg_server,
+ }
+
+ return result
+
diff --git a/tasks/main.yml b/tasks/main.yml
index 91910ef..69df94d 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,9 +1,11 @@
---
+- action: init
+
- import_tasks: common.yml
- when: adyxax['is_borg_server'] or borg_server is defined
+ when: is_borg_server or borg_server is defined
- import_tasks: server.yml
- when: adyxax['is_borg_server']
+ when: is_borg_server
- import_tasks: client.yml
when: borg_server is defined