diff --git a/Makefile b/Makefile index e8dcd952..ac914a72 100644 --- a/Makefile +++ b/Makefile @@ -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)..." diff --git a/cli/generate_default_applications.py b/cli/generate_defaults_applications.py similarity index 92% rename from cli/generate_default_applications.py rename to cli/generate_defaults_applications.py index aa5e5e1a..102727d8 100644 --- a/cli/generate_default_applications.py +++ b/cli/generate_defaults_applications.py @@ -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) diff --git a/group_vars/all/00_general.yml b/group_vars/all/00_general.yml index 8caa5801..c59f1339 100644 --- a/group_vars/all/00_general.yml +++ b/group_vars/all/00_general.yml @@ -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') }}" \ No newline at end of file diff --git a/requirements.yml b/requirements.yml index b39faafe..24529798 100644 --- a/requirements.yml +++ b/requirements.yml @@ -3,6 +3,4 @@ collections: - name: community.general pacman: - ansible - - python-passlib -pkgmgr: - - j2r \ No newline at end of file + - python-passlib \ No newline at end of file diff --git a/roles/nginx-serve-assets/templates/configuration.yml.j2 b/roles/nginx-serve-assets/templates/configuration.yml.j2 deleted file mode 100644 index 666deb80..00000000 --- a/roles/nginx-serve-assets/templates/configuration.yml.j2 +++ /dev/null @@ -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 \ No newline at end of file diff --git a/roles/nginx-serve-assets/vars/configuration.yml b/roles/nginx-serve-assets/vars/configuration.yml new file mode 100644 index 00000000..10bc1bc5 --- /dev/null +++ b/roles/nginx-serve-assets/vars/configuration.yml @@ -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 \ No newline at end of file diff --git a/templates/vars/applications.yml.j2 b/templates/vars/applications.yml.j2 deleted file mode 100644 index 83244eef..00000000 --- a/templates/vars/applications.yml.j2 +++ /dev/null @@ -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') }}" \ No newline at end of file diff --git a/templates/vars/features.yml.j2 b/templates/vars/features.yml.j2 deleted file mode 100644 index 00146e78..00000000 --- a/templates/vars/features.yml.j2 +++ /dev/null @@ -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 %} diff --git a/tests/unit/test_generate_default_applications.py b/tests/unit/test_generate_default_applications.py index 04dc032a..c4bde332 100644 --- a/tests/unit/test_generate_default_applications.py +++ b/tests/unit/test_generate_default_applications.py @@ -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__":