mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-05-10 07:15:43 +02:00
Solved some variable bugs and cleaned up
This commit is contained in:
parent
0d8027c908
commit
e7c193f409
4
Makefile
4
Makefile
@ -1,8 +1,6 @@
|
|||||||
# Makefile for j2render
|
|
||||||
|
|
||||||
ROLES_DIR=./roles
|
ROLES_DIR=./roles
|
||||||
OUTPUT=./group_vars/all/11_applications.yml
|
OUTPUT=./group_vars/all/11_applications.yml
|
||||||
SCRIPT=./cli/generate_default_applications.py
|
SCRIPT=./cli/generate_defaults_applications.py
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "🔧 Generating $(OUTPUT) from roles in $(ROLES_DIR)..."
|
@echo "🔧 Generating $(OUTPUT) from roles in $(ROLES_DIR)..."
|
||||||
|
@ -13,7 +13,7 @@ def load_yaml_file(path):
|
|||||||
return yaml.safe_load(f) or {}
|
return yaml.safe_load(f) or {}
|
||||||
|
|
||||||
def main():
|
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("--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")
|
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)
|
output_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
result = {"default_applications": {}}
|
result = {"defaults_applications": {}}
|
||||||
|
|
||||||
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
|
||||||
@ -48,7 +48,7 @@ def main():
|
|||||||
|
|
||||||
config_data = load_yaml_file(config_file)
|
config_data = load_yaml_file(config_file)
|
||||||
if config_data:
|
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:
|
with output_file.open("w", encoding="utf-8") as f:
|
||||||
yaml.dump(result, f, sort_keys=False)
|
yaml.dump(result, f, sort_keys=False)
|
@ -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_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_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
|
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') }}"
|
@ -4,5 +4,3 @@ collections:
|
|||||||
pacman:
|
pacman:
|
||||||
- ansible
|
- ansible
|
||||||
- python-passlib
|
- python-passlib
|
||||||
pkgmgr:
|
|
||||||
- j2r
|
|
@ -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
|
|
2
roles/nginx-serve-assets/vars/configuration.yml
Normal file
2
roles/nginx-serve-assets/vars/configuration.yml
Normal 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
|
@ -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') }}"
|
|
@ -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 %}
|
|
@ -29,7 +29,7 @@ class TestGenerateDefaultApplications(unittest.TestCase):
|
|||||||
shutil.rmtree(self.temp_dir)
|
shutil.rmtree(self.temp_dir)
|
||||||
|
|
||||||
def test_script_generates_expected_yaml(self):
|
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(
|
result = subprocess.run(
|
||||||
[
|
[
|
||||||
@ -45,10 +45,10 @@ class TestGenerateDefaultApplications(unittest.TestCase):
|
|||||||
self.assertTrue(self.output_file.exists(), "Output file was not created.")
|
self.assertTrue(self.output_file.exists(), "Output file was not created.")
|
||||||
|
|
||||||
data = yaml.safe_load(self.output_file.read_text())
|
data = yaml.safe_load(self.output_file.read_text())
|
||||||
self.assertIn("default_applications", data)
|
self.assertIn("defaults_applications", data)
|
||||||
self.assertIn("testapp", data["default_applications"])
|
self.assertIn("testapp", data["defaults_applications"])
|
||||||
self.assertEqual(data["default_applications"]["testapp"]["foo"], "bar")
|
self.assertEqual(data["defaults_applications"]["testapp"]["foo"], "bar")
|
||||||
self.assertEqual(data["default_applications"]["testapp"]["baz"], 123)
|
self.assertEqual(data["defaults_applications"]["testapp"]["baz"], 123)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user