diff --git a/Makefile b/Makefile index 9e3c6dc6..0c1db72b 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,56 @@ -ROLES_DIR := ./roles -APPLICATIONS_OUT := ./group_vars/all/04_applications.yml +ROLES_DIR := ./roles +APPLICATIONS_OUT := ./group_vars/all/04_applications.yml APPLICATIONS_SCRIPT := ./cli/generate_applications.py -USERS_OUT := ./group_vars/all/03_users.yml -USERS_SCRIPT := ./cli/generate_users.py -INCLUDES_OUT := ./tasks/utils/server-roles.yml -INCLUDES_SCRIPT := ./cli/generate_playbook.py +USERS_OUT := ./group_vars/all/03_users.yml +USERS_SCRIPT := ./cli/generate_users.py +INCLUDES_SCRIPT := ./cli/generate_playbook.py +# Define the prefixes for which we want individual role-include files +INCLUDE_GROUPS := "web-" "svc-" + +# Directory where these include-files will be written +INCLUDES_OUT_DIR := ./tasks/groups + +# Compute extra users as before EXTRA_USERS := $(shell \ - find $(ROLES_DIR) -maxdepth 1 -type d -name '*' -printf '%f\n' \ - | sed -E 's/.*-//' \ - | grep -E -x '[a-z0-9]+' \ - | sort -u \ - | paste -sd, - \ + find $(ROLES_DIR) -maxdepth 1 -type d -printf '%f\n' \ + | sed -E 's/.*-//' \ + | grep -E -x '[a-z0-9]+' \ + | sort -u \ + | paste -sd, - \ ) .PHONY: build install test build: - @echo "🔧 Generating applications defaults → $(APPLICATIONS_OUT) from roles in $(ROLES_DIR)…" - python3 $(USERS_SCRIPT) --roles-dir $(ROLES_DIR) --output $(USERS_OUT) --extra-users "$(EXTRA_USERS)" + @echo "🔧 Generating users defaults → $(USERS_OUT)…" + python3 $(USERS_SCRIPT) \ + --roles-dir $(ROLES_DIR) \ + --output $(USERS_OUT) \ + --extra-users "$(EXTRA_USERS)" @echo "✅ Users defaults written to $(USERS_OUT)\n" - python3 $(APPLICATIONS_SCRIPT) --roles-dir $(ROLES_DIR) --output-file $(APPLICATIONS_OUT) + + @echo "🔧 Generating applications defaults → $(APPLICATIONS_OUT)…" + python3 $(APPLICATIONS_SCRIPT) \ + --roles-dir $(ROLES_DIR) \ + --output-file $(APPLICATIONS_OUT) @echo "✅ Applications defaults written to $(APPLICATIONS_OUT)\n" - @echo "🔧 Generating users defaults → $(USERS_OUT) from roles in $(ROLES_DIR)…" - @echo "🔧 Generating Docker role includes → $(INCLUDES_OUT)…" - @mkdir -p $(dir $(INCLUDES_OUT)) - python3 $(INCLUDES_SCRIPT) $(ROLES_DIR) -o $(INCLUDES_OUT) \ - -p web-app \ - -p web-svc \ - -p svc-openldap \ - -p svc-rdbms-postgres \ - -p svc-rdbms-mariadb - @echo "✅ Docker role includes written to $(INCLUDES_OUT)" + + @echo "🔧 Generating role-include files for each group…" + @mkdir -p $(INCLUDES_OUT_DIR) + @$(foreach grp,$(INCLUDE_GROUPS), \ + out=$(INCLUDES_OUT_DIR)/$(grp)roles.yml; \ + echo "→ Building $$out (pattern: '$(grp)')…"; \ + python3 $(INCLUDES_SCRIPT) $(ROLES_DIR) \ + -p $(grp) -o $$out; \ + echo " ✅ $$out"; \ + ) install: build @echo "⚙️ Install complete." test: - @echo "🧪 Running Python Tests..." + @echo "🧪 Running Python tests…" python -m unittest discover -s tests - @echo "📑 Syntax Checking Ansible Playbook..." + @echo "📑 Checking Ansible syntax…" ansible-playbook playbook.yml --syntax-check diff --git a/roles/cmp-db-docker/README.md b/roles/cmp-db-docker/README.md index 045edd5c..e9a21e11 100644 --- a/roles/cmp-db-docker/README.md +++ b/roles/cmp-db-docker/README.md @@ -1,18 +1,18 @@ # Database Docker Composition -This role combines the central RDBMS role (`svc-rdbms-central`) with Docker Compose to deliver a ready-to-use containerized database environment. +This role combines the central RDBMS role (`cmp-rdbms-orchestrator`) with Docker Compose to deliver a ready-to-use containerized database environment. ## Features - **Central RDBMS Integration** - Includes the `svc-rdbms-central` role, which handles backups, restores, user and permission management for your relational database system (PostgreSQL, MariaDB, etc.). + Includes the `cmp-rdbms-orchestrator` role, which handles backups, restores, user and permission management for your relational database system (PostgreSQL, MariaDB, etc.). - **Docker Compose** Utilizes the standalone `docker-compose` role to define and bring up containers, networks, and volumes automatically. - **Variable Load Order** 1. Docker Compose variables (`roles/docker-compose/vars/docker-compose.yml`) - 2. Database variables (`roles/svc-rdbms-central/vars/database.yml`) + 2. Database variables (`roles/cmp-rdbms-orchestrator/vars/database.yml`) Ensures compose ports and volumes are defined before the database role consumes them. The role will load both sub-roles and satisfy all dependencies transparently. @@ -22,4 +22,4 @@ The role will load both sub-roles and satisfy all dependencies transparently. 1. **Set Fact** `database_application_id` to work around lazy‐loading ordering. 2. **Include Vars** in the specified order. 3. **Invoke** `docker-compose` role to create containers, networks, and volumes. -4. **Invoke** `svc-rdbms-central` role to provision the database, backups, and users. \ No newline at end of file +4. **Invoke** `cmp-rdbms-orchestrator` role to provision the database, backups, and users. \ No newline at end of file diff --git a/roles/cmp-db-docker/tasks/main.yml b/roles/cmp-db-docker/tasks/main.yml index d168a648..6310df87 100644 --- a/roles/cmp-db-docker/tasks/main.yml +++ b/roles/cmp-db-docker/tasks/main.yml @@ -14,4 +14,4 @@ - name: "Load central rdbms for {{ application_id }}" include_role: - name: svc-rdbms-central \ No newline at end of file + name: cmp-rdbms-orchestrator \ No newline at end of file diff --git a/roles/cmp-db-docker/vars/main.yml b/roles/cmp-db-docker/vars/main.yml index e684413d..cbb7f293 100644 --- a/roles/cmp-db-docker/vars/main.yml +++ b/roles/cmp-db-docker/vars/main.yml @@ -1,2 +1,2 @@ -cmp_db_docker_vars_file_db: "{{ playbook_dir }}/roles/svc-rdbms-central/vars/database.yml" +cmp_db_docker_vars_file_db: "{{ playbook_dir }}/roles/cmp-rdbms-orchestrator/vars/database.yml" cmp_db_docker_vars_file_docker: "{{ playbook_dir }}/roles/docker-compose/vars/docker-compose.yml" \ No newline at end of file diff --git a/roles/svc-rdbms-central/README.md b/roles/cmp-rdbms-orchestrator/README.md similarity index 100% rename from roles/svc-rdbms-central/README.md rename to roles/cmp-rdbms-orchestrator/README.md diff --git a/roles/svc-rdbms-central/meta/main.yml b/roles/cmp-rdbms-orchestrator/meta/main.yml similarity index 100% rename from roles/svc-rdbms-central/meta/main.yml rename to roles/cmp-rdbms-orchestrator/meta/main.yml diff --git a/roles/svc-rdbms-central/tasks/main.yml b/roles/cmp-rdbms-orchestrator/tasks/main.yml similarity index 100% rename from roles/svc-rdbms-central/tasks/main.yml rename to roles/cmp-rdbms-orchestrator/tasks/main.yml diff --git a/roles/svc-rdbms-central/templates/configuration.yml.j2 b/roles/cmp-rdbms-orchestrator/templates/configuration.yml.j2 similarity index 100% rename from roles/svc-rdbms-central/templates/configuration.yml.j2 rename to roles/cmp-rdbms-orchestrator/templates/configuration.yml.j2 diff --git a/roles/svc-rdbms-central/templates/env/mariadb.env.j2 b/roles/cmp-rdbms-orchestrator/templates/env/mariadb.env.j2 similarity index 100% rename from roles/svc-rdbms-central/templates/env/mariadb.env.j2 rename to roles/cmp-rdbms-orchestrator/templates/env/mariadb.env.j2 diff --git a/roles/svc-rdbms-central/templates/env/postgres.env.j2 b/roles/cmp-rdbms-orchestrator/templates/env/postgres.env.j2 similarity index 100% rename from roles/svc-rdbms-central/templates/env/postgres.env.j2 rename to roles/cmp-rdbms-orchestrator/templates/env/postgres.env.j2 diff --git a/roles/cmp-rdbms-orchestrator/templates/services/main.yml.j2 b/roles/cmp-rdbms-orchestrator/templates/services/main.yml.j2 new file mode 100644 index 00000000..fca3c44c --- /dev/null +++ b/roles/cmp-rdbms-orchestrator/templates/services/main.yml.j2 @@ -0,0 +1 @@ +{% include 'roles/cmp-rdbms-orchestrator/templates/services/' + database_type + '.yml.j2' %} \ No newline at end of file diff --git a/roles/svc-rdbms-central/templates/services/mariadb.yml.j2 b/roles/cmp-rdbms-orchestrator/templates/services/mariadb.yml.j2 similarity index 100% rename from roles/svc-rdbms-central/templates/services/mariadb.yml.j2 rename to roles/cmp-rdbms-orchestrator/templates/services/mariadb.yml.j2 diff --git a/roles/svc-rdbms-central/templates/services/postgres.yml.j2 b/roles/cmp-rdbms-orchestrator/templates/services/postgres.yml.j2 similarity index 100% rename from roles/svc-rdbms-central/templates/services/postgres.yml.j2 rename to roles/cmp-rdbms-orchestrator/templates/services/postgres.yml.j2 diff --git a/roles/svc-rdbms-central/vars/database.yml b/roles/cmp-rdbms-orchestrator/vars/database.yml similarity index 100% rename from roles/svc-rdbms-central/vars/database.yml rename to roles/cmp-rdbms-orchestrator/vars/database.yml diff --git a/roles/desk-nextcloud/README.md b/roles/desk-nextcloud-client/README.md similarity index 100% rename from roles/desk-nextcloud/README.md rename to roles/desk-nextcloud-client/README.md diff --git a/roles/desk-nextcloud/meta/main.yml b/roles/desk-nextcloud-client/meta/main.yml similarity index 100% rename from roles/desk-nextcloud/meta/main.yml rename to roles/desk-nextcloud-client/meta/main.yml diff --git a/roles/desk-nextcloud/tasks/main.yml b/roles/desk-nextcloud-client/tasks/main.yml similarity index 100% rename from roles/desk-nextcloud/tasks/main.yml rename to roles/desk-nextcloud-client/tasks/main.yml diff --git a/roles/desk-nextcloud/vars/main.yml b/roles/desk-nextcloud-client/vars/main.yml similarity index 100% rename from roles/desk-nextcloud/vars/main.yml rename to roles/desk-nextcloud-client/vars/main.yml diff --git a/roles/docker-compose/templates/base.yml.j2 b/roles/docker-compose/templates/base.yml.j2 index b16dee9d..03a284f6 100644 --- a/roles/docker-compose/templates/base.yml.j2 +++ b/roles/docker-compose/templates/base.yml.j2 @@ -2,7 +2,7 @@ services: {# Load Database #} {% if applications[application_id].docker.services.database.enabled | default(false) | bool %} -{% include 'roles/svc-rdbms-central/templates/services/main.yml.j2' %} +{% include 'roles/cmp-rdbms-orchestrator/templates/services/main.yml.j2' %} {% endif %} {# Load Redis #} {% if applications[application_id].docker.services.redis.enabled | default(false) | bool %} diff --git a/roles/svc-rdbms-central/templates/services/main.yml.j2 b/roles/svc-rdbms-central/templates/services/main.yml.j2 deleted file mode 100644 index 5174ca10..00000000 --- a/roles/svc-rdbms-central/templates/services/main.yml.j2 +++ /dev/null @@ -1 +0,0 @@ -{% include 'roles/svc-rdbms-central/templates/services/' + database_type + '.yml.j2' %} \ No newline at end of file diff --git a/roles/util-srv-corporate-identity/meta/main.yml b/roles/util-srv-corporate-identity/meta/main.yml index 24b87bc1..bd9f2d07 100644 --- a/roles/util-srv-corporate-identity/meta/main.yml +++ b/roles/util-srv-corporate-identity/meta/main.yml @@ -25,5 +25,5 @@ galaxy_info: documentation: https://s.veen.world/cymais dependencies: - web-svc-legal - - web-svc-assets + - web-svc-asset - web-app-portfolio \ No newline at end of file diff --git a/roles/web-app-discourse/tasks/reset.yml b/roles/web-app-discourse/tasks/reset.yml index aedac923..3ef8e8b8 100644 --- a/roles/web-app-discourse/tasks/reset.yml +++ b/roles/web-app-discourse/tasks/reset.yml @@ -1,5 +1,5 @@ - name: "Load database variables for reset function" - include_vars: "{{playbook_dir}}/roles/svc-rdbms-central/vars/main.yml" + include_vars: "{{playbook_dir}}/roles/cmp-rdbms-orchestrator/vars/main.yml" - name: "cleanup central database from {{application_id}}_default network" command: diff --git a/roles/web-app-espocrm/README.md b/roles/web-app-espocrm/README.md index cc2e27f7..62a7225c 100644 --- a/roles/web-app-espocrm/README.md +++ b/roles/web-app-espocrm/README.md @@ -8,7 +8,7 @@ Enhance your sales and service processes with EspoCRM, an open-source CRM featur This Ansible role deploys EspoCRM using Docker. It handles: -- MariaDB database provisioning via the `svc-rdbms-central` role +- MariaDB database provisioning via the `cmp-rdbms-orchestrator` role - Nginx domain setup with WebSocket and reverse-proxy configuration - Environment variable management through Jinja2 templates - Docker Compose orchestration for **web**, **daemon**, and **websocket** services diff --git a/roles/web-app-friendica/meta/main.yml b/roles/web-app-friendica/meta/main.yml index 345e305a..3d113c60 100644 --- a/roles/web-app-friendica/meta/main.yml +++ b/roles/web-app-friendica/meta/main.yml @@ -21,4 +21,3 @@ galaxy_info: run_after: - web-app-matomo - web-app-keycloak - - svc-openldap diff --git a/roles/web-app-funkwhale/meta/main.yml b/roles/web-app-funkwhale/meta/main.yml index 50be2eb9..95637253 100644 --- a/roles/web-app-funkwhale/meta/main.yml +++ b/roles/web-app-funkwhale/meta/main.yml @@ -21,5 +21,4 @@ galaxy_info: run_after: - web-app-matomo - web-app-keycloak - - web-app-mailu - - svc-openldap \ No newline at end of file + - web-app-mailu \ No newline at end of file diff --git a/roles/web-app-keycloak/meta/main.yml b/roles/web-app-keycloak/meta/main.yml index 32723d3b..fab8bae0 100644 --- a/roles/web-app-keycloak/meta/main.yml +++ b/roles/web-app-keycloak/meta/main.yml @@ -20,5 +20,4 @@ galaxy_info: logo: class: "fa-solid fa-lock" run_after: - - web-app-matomo - - svc-openldap + - web-app-matomo \ No newline at end of file diff --git a/roles/web-app-matomo/meta/main.yml b/roles/web-app-matomo/meta/main.yml index 13894cd4..f2f17e56 100644 --- a/roles/web-app-matomo/meta/main.yml +++ b/roles/web-app-matomo/meta/main.yml @@ -17,6 +17,4 @@ galaxy_info: issue_tracker_url: "https://s.veen.world/cymaisissues" documentation: "https://s.veen.world/cymais" logo: - class: "fa-solid fa-chart-line" - run_after: - - "svc-rdbms-postgres" \ No newline at end of file + class: "fa-solid fa-chart-line" \ No newline at end of file diff --git a/roles/web-app-mobilizon/meta/main.yml b/roles/web-app-mobilizon/meta/main.yml index 8cc9bb02..7b28c724 100644 --- a/roles/web-app-mobilizon/meta/main.yml +++ b/roles/web-app-mobilizon/meta/main.yml @@ -21,6 +21,4 @@ galaxy_info: run_after: - web-app-matomo - web-app-keycloak - - web-app-mailu - - svc-openldap - - svc-rdbms-postgres + - web-app-mailu \ No newline at end of file diff --git a/roles/web-app-nextcloud/meta/main.yml b/roles/web-app-nextcloud/meta/main.yml index a75063e3..f2d48409 100644 --- a/roles/web-app-nextcloud/meta/main.yml +++ b/roles/web-app-nextcloud/meta/main.yml @@ -32,4 +32,3 @@ galaxy_info: - web-app-collabora - web-app-keycloak - web-app-mastodon - - svc-rdbms-mariadb diff --git a/roles/web-app-phpldapadmin/meta/main.yml b/roles/web-app-phpldapadmin/meta/main.yml index 7a0ce8cd..ad176d3a 100644 --- a/roles/web-app-phpldapadmin/meta/main.yml +++ b/roles/web-app-phpldapadmin/meta/main.yml @@ -24,6 +24,5 @@ galaxy_info: logo: class: "fa-solid fa-user-lock" run_after: - - svc-openldap - web-app-matomo - web-app-keycloak diff --git a/roles/web-app-phpmyadmin/meta/main.yml b/roles/web-app-phpmyadmin/meta/main.yml index 2cb8872b..ce0f68e6 100644 --- a/roles/web-app-phpmyadmin/meta/main.yml +++ b/roles/web-app-phpmyadmin/meta/main.yml @@ -26,6 +26,5 @@ galaxy_info: logo: class: "fa-solid fa-database" run_after: - - svc-rdbms-mariadb - web-app-matomo - web-app-keycloak \ No newline at end of file diff --git a/roles/web-app-taiga/meta/main.yml b/roles/web-app-taiga/meta/main.yml index a722a02e..c9e767e5 100644 --- a/roles/web-app-taiga/meta/main.yml +++ b/roles/web-app-taiga/meta/main.yml @@ -29,6 +29,5 @@ galaxy_info: logo: class: "fa-solid fa-tasks" run_after: - - svc-rdbms-postgres - web-app-matomo - web-app-keycloak diff --git a/roles/web-app-yourls/meta/main.yml b/roles/web-app-yourls/meta/main.yml index c67698f7..938d9f90 100644 --- a/roles/web-app-yourls/meta/main.yml +++ b/roles/web-app-yourls/meta/main.yml @@ -25,6 +25,5 @@ galaxy_info: logo: class: "fa-solid fa-link" run_after: - - svc-rdbms-mariadb - web-app-matomo - web-app-keycloak \ No newline at end of file diff --git a/roles/web-svc-assets/README.md b/roles/web-svc-asset/README.md similarity index 100% rename from roles/web-svc-assets/README.md rename to roles/web-svc-asset/README.md diff --git a/roles/web-svc-assets/config/main.yml b/roles/web-svc-asset/config/main.yml similarity index 100% rename from roles/web-svc-assets/config/main.yml rename to roles/web-svc-asset/config/main.yml diff --git a/roles/web-svc-assets/meta/main.yml b/roles/web-svc-asset/meta/main.yml similarity index 93% rename from roles/web-svc-assets/meta/main.yml rename to roles/web-svc-asset/meta/main.yml index 26d081a1..ccbb5e95 100644 --- a/roles/web-svc-assets/meta/main.yml +++ b/roles/web-svc-asset/meta/main.yml @@ -14,11 +14,11 @@ galaxy_info: - static repository: "https://github.com/kevinveenbirkenbach/cymais" issue_tracker_url: "https://github.com/kevinveenbirkenbach/cymais/issues" - documentation: "https://github.com/kevinveenbirkenbach/cymais/tree/main/roles/web-svc-assets" + documentation: "https://github.com/kevinveenbirkenbach/cymais/tree/main/roles/web-svc-asset" min_ansible_version: "2.9" platforms: - name: Any versions: - all dependencies: - - web-svc-files + - web-svc-file diff --git a/roles/web-svc-assets/tasks/main.yml b/roles/web-svc-asset/tasks/main.yml similarity index 100% rename from roles/web-svc-assets/tasks/main.yml rename to roles/web-svc-asset/tasks/main.yml diff --git a/roles/web-svc-assets/vars/main.yml b/roles/web-svc-asset/vars/main.yml similarity index 71% rename from roles/web-svc-assets/vars/main.yml rename to roles/web-svc-asset/vars/main.yml index 266789a6..c94bccf7 100644 --- a/roles/web-svc-assets/vars/main.yml +++ b/roles/web-svc-asset/vars/main.yml @@ -1,3 +1,3 @@ -application_id: "assets-server" # Application identifier +application_id: "asset" # Application identifier source_directory: "{{ applications[application_id].source_directory }}/" # Source directory from which the files are coming from target_directory: "{{ nginx.directories.data.files }}assets" # Directory to which the files will be copied diff --git a/roles/web-svc-files/README.md b/roles/web-svc-file/README.md similarity index 100% rename from roles/web-svc-files/README.md rename to roles/web-svc-file/README.md diff --git a/roles/web-svc-files/config/main.yml b/roles/web-svc-file/config/main.yml similarity index 100% rename from roles/web-svc-files/config/main.yml rename to roles/web-svc-file/config/main.yml diff --git a/roles/web-svc-files/meta/main.yml b/roles/web-svc-file/meta/main.yml similarity index 100% rename from roles/web-svc-files/meta/main.yml rename to roles/web-svc-file/meta/main.yml diff --git a/roles/web-svc-files/tasks/main.yml b/roles/web-svc-file/tasks/main.yml similarity index 100% rename from roles/web-svc-files/tasks/main.yml rename to roles/web-svc-file/tasks/main.yml diff --git a/roles/web-svc-files/templates/nginx.conf.j2 b/roles/web-svc-file/templates/nginx.conf.j2 similarity index 100% rename from roles/web-svc-files/templates/nginx.conf.j2 rename to roles/web-svc-file/templates/nginx.conf.j2 diff --git a/roles/web-svc-files/vars/main.yml b/roles/web-svc-file/vars/main.yml similarity index 67% rename from roles/web-svc-files/vars/main.yml rename to roles/web-svc-file/vars/main.yml index c8609e8b..de6538c1 100644 --- a/roles/web-svc-files/vars/main.yml +++ b/roles/web-svc-file/vars/main.yml @@ -1,2 +1,2 @@ -application_id: "file-server" +application_id: "file" domain: "{{ domains | get_domain(application_id) }}" diff --git a/roles/web-svc-html/vars/main.yml b/roles/web-svc-html/vars/main.yml index c4c86a55..d008760a 100644 --- a/roles/web-svc-html/vars/main.yml +++ b/roles/web-svc-html/vars/main.yml @@ -1,4 +1,4 @@ -application_id: "html-server" +application_id: "html" domain: "{{domains | get_domain(application_id)}}" features: portfolio_iframe: true # Necessary for imprint loading \ No newline at end of file diff --git a/roles/web-svc-legal/vars/main.yml b/roles/web-svc-legal/vars/main.yml index b132884a..6993e56a 100644 --- a/roles/web-svc-legal/vars/main.yml +++ b/roles/web-svc-legal/vars/main.yml @@ -1 +1 @@ -application_id: "legal" # Application identifier \ No newline at end of file +application_id: "legal" \ No newline at end of file diff --git a/roles/web-redirect-domains/README.md b/roles/web-svc-redir-domains/README.md similarity index 100% rename from roles/web-redirect-domains/README.md rename to roles/web-svc-redir-domains/README.md diff --git a/roles/web-redirect-domains/meta/main.yml b/roles/web-svc-redir-domains/meta/main.yml similarity index 94% rename from roles/web-redirect-domains/meta/main.yml rename to roles/web-svc-redir-domains/meta/main.yml index 606c8b3d..93d35be8 100644 --- a/roles/web-redirect-domains/meta/main.yml +++ b/roles/web-svc-redir-domains/meta/main.yml @@ -14,7 +14,7 @@ galaxy_info: - domains repository: "https://github.com/kevinveenbirkenbach/cymais" issue_tracker_url: "https://github.com/kevinveenbirkenbach/cymais/issues" - documentation: "https://github.com/kevinveenbirkenbach/cymais/tree/main/roles/web-redirect-domains" + documentation: "https://github.com/kevinveenbirkenbach/cymais/tree/main/roles/web-svc-redir-domains" min_ansible_version: "2.9" platforms: - name: Any diff --git a/roles/web-redirect-domains/tasks/main.yml b/roles/web-svc-redir-domains/tasks/main.yml similarity index 100% rename from roles/web-redirect-domains/tasks/main.yml rename to roles/web-svc-redir-domains/tasks/main.yml diff --git a/roles/web-redirect-domains/tasks/redirect-domain.yml b/roles/web-svc-redir-domains/tasks/redirect-domain.yml similarity index 100% rename from roles/web-redirect-domains/tasks/redirect-domain.yml rename to roles/web-svc-redir-domains/tasks/redirect-domain.yml diff --git a/roles/web-redirect-domains/templates/redirect.domain.nginx.conf.j2 b/roles/web-svc-redir-domains/templates/redirect.domain.nginx.conf.j2 similarity index 100% rename from roles/web-redirect-domains/templates/redirect.domain.nginx.conf.j2 rename to roles/web-svc-redir-domains/templates/redirect.domain.nginx.conf.j2 diff --git a/roles/web-svc-redir-domains/vars/main.yml b/roles/web-svc-redir-domains/vars/main.yml new file mode 100644 index 00000000..a03da976 --- /dev/null +++ b/roles/web-svc-redir-domains/vars/main.yml @@ -0,0 +1 @@ +application_id: "redir-domains" \ No newline at end of file diff --git a/roles/web-redirect-www/README.md b/roles/web-svc-redir-www/README.md similarity index 95% rename from roles/web-redirect-www/README.md rename to roles/web-svc-redir-www/README.md index 3899384c..ccf3e482 100644 --- a/roles/web-redirect-www/README.md +++ b/roles/web-svc-redir-www/README.md @@ -7,7 +7,7 @@ Automates the creation of Nginx server blocks that redirect all `www.` subdomain This role will: - **Discover** existing `*.conf` vhosts in your Nginx servers directory - **Filter** domains with or without your `primary_domain` -- **Generate** redirect rules via the `web-redirect-domains` role +- **Generate** redirect rules via the `web-svc-redir-domains` role - **Optionally** include a wildcard redirect template (experimental) ⭐️ - **Clean up** leftover configs when running in cleanup mode 🧹 diff --git a/roles/web-redirect-www/meta/main.yml b/roles/web-svc-redir-www/meta/main.yml similarity index 100% rename from roles/web-redirect-www/meta/main.yml rename to roles/web-svc-redir-www/meta/main.yml diff --git a/roles/web-redirect-www/tasks/main.yml b/roles/web-svc-redir-www/tasks/main.yml similarity index 87% rename from roles/web-redirect-www/tasks/main.yml rename to roles/web-svc-redir-www/tasks/main.yml index e60f6b7c..03c48f59 100644 --- a/roles/web-redirect-www/tasks/main.yml +++ b/roles/web-svc-redir-www/tasks/main.yml @@ -3,9 +3,9 @@ set_fact: www_domains: "{{ current_play_domains_all | select('match', '^www\\.') | list }}" -- name: Include web-redirect-domains role for www-to-bare redirects +- name: Include web-svc-redir-domains role for www-to-bare redirects include_role: - name: web-redirect-domains + name: web-svc-redir-domains vars: domain_mappings: "{{ www_domains | map('regex_replace', diff --git a/roles/web-svc-redir-www/vars/main.yml b/roles/web-svc-redir-www/vars/main.yml new file mode 100644 index 00000000..920eea5c --- /dev/null +++ b/roles/web-svc-redir-www/vars/main.yml @@ -0,0 +1 @@ +application_id: "redir-www" \ No newline at end of file diff --git a/tasks/groups/.gitignore b/tasks/groups/.gitignore new file mode 100644 index 00000000..4515f4cd --- /dev/null +++ b/tasks/groups/.gitignore @@ -0,0 +1 @@ +*-roles.yml diff --git a/tasks/plays/02_personal-computer.yml b/tasks/plays/02_personal-computer.yml index 1cb18a8c..863c3957 100644 --- a/tasks/plays/02_personal-computer.yml +++ b/tasks/plays/02_personal-computer.yml @@ -69,7 +69,7 @@ - name: setup nextcloud-client when: ("nextcloud_client" in group_names) include_role: - name: desk-nextcloud + name: desk-nextcloud-client - name: setup docker when: ("docker_client" in group_names) diff --git a/tasks/plays/02_server.yml b/tasks/plays/02_server.yml index c03cd5d0..1e61eca8 100644 --- a/tasks/plays/02_server.yml +++ b/tasks/plays/02_server.yml @@ -12,29 +12,14 @@ - maint-btrfs-auto-balancer - name: "Integrate Docker Role includes" - include_tasks: "./tasks/utils/server-roles.yml" - -# Native Webserver Roles -- name: setup web-svc-htmls - include_role: - name: web-svc-html - vars: - domain: "{{primary_domain}}" - when: ('web-svc-htmls' | application_allowed(group_names, allowed_applications)) + include_tasks: "./tasks/groups/{{ item }}-roles.yml" + loop: + - svc + - web + loop_control: + label: "{{ item }}-roles.yml" - name: "setup corporate identity" include_role: name: util-srv-corporate-identity - when: ('corporate_identity' | application_allowed(group_names, allowed_applications)) - -- name: setup redirect hosts - when: ('redirect' | application_allowed(group_names, allowed_applications)) - include_role: - name: web-redirect-domains - vars: - domain_mappings: "{{ current_play_domain_mappings_redirect}}" - -- name: setup www redirect - when: ('www_redirect' | application_allowed(group_names, allowed_applications)) - include_role: - name: web-redirect-www \ No newline at end of file + when: ('corporate_identity' | application_allowed(group_names, allowed_applications)) \ No newline at end of file diff --git a/tasks/utils/.gitignore b/tasks/utils/.gitignore deleted file mode 100644 index c6b775e3..00000000 --- a/tasks/utils/.gitignore +++ /dev/null @@ -1 +0,0 @@ -server-roles.yml diff --git a/tests/integration/test_application_id_consistency.py b/tests/integration/test_application_id_consistency.py index 0bc9cdd3..b7639555 100644 --- a/tests/integration/test_application_id_consistency.py +++ b/tests/integration/test_application_id_consistency.py @@ -9,32 +9,43 @@ ROLES_DIR = Path(__file__).resolve().parent.parent.parent / "roles" class TestApplicationIdConsistency(unittest.TestCase): def test_application_id_matches_docker_prefix(self): failed_roles = [] + prefixes = ("web-app-", "web-svc-") for role_path in ROLES_DIR.iterdir(): - if role_path.name in ["docker-container","docker-compose", "svc-rdbms-central", "docker-repository-setup"]: + if not role_path.is_dir(): continue - - if role_path.is_dir() and role_path.name.startswith("web-app-"): - expected_id = role_path.name.replace("web-app-", "", 1) - vars_file = role_path / "vars" / "main.yml" - if not vars_file.exists(): - failed_roles.append((role_path.name, "vars/main.yml missing")) + role_name = role_path.name + # check if the role name starts with one of our prefixes + matching = [p for p in prefixes if role_name.startswith(p)] + if not matching: + continue + + prefix = matching[0] + # expected_id is just the remainder after the prefix + expected_id = role_name[len(prefix):] + + vars_file = role_path / "vars" / "main.yml" + if not vars_file.exists(): + failed_roles.append((role_name, "vars/main.yml missing")) + continue + + with open(vars_file, "r") as f: + try: + vars_data = yaml.safe_load(f) or {} + except yaml.YAMLError as e: + failed_roles.append((role_name, f"YAML error: {e}")) continue - with open(vars_file, "r") as f: - try: - vars_data = yaml.safe_load(f) or {} - except yaml.YAMLError as e: - failed_roles.append((role_path.name, f"YAML error: {e}")) - continue - - actual_id = vars_data.get("application_id") - if actual_id != expected_id: - failed_roles.append((role_path.name, f"application_id is '{actual_id}', expected '{expected_id}'")) + actual_id = vars_data.get("application_id") + if actual_id != expected_id: + failed_roles.append(( + role_name, + f"application_id is '{actual_id}', expected '{expected_id}'" + )) if failed_roles: - msg = "\n".join([f"{role}: {reason}" for role, reason in failed_roles]) + msg = "\n".join(f"{r}: {reason}" for r, reason in failed_roles) self.fail(f"The following roles have mismatching or missing application_id:\n{msg}")