aboutsummaryrefslogtreecommitdiff
path: root/action_plugins/borg_init.py
blob: 17752712aa7bef266cadef9e05425c6f76a9d067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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