1
0
Fork 0

Moved borg action plugin into its own role

This commit is contained in:
Julien Dessaux 2021-03-04 12:51:16 +01:00
parent cab3d045c1
commit e19baa85fa
2 changed files with 27 additions and 2 deletions

23
action_plugins/init.py Normal file
View file

@ -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

View file

@ -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