diff options
Diffstat (limited to 'filter_plugins')
-rw-r--r-- | filter_plugins/__pycache__/filters.cpython-38.pyc | bin | 0 -> 1027 bytes | |||
-rw-r--r-- | filter_plugins/filters.py | 21 | ||||
-rw-r--r-- | filter_plugins/filters.yml | 17 |
3 files changed, 36 insertions, 2 deletions
diff --git a/filter_plugins/__pycache__/filters.cpython-38.pyc b/filter_plugins/__pycache__/filters.cpython-38.pyc Binary files differnew file mode 100644 index 0000000..e52f396 --- /dev/null +++ b/filter_plugins/__pycache__/filters.cpython-38.pyc diff --git a/filter_plugins/filters.py b/filter_plugins/filters.py index 1f1500e..efe0c43 100644 --- a/filter_plugins/filters.py +++ b/filter_plugins/filters.py @@ -1,8 +1,25 @@ #!/bin/python +import requests + class FilterModule(object): def filters(self): + return { + "repology": self.repology_filter + } + + def repology_filter(self, package, repository): + """ + Use repology.org API for getting generic package names accrossed different Unix systems. + This allows us to use standard package names, and execute install tasks with a system-agnostic way. + """ + api_endpoint = "https://repology.org/api/v1/project/" + + response = requests.get(f"{api_endpoint}/{package}") + + for res in response.json(): + if res["repo"] == repository: + return res - def get_vm_distro(vms, distro): - return False + return response.json()[0] diff --git a/filter_plugins/filters.yml b/filter_plugins/filters.yml new file mode 100644 index 0000000..8ffd742 --- /dev/null +++ b/filter_plugins/filters.yml @@ -0,0 +1,17 @@ + +# filters ~~ filter_plugins/filters.yml +# DEBUG PLAYBOOK for custom filters + +--- + +- hosts: localhost + tasks: + + - debug: + msg: "{{ item | repology }}" + loop: + - "AAA" + - "firefox" + - "neovim" + - "brrrrrrrr" + |