aboutsummaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-15 17:26:32 +0100
committerbinary <me@rgoncalves.se>2020-11-15 17:26:32 +0100
commitaea6b114e050545ccc8b953c579d53c9158e238b (patch)
tree7cbeb2ad790638e433c21f1452dded1588949d2e /filter_plugins
parent5bcecbf08db7013ba4de12e492961e2cba6e6b8a (diff)
downloadinfrastructure-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.pycbin0 -> 1027 bytes
-rw-r--r--filter_plugins/filters.py21
-rw-r--r--filter_plugins/filters.yml17
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
new file mode 100644
index 0000000..e52f396
--- /dev/null
+++ b/filter_plugins/__pycache__/filters.cpython-38.pyc
Binary files 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"
+
remember that computers suck.