mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-31 23:58:57 +02:00
Renamed web-app-port-ui to web-app-desktop
This commit is contained in:
38
roles/web-app-desktop/lookup_plugins/docker_cards_grouped.py
Normal file
38
roles/web-app-desktop/lookup_plugins/docker_cards_grouped.py
Normal file
@@ -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) < 2:
|
||||
raise AnsibleError("Missing required arguments")
|
||||
|
||||
cards = terms[0]
|
||||
menu_categories = terms[1]
|
||||
|
||||
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