From aea6b114e050545ccc8b953c579d53c9158e238b Mon Sep 17 00:00:00 2001 From: binary Date: Sun, 15 Nov 2020 17:26:32 +0100 Subject: I'm so lazy so ignore this cimment this time pls --- filter_plugins/__pycache__/filters.cpython-38.pyc | Bin 0 -> 1027 bytes filter_plugins/filters.py | 21 +++++++++++++++++++-- filter_plugins/filters.yml | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 filter_plugins/__pycache__/filters.cpython-38.pyc create mode 100644 filter_plugins/filters.yml (limited to 'filter_plugins') diff --git a/filter_plugins/__pycache__/filters.cpython-38.pyc b/filter_plugins/__pycache__/filters.cpython-38.pyc new file mode 100644 index 0000000..e52f396 Binary files /dev/null and b/filter_plugins/__pycache__/filters.cpython-38.pyc differ 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" + -- cgit v1.2.3