mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Optimized portfolio and pkgmgr update procedures
This commit is contained in:
@@ -73,6 +73,11 @@ class LookupModule(LookupBase):
|
||||
meta_data = yaml.safe_load(f)
|
||||
|
||||
galaxy_info = meta_data.get("galaxy_info", {})
|
||||
|
||||
# If display is set to False ignore it
|
||||
if not galaxy_info.get("display", True):
|
||||
continue
|
||||
|
||||
description = galaxy_info.get("description", "")
|
||||
logo = galaxy_info.get("logo", {})
|
||||
icon_class = logo.get("class", "fa-solid fa-cube")
|
||||
|
@@ -0,0 +1,38 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
def run(self, terms, variables=None, **kwargs):
|
||||
"""
|
||||
Group the given cards into categorized and uncategorized lists
|
||||
based on the tags from menu_categories.
|
||||
"""
|
||||
if len(terms) < 1:
|
||||
raise AnsibleError("Missing required argument: cards")
|
||||
|
||||
cards = terms[0]
|
||||
menu_categories = variables.get("menu_categories", {})
|
||||
|
||||
categorized = {}
|
||||
uncategorized = []
|
||||
|
||||
for card in cards:
|
||||
found = False
|
||||
for category, data in menu_categories.items():
|
||||
if any(tag in data.get('tags', []) for tag in card.get('tags', [])):
|
||||
categorized.setdefault(category, []).append(card)
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
uncategorized.append(card)
|
||||
|
||||
return [
|
||||
{
|
||||
'categorized': categorized,
|
||||
'uncategorized': uncategorized,
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user