diff --git a/roles/svc-db-mariadb/config/main.yml b/roles/svc-db-mariadb/config/main.yml index 90a55b43..3c09f80e 100644 --- a/roles/svc-db-mariadb/config/main.yml +++ b/roles/svc-db-mariadb/config/main.yml @@ -5,7 +5,7 @@ docker: image: "mariadb" name: "mariadb" backup: - datase_routine: true + database_routine: true network: "mariadb" volumes: data: "mariadb_data" \ No newline at end of file diff --git a/roles/svc-db-memcached/config/main.yml b/roles/svc-db-memcached/config/main.yml index 085fa5fd..2e96d0e2 100644 --- a/roles/svc-db-memcached/config/main.yml +++ b/roles/svc-db-memcached/config/main.yml @@ -4,4 +4,4 @@ docker: image: memcached version: latest backup: - enabled: false \ No newline at end of file + disabled: true \ No newline at end of file diff --git a/roles/svc-db-postgres/config/main.yml b/roles/svc-db-postgres/config/main.yml index af5a1fd2..339e2a46 100644 --- a/roles/svc-db-postgres/config/main.yml +++ b/roles/svc-db-postgres/config/main.yml @@ -8,7 +8,7 @@ docker: # Rolling release isn't recommended version: "latest" backup: - datase_routine: true + database_routine: true volumes: data: "postgres_data" network: "postgres" \ No newline at end of file diff --git a/roles/svc-db-redis/config/main.yml b/roles/svc-db-redis/config/main.yml index dddc5645..14bf37dd 100644 --- a/roles/svc-db-redis/config/main.yml +++ b/roles/svc-db-redis/config/main.yml @@ -4,4 +4,4 @@ docker: image: redis version: alpine backup: - enabled: false \ No newline at end of file + disabled: true \ No newline at end of file diff --git a/roles/sys-bkp-docker-2-loc/Todo.md b/roles/sys-bkp-docker-2-loc/Todo.md new file mode 100644 index 00000000..30202008 --- /dev/null +++ b/roles/sys-bkp-docker-2-loc/Todo.md @@ -0,0 +1,2 @@ +# Todos +- Add to all of the applications the correct backup procedures. \ No newline at end of file diff --git a/roles/sys-bkp-docker-2-loc/vars/main.yml b/roles/sys-bkp-docker-2-loc/vars/main.yml index 282b7f0e..1f69106e 100644 --- a/roles/sys-bkp-docker-2-loc/vars/main.yml +++ b/roles/sys-bkp-docker-2-loc/vars/main.yml @@ -20,17 +20,17 @@ bkp_docker_to_local_disabled: >- # CLI argument strings (only set if list not empty) bkp_docker_to_local_database_routine_cli: >- {% if bkp_docker_to_local_database_routine | length > 0 -%} - --database-containers="{{ bkp_docker_to_local_database_routine | join(' ') }}" + --database-containers {{ bkp_docker_to_local_database_routine | join(' ') }} {%- endif %} bkp_docker_to_local_no_stop_required_cli: >- {% if bkp_docker_to_local_no_stop_required | length > 0 -%} - --images-no-stop-required="{{ bkp_docker_to_local_no_stop_required | join(' ') }}" + --images-no-stop-required {{ bkp_docker_to_local_no_stop_required | join(' ') }} {%- endif %} bkp_docker_to_local_disabled_cli: >- {% if bkp_docker_to_local_disabled | length > 0 -%} - --images-no-backup-required="{{ bkp_docker_to_local_disabled | join(' ') }}" + --images-no-backup-required {{ bkp_docker_to_local_disabled | join(' ') }} {%- endif %} # List of CLI args for convenience (e.g. for looping or joining) @@ -42,5 +42,4 @@ bkp_docker_to_local_cli_args_list: bkp_docker_to_local_exec: >- /usr/bin/python {{ backup_docker_to_local_folder }}backup-docker-to-local.py --compose-dir {{ path_docker_compose_instances }} - {{ bkp_docker_to_local_cli_args_list | select('string') | join(' ') }} - | trim \ No newline at end of file + {{ bkp_docker_to_local_cli_args_list | select('string') | join(' ') }} \ No newline at end of file diff --git a/roles/web-app-nextcloud/config/main.yml b/roles/web-app-nextcloud/config/main.yml index d50d651a..c9fb0c82 100644 --- a/roles/web-app-nextcloud/config/main.yml +++ b/roles/web-app-nextcloud/config/main.yml @@ -19,15 +19,17 @@ docker: database: enabled: true nextcloud: - name: "nextcloud" - image: "nextcloud" - version: "latest-fpm-alpine" + name: "nextcloud" + image: "nextcloud" + version: "latest-fpm-alpine" backup: no_stop_required: true proxy: name: "nextcloud-proxy" image: "nginx" version: "alpine" + backup: + no_stop_required: true cron: name: "nextcloud-cron" talk: diff --git a/templates/roles/web-app/config/main.yml.j2 b/templates/roles/web-app/config/main.yml.j2 index 5071baa4..14080574 100644 --- a/templates/roles/web-app/config/main.yml.j2 +++ b/templates/roles/web-app/config/main.yml.j2 @@ -7,7 +7,9 @@ docker: enabled: false # Enable the database {{ application_id }}: backup: - no_stop_required: true + no_stop_required: true # The images that don't need to stop + disabled: true # Disables the image + database_routine: true # Instead of copying a database routine will be triggered for this container image: "" version: "latest" name: "web-app-{{ application_id }}" diff --git a/templates/roles/web-app/tasks/reset.yml.j2 b/templates/roles/web-app/tasks/reset.yml.j2 new file mode 100644 index 00000000..47f7d012 --- /dev/null +++ b/templates/roles/web-app/tasks/reset.yml.j2 @@ -0,0 +1 @@ +# This file contains reset procedures which will be executed at the begining of the role for cleanup \ No newline at end of file diff --git a/tests/integration/test_roles_naming.py b/tests/integration/test_roles_naming.py new file mode 100644 index 00000000..664861f4 --- /dev/null +++ b/tests/integration/test_roles_naming.py @@ -0,0 +1,37 @@ +import unittest +import re +from pathlib import Path + +# Regex: +# - one or more lowercase letters, digits or hyphens +# - optionally exactly one '_' followed by one or more lowercase letters, digits or hyphens +ROLE_NAME_PATTERN = re.compile(r'^[a-z0-9-]+(?:_[a-z0-9-]+)?$') + +class TestRoleNames(unittest.TestCase): + def test_role_names_follow_naming_convention(self): + # go up from tests/integration/test_roles_naming.py to project root, then into roles/ + roles_dir = Path(__file__).resolve().parents[2] / "roles" + self.assertTrue( + roles_dir.is_dir(), + f"'roles/' directory not found at {roles_dir}" + ) + + invalid_names = [] + for role_path in roles_dir.iterdir(): + if not role_path.is_dir(): + # skip non-directories + continue + + name = role_path.name + if not ROLE_NAME_PATTERN.fullmatch(name): + invalid_names.append(name) + + self.assertFalse( + invalid_names, + "The following role directory names violate the naming convention " + "(only a–z, 0–9, '-', max one '_', and '_' must be followed by at least one character):\n" + + "\n".join(f"- {n}" for n in invalid_names) + ) + +if __name__ == "__main__": + unittest.main()