Solved some variable bugs and cleaned up

This commit is contained in:
Kevin Veen-Birkenbach 2025-05-09 18:33:47 +02:00
parent 0d8027c908
commit e7c193f409
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
9 changed files with 18 additions and 48 deletions

View File

@ -1,8 +1,6 @@
# Makefile for j2render
ROLES_DIR=./roles
OUTPUT=./group_vars/all/11_applications.yml
SCRIPT=./cli/generate_default_applications.py
SCRIPT=./cli/generate_defaults_applications.py
build:
@echo "🔧 Generating $(OUTPUT) from roles in $(ROLES_DIR)..."

View File

@ -13,7 +13,7 @@ def load_yaml_file(path):
return yaml.safe_load(f) or {}
def main():
parser = argparse.ArgumentParser(description="Generate default_applications YAML from docker roles.")
parser = argparse.ArgumentParser(description="Generate defaults_applications YAML from docker roles.")
parser.add_argument("--roles-dir", default="roles", help="Path to the roles directory (default: roles)")
parser.add_argument("--output-file", default="group_vars/all/11_applications.yml", help="Path to output YAML file")
@ -24,7 +24,7 @@ def main():
output_file.parent.mkdir(parents=True, exist_ok=True)
result = {"default_applications": {}}
result = {"defaults_applications": {}}
for role_dir in sorted(roles_dir.iterdir()):
role_name = role_dir.name
@ -48,7 +48,7 @@ def main():
config_data = load_yaml_file(config_file)
if config_data:
result["default_applications"][application_id] = config_data
result["defaults_applications"][application_id] = config_data
with output_file.open("w", encoding="utf-8") as f:
yaml.dump(result, f, sort_keys=False)

View File

@ -48,3 +48,9 @@ certbot_dns_propagation_wait_seconds: 40 # How long sho
certbot_flavor: san # Possible options: san (recommended, with a dns flavor like cloudflare, or hetzner), wildcard(doesn't function with www redirect), deicated
certbot_webroot_path: "/var/lib/letsencrypt/" # Path used by Certbot to serve HTTP-01 ACME challenges
certbot_cert_path: "/etc/letsencrypt/live" # Path containing active certificate symlinks for domains
## Docker Role Specific Parameters
docker_restart_policy: "unless-stopped"
# helper
_applications_nextcloud_oidc_flavor: "{{ applications.nextcloud.oidc.flavor | default('oidc_login' if applications.nextcloud.features.ldap | default(true) else 'sociallogin') }}"

View File

@ -3,6 +3,4 @@ collections:
- name: community.general
pacman:
- ansible
- python-passlib
pkgmgr:
- j2r
- python-passlib

View File

@ -1,4 +0,0 @@
assets_server:
source_directory: "{{ playbook_dir }}/assets" # Directory from which the assets will be copied
url: "{{ web_protocol }}://{{domains.file_server}}/assets" # Public address of the assets directory

View File

@ -0,0 +1,2 @@
source_directory: "{{ playbook_dir }}/assets" # Directory from which the assets will be copied
url: "{{ web_protocol }}://{{domains.file_server}}/assets" # Public address of the assets directory

View File

@ -1,12 +0,0 @@
## Docker Role Specific Parameters
docker_restart_policy: "unless-stopped"
##############################################
## Applications Configuration
##############################################
# Keep in mind, that this configuration should in general just apply to the roles which set the applications up.
# If other applications depend on this variables, propably it makes sense to define it in e.g. IMA or other variable files.
# helper
_applications_nextcloud_oidc_flavor: "{{ applications.nextcloud.oidc.flavor | default('oidc_login' if applications.nextcloud.features.ldap | default(true) else 'sociallogin') }}"

View File

@ -1,18 +0,0 @@
{% macro render_features(options) %}
features:
{%- set feature_map = {
'matomo': 'Enables Matomo tracking',
'css': 'Enables custom CSS styling',
'iframe': 'Allows embedding via iframe on landing page',
'ldap': 'Enables LDAP integration and networking',
'oidc': 'Enables OpenID Connect (OIDC) authentication',
'oauth2': 'Enables OAuth2 proxy integration',
'database': 'Enables use of central database',
'recaptcha': 'Enables recaptcha functionality'
} %}
{%- for key, comment in feature_map.items() %}
{%- if key in options %}
{{ key }}: {{ options[key] }} # {{ comment }}
{%- endif %}
{%- endfor %}
{% endmacro %}

View File

@ -29,7 +29,7 @@ class TestGenerateDefaultApplications(unittest.TestCase):
shutil.rmtree(self.temp_dir)
def test_script_generates_expected_yaml(self):
script_path = Path(__file__).resolve().parent.parent.parent / "cli" / "generate_default_applications.py"
script_path = Path(__file__).resolve().parent.parent.parent / "cli" / "generate_defaults_applications.py"
result = subprocess.run(
[
@ -45,10 +45,10 @@ class TestGenerateDefaultApplications(unittest.TestCase):
self.assertTrue(self.output_file.exists(), "Output file was not created.")
data = yaml.safe_load(self.output_file.read_text())
self.assertIn("default_applications", data)
self.assertIn("testapp", data["default_applications"])
self.assertEqual(data["default_applications"]["testapp"]["foo"], "bar")
self.assertEqual(data["default_applications"]["testapp"]["baz"], 123)
self.assertIn("defaults_applications", data)
self.assertIn("testapp", data["defaults_applications"])
self.assertEqual(data["defaults_applications"]["testapp"]["foo"], "bar")
self.assertEqual(data["defaults_applications"]["testapp"]["baz"], 123)
if __name__ == "__main__":