Moved borg action plugin into its own role
This commit is contained in:
parent
cab3d045c1
commit
e19baa85fa
2 changed files with 27 additions and 2 deletions
23
action_plugins/init.py
Normal file
23
action_plugins/init.py
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
Reference in a new issue