Implemented schema/main.yml und config/main.yml file

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-09 02:03:32 +02:00
parent 7362accab0
commit 22b4342300
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
114 changed files with 48 additions and 45 deletions

View File

@ -47,7 +47,7 @@ def main():
for role_dir in sorted(roles_dir.iterdir()): for role_dir in sorted(roles_dir.iterdir()):
role_name = role_dir.name role_name = role_dir.name
vars_main = role_dir / "vars" / "main.yml" vars_main = role_dir / "vars" / "main.yml"
config_file = role_dir / "vars" / "configuration.yml" config_file = role_dir / "config" / "main.yml"
if not vars_main.exists(): if not vars_main.exists():
print(f"[!] Skipping {role_name}: vars/main.yml missing") print(f"[!] Skipping {role_name}: vars/main.yml missing")
@ -68,7 +68,7 @@ def main():
continue continue
if not config_file.exists(): if not config_file.exists():
print(f"[!] Skipping {role_name}: vars/configuration.yml missing") print(f"[!] Skipping {role_name}: config/main.yml missing")
continue continue
config_data = load_yaml_file(config_file) config_data = load_yaml_file(config_file)

View File

@ -21,7 +21,7 @@ def load_run_after(meta_file):
def load_application_id(role_path): def load_application_id(role_path):
"""Load the application_id from the vars/main.yml of the role.""" """Load the application_id from the vars/main.yml of the role."""
vars_file = os.path.join(role_path, 'vars', 'main.yml') vars_file = os.path.join(role_path, 'main', 'main.yml')
if os.path.exists(vars_file): if os.path.exists(vars_file):
with open(vars_file, 'r') as f: with open(vars_file, 'r') as f:
data = yaml.safe_load(f) or {} data = yaml.safe_load(f) or {}

View File

@ -17,7 +17,7 @@ class InventoryManager:
self.vault_pw = vault_pw self.vault_pw = vault_pw
self.overrides = overrides self.overrides = overrides
self.inventory = YamlHandler.load_yaml(inventory_path) self.inventory = YamlHandler.load_yaml(inventory_path)
self.schema = YamlHandler.load_yaml(role_path / "meta" / "schema.yml") self.schema = YamlHandler.load_yaml(role_path / "schema" / "main.yml")
self.app_id = self.load_application_id(role_path) self.app_id = self.load_application_id(role_path)
self.vault_handler = VaultHandler(vault_pw) self.vault_handler = VaultHandler(vault_pw)
@ -38,7 +38,7 @@ class InventoryManager:
target = apps.setdefault(self.app_id, {}) target = apps.setdefault(self.app_id, {})
# Load the data from vars/main.yml # Load the data from vars/main.yml
vars_file = self.role_path / "vars" / "configuration.yml" vars_file = self.role_path / "config" / "main.yml"
data = YamlHandler.load_yaml(vars_file) data = YamlHandler.load_yaml(vars_file)
# Check if 'central-database' is enabled in the features section of data # Check if 'central-database' is enabled in the features section of data

View File

@ -30,10 +30,10 @@ def load_configuration(application_id, key):
except Exception: except Exception:
md = {} md = {}
if md.get('application_id') == application_id: if md.get('application_id') == application_id:
cf = os.path.join(roles_dir, role, 'vars', 'configuration.yml') cf = os.path.join(roles_dir, role, "config" , "main.yml")
if not os.path.exists(cf): if not os.path.exists(cf):
raise AnsibleFilterError( raise AnsibleFilterError(
f"Role '{role}' declares '{application_id}' but missing configuration.yml" f"Role '{role}' declares '{application_id}' but missing config/main.yml"
) )
config_path = cf config_path = cf
break break
@ -41,7 +41,7 @@ def load_configuration(application_id, key):
# 2) fallback nested # 2) fallback nested
if config_path is None: if config_path is None:
for role in os.listdir(roles_dir): for role in os.listdir(roles_dir):
cf = os.path.join(roles_dir, role, 'vars', 'configuration.yml') cf = os.path.join(roles_dir, role, "config" , "main.yml")
if not os.path.exists(cf): if not os.path.exists(cf):
continue continue
try: try:
@ -55,7 +55,7 @@ def load_configuration(application_id, key):
# 3) fallback flat # 3) fallback flat
if config_path is None: if config_path is None:
for role in os.listdir(roles_dir): for role in os.listdir(roles_dir):
cf = os.path.join(roles_dir, role, 'vars', 'configuration.yml') cf = os.path.join(roles_dir, role, "config" , "main.yml")
if not os.path.exists(cf): if not os.path.exists(cf):
continue continue
try: try:
@ -74,7 +74,7 @@ def load_configuration(application_id, key):
try: try:
parsed = yaml.safe_load(open(config_path)) or {} parsed = yaml.safe_load(open(config_path)) or {}
except Exception as e: except Exception as e:
raise AnsibleFilterError(f"Error loading configuration.yml at {config_path}: {e}") raise AnsibleFilterError(f"Error loading config/main.yml at {config_path}: {e}")
# detect nested vs flat # detect nested vs flat
is_nested = isinstance(parsed, dict) and (application_id in parsed) is_nested = isinstance(parsed, dict) and (application_id in parsed)

View File

@ -6,7 +6,7 @@ This directory contains variable definition files for the `service-rdbms-mariadb
## files and their purpose ## files and their purpose
### 1. `configuration.yml` ### 1. `config/main.yml`
Contains configuration values that determine which Docker image version to use and what hostname the container will be registered under. Contains configuration values that determine which Docker image version to use and what hostname the container will be registered under.

View File

@ -11,5 +11,5 @@
http_port: "{{ ports.localhost.http[application_id] }}" http_port: "{{ ports.localhost.http[application_id] }}"
- name: "configure pgadmin servers" - name: "configure pgadmin servers"
include_tasks: configuration.yml include_tasks: config/main.yml
when: applications[application_id].server_mode | bool when: applications[application_id].server_mode | bool

Some files were not shown because too many files have changed in this diff Show More