Refactor systemctl services and categories due to alarm bugs

This commit restructures systemctl service definitions and category mappings.

Motivation: Alarm-related bugs revealed inconsistencies in service and role handling.

Preparation step: lays the groundwork for fixing the alarm issues by aligning categories, roles, and service templates.
This commit is contained in:
2025-08-18 13:35:43 +02:00
parent 29f50da226
commit 3a839cfe37
289 changed files with 975 additions and 948 deletions

View File

@@ -7,10 +7,10 @@ import ipaddress
class TestNetworksUniqueValidAndMapped(unittest.TestCase):
@classmethod
def setUpClass(cls):
# locate group_vars/all/10_networks.yml
# locate group_vars/all/09_networks.yml
base_dir = os.path.dirname(__file__)
cls.networks_file = os.path.abspath(
os.path.join(base_dir, '..', '..', 'group_vars', 'all', '10_networks.yml')
os.path.join(base_dir, '..', '..', 'group_vars', 'all', '09_networks.yml')
)
if os.path.isfile(cls.networks_file):
with open(cls.networks_file, 'r', encoding='utf-8') as f:
@@ -28,7 +28,7 @@ class TestNetworksUniqueValidAndMapped(unittest.TestCase):
def test_unique_and_non_overlapping_subnets(self):
"""Ensure that all subnets are valid, unique and do not overlap."""
if self.networks_data is None:
self.skipTest("10_networks.yml not found, skipping subnet validation.")
self.skipTest("09_networks.yml not found, skipping subnet validation.")
# extract all named subnets under defaults_networks.local
local = self.networks_data.get('defaults_networks', {}).get('local', {})
@@ -73,7 +73,7 @@ class TestNetworksUniqueValidAndMapped(unittest.TestCase):
matches an application_id in some roles/*/vars/main.yml.
"""
if self.networks_data is None:
self.skipTest("10_networks.yml not found, skipping application_id mapping check.")
self.skipTest("09_networks.yml not found, skipping application_id mapping check.")
# collect network names
local = self.networks_data.get('defaults_networks', {}).get('local', {})

View File

@@ -19,7 +19,7 @@ class TestCreateDockerRoleCLI(unittest.TestCase):
# Temporary directory for YAML files and templates
self.tmpdir = tempfile.mkdtemp()
self.ports_file = os.path.join(self.tmpdir, '09_ports.yml')
self.networks_file = os.path.join(self.tmpdir, '10_networks.yml')
self.networks_file = os.path.join(self.tmpdir, '09_networks.yml')
def tearDown(self):
shutil.rmtree(self.tmpdir)

View File

@@ -17,32 +17,24 @@ class TestGetEntityNameFilter(unittest.TestCase):
categories = {
'roles': {
'web': {
'app': {
'title': "Applications",
'invokable': True
},
'svc': {
'title': "Services",
'invokable': True
}
'app': {'title': "Applications", 'invokable': True},
'svc': {'title': "Services", 'invokable': True},
},
'util': {
'desk': {
'dev': {
'title': "Dev Utilities",
'invokable': True
}
}
'desk': {
'dev': {'title': "Dev Utilities", 'invokable': True}
}
},
'sys': {
'bkp': {
'title': "Backup",
'invokable': True
},
'hlth': {
'title': "Health",
'invokable': True
}
'ctl': {
'bkp': {'title': "Backup", 'invokable': True},
'hlth': {'title': "Health", 'invokable': True},
},
# falls du 'core' o. ä. brauchst, hier ergänzen
},
# 'svc' ist in deinem echten Baum top-level, nicht unter 'sys'
'svc': {
'db': {'title': "Databases", 'invokable': True}
}
}
}
@@ -77,10 +69,10 @@ class TestGetEntityNameFilter(unittest.TestCase):
self.assertEqual(self.get_entity_name("util-desk-dev-shell"), "shell")
def test_entity_name_sys_bkp(self):
self.assertEqual(self.get_entity_name("sys-bkp-directory-validator"), "directory-validator")
self.assertEqual(self.get_entity_name("sys-ctl-bkp-directory-validator"), "directory-validator")
def test_entity_name_sys_hlth(self):
self.assertEqual(self.get_entity_name("sys-hlth-btrfs"), "btrfs")
self.assertEqual(self.get_entity_name("sys-ctl-hlth-btrfs"), "btrfs")
def test_no_category_match(self):
# Unknown category, should return input

View File

@@ -2,10 +2,10 @@ import unittest
import os
import sys
# Add the path to roles/sys-bkp-docker-2-loc/filter_plugins
# Add the path to roles/sys-ctl-bkp-docker-2-loc/filter_plugins
CURRENT_DIR = os.path.dirname(__file__)
FILTER_PLUGIN_DIR = os.path.abspath(
os.path.join(CURRENT_DIR, '../../../../../roles/sys-bkp-docker-2-loc/filter_plugins')
os.path.join(CURRENT_DIR, '../../../../../roles/sys-ctl-bkp-docker-2-loc/filter_plugins')
)
sys.path.insert(0, FILTER_PLUGIN_DIR)

View File

@@ -5,7 +5,7 @@ import os
TEST_DIR = os.path.dirname(__file__)
PLUGIN_PATH = os.path.abspath(os.path.join(
TEST_DIR,
'../../../../../roles/sys-bkp-docker-2-loc/filter_plugins/find_dock_val_by_bkp_entr.py'
'../../../../../roles/sys-ctl-bkp-docker-2-loc/filter_plugins/find_dock_val_by_bkp_entr.py'
))
spec = importlib.util.spec_from_file_location("find_dock_val_by_bkp_entr", PLUGIN_PATH)