summaryrefslogtreecommitdiff
path: root/roles/installer/debian/fetch/filter_plugins/main.py
blob: 947db2ebacc1c412824457017a5dade1a6704af6 (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible import errors


def di_dists_path(data):
    try:
        if data[0] != 'ubuntu':
            return data[1]

        if data[1] in ['xenial']:
            return data[1]+'-updates'

        return data[1]
    except Exception as e:
        raise errors.AnsibleFilterError("di_dists_path(): %s" % str(e))


def di_images_path(data):
    try:
        if data[0] != 'ubuntu':
            return 'images'

        if data[1] in ['xenial', 'bionic']:
            return 'images'

        return 'legacy-images'
    except Exception as e:
        raise errors.AnsibleFilterError("di_images_path(): %s" % str(e))


class FilterModule(object):

    filter_map = {
        'di_dists_path': di_dists_path,
        'di_images_path': di_images_path,
    }

    def filters(self):
        return self.filter_map