diff options
author | binary <me@rgoncalves.se> | 2020-11-15 17:26:32 +0100 |
---|---|---|
committer | binary <me@rgoncalves.se> | 2020-11-15 17:26:32 +0100 |
commit | aea6b114e050545ccc8b953c579d53c9158e238b (patch) | |
tree | 7cbeb2ad790638e433c21f1452dded1588949d2e /filter_plugins | |
parent | 5bcecbf08db7013ba4de12e492961e2cba6e6b8a (diff) | |
download | infrastructure-aea6b114e050545ccc8b953c579d53c9158e238b.tar.gz |
I'm so lazy so ignore this cimment this time pls
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" + |