From ece4fe465e79359eefb6f93b6c25ee23d01936b0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 3 Jan 2024 12:07:19 +0100 Subject: [PATCH] Removed buggy variable mapping --- constructor.yml | 11 +---------- roles/backup-docker-to-local/tasks/main.yml | 2 +- roles/backup-remote-to-local/tasks/main.yml | 2 +- roles/cleanup-backups-timer/tasks/main.yml | 2 +- roles/cleanup-disc-space/tasks/main.yml | 2 +- roles/cleanup-failed-docker-backups/tasks/main.yml | 2 +- roles/docker-discourse/templates/app.yml.j2 | 4 ++-- roles/docker-mailu/tasks/main.yml | 2 +- roles/docker-mastodon/templates/mastodon.conf.j2 | 2 +- roles/docker-nextcloud/templates/nextcloud.conf.j2 | 2 +- roles/docker-peertube/templates/peertube.conf.j2 | 2 +- roles/heal-docker/tasks/main.yml | 2 +- roles/health-btrfs/tasks/main.yml | 2 +- roles/health-disc-space/tasks/main.yml | 2 +- roles/health-docker-container/tasks/main.yml | 2 +- roles/health-docker-volumes/tasks/main.yml | 2 +- roles/health-journalctl/tasks/main.yml | 2 +- roles/health-nginx/tasks/main.yml | 2 +- roles/health-nginx/templates/health-nginx.py.j2 | 2 +- roles/nginx-certbot/tasks/main.yml | 2 +- .../templates/domain.conf.j2 | 2 +- roles/nginx-homepage/templates/homepage.nginx.conf.j2 | 2 +- roles/update-docker/tasks/main.yml | 2 +- tasks/implement-matomo-tracking.yml | 2 +- templates/docker-compose-networks.yml.j2 | 2 +- templates/docker-compose-volumes-just-database.yml.j2 | 2 +- templates/docker-compose-volumes.yml.j2 | 2 +- .../docker-container-depends-on-also-database.yml.j2 | 2 +- .../docker-container-depends-on-database-redis.yml.j2 | 2 +- .../docker-container-depends-on-just-database.yml.j2 | 2 +- templates/docker-container-networks.yml.j2 | 2 +- templates/docker-service-mariadb.yml.j2 | 2 +- templates/docker-service-postgres.yml.j2 | 2 +- 33 files changed, 34 insertions(+), 43 deletions(-) diff --git a/constructor.yml b/constructor.yml index 16a61e2d..d0715d3e 100644 --- a/constructor.yml +++ b/constructor.yml @@ -1,20 +1,11 @@ --- -- name: variable mapping - hosts: all - vars: - activate_all_timers: "{{ activate_all_timers | lower | bool }}" - nginx_matomo_tracking: "{{ nginx_matomo_tracking | lower | bool }}" - execute_updates: "{{ execute_updates | lower | bool }}" - force_backup_before_update: "{{ force_backup_before_update | lower | bool }}" - enable_central_database: "{{ enable_central_database | lower | bool }}" - name: update device hosts: all become: true - tasks: roles: - role: update - when: execute_updates + when: execute_updates | bool - name: setup standard wireguard hosts: wireguard_server diff --git a/roles/backup-docker-to-local/tasks/main.yml b/roles/backup-docker-to-local/tasks/main.yml index 3b65ced3..d436835a 100644 --- a/roles/backup-docker-to-local/tasks/main.yml +++ b/roles/backup-docker-to-local/tasks/main.yml @@ -37,7 +37,7 @@ - name: configure backup-docker-to-local.timer.tpl template: src=backup-docker-to-local.timer.j2 dest=/etc/systemd/system/backup-docker-to-local.timer register: backup_docker_to_local_timer - changed_when: backup_docker_to_local_timer.changed or activate_all_timers + changed_when: backup_docker_to_local_timer.changed or activate_all_timers | bool notify: restart backup-docker-to-local.timer when: run_once_backup_docker_to_local is not defined diff --git a/roles/backup-remote-to-local/tasks/main.yml b/roles/backup-remote-to-local/tasks/main.yml index f43489b6..57c70220 100644 --- a/roles/backup-remote-to-local/tasks/main.yml +++ b/roles/backup-remote-to-local/tasks/main.yml @@ -17,7 +17,7 @@ - name: create backup-remote-to-local.timer template: src=backup-remote-to-local.timer.j2 dest=/etc/systemd/system/backup-remote-to-local.timer register: backup_backup_remote_to_local_timer - changed_when: backup_backup_remote_to_local_timer.changed or activate_all_timers + changed_when: backup_backup_remote_to_local_timer.changed or activate_all_timers | bool notify: restart backup-remote-to-local timer - name: create backups-remote-to-local.sh diff --git a/roles/cleanup-backups-timer/tasks/main.yml b/roles/cleanup-backups-timer/tasks/main.yml index 5ee7f2bd..f15a4fc1 100644 --- a/roles/cleanup-backups-timer/tasks/main.yml +++ b/roles/cleanup-backups-timer/tasks/main.yml @@ -3,7 +3,7 @@ src: "cleanup-backups.timer.j2" dest: "/etc/systemd/system/cleanup-backups.timer" register: cleanup_backups_timer - changed_when: cleanup_backups_timer.changed or activate_all_timers + changed_when: cleanup_backups_timer.changed or activate_all_timers | bool notify: restart cleanup-backups.timer when: run_once_cleanup_backups_timer is not defined diff --git a/roles/cleanup-disc-space/tasks/main.yml b/roles/cleanup-disc-space/tasks/main.yml index a7ceb6d2..26a66e51 100644 --- a/roles/cleanup-disc-space/tasks/main.yml +++ b/roles/cleanup-disc-space/tasks/main.yml @@ -20,5 +20,5 @@ src: cleanup-disc-space.timer.j2 dest: /etc/systemd/system/cleanup-disc-space.timer register: cleanup_disc_space_timer - changed_when: cleanup_disc_space_timer.changed or activate_all_timers + changed_when: cleanup_disc_space_timer.changed or activate_all_timers | bool notify: restart cleanup-disc-space.timer \ No newline at end of file diff --git a/roles/cleanup-failed-docker-backups/tasks/main.yml b/roles/cleanup-failed-docker-backups/tasks/main.yml index a38df6a4..b36c0f18 100644 --- a/roles/cleanup-failed-docker-backups/tasks/main.yml +++ b/roles/cleanup-failed-docker-backups/tasks/main.yml @@ -24,7 +24,7 @@ src: cleanup-failed-docker-backups.timer.j2 dest: /etc/systemd/system/cleanup-failed-docker-backups.timer register: cleanup_failed_docker_backups_timer - changed_when: cleanup_failed_docker_backups_timer.changed or activate_all_timers + changed_when: cleanup_failed_docker_backups_timer.changed or activate_all_timers | bool notify: restart cleanup-failed-docker-backups.timer when: run_once_cleanup_failed_docker_backups is not defined diff --git a/roles/docker-discourse/templates/app.yml.j2 b/roles/docker-discourse/templates/app.yml.j2 index fe222609..b73396ad 100644 --- a/roles/docker-discourse/templates/app.yml.j2 +++ b/roles/docker-discourse/templates/app.yml.j2 @@ -71,13 +71,13 @@ env: DISCOURSE_SMTP_DOMAIN: {{ system_email_domain }} DISCOURSE_NOTIFICATION_EMAIL: {{ system_email }} -{% if enable_central_database %} +{% if enable_central_database | bool %} # Database Configuration DISCOURSE_DB_USERNAME: {{ database_username }} DISCOURSE_DB_PASSWORD: {{ database_password }} DISCOURSE_DB_HOST: {{ database_host }} DISCOURSE_DB_NAME: {{ database_databasename }} -{% if enable_central_database %} +{% if enable_central_database | bool %} ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate #LETSENCRYPT_ACCOUNT_EMAIL: administrator@veen.world diff --git a/roles/docker-mailu/tasks/main.yml b/roles/docker-mailu/tasks/main.yml index 5c946e5d..6da02317 100644 --- a/roles/docker-mailu/tasks/main.yml +++ b/roles/docker-mailu/tasks/main.yml @@ -64,5 +64,5 @@ src: "deploy-letsencrypt-mailu.timer.j2" dest: "/etc/systemd/system/deploy-letsencrypt-mailu.timer" register: deploy_letsencrypt_mailu_timer - changed_when: deploy_letsencrypt_mailu_timer.changed or activate_all_timers + changed_when: deploy_letsencrypt_mailu_timer.changed or activate_all_timers | bool notify: restart deploy-letsencrypt-mailu.timer \ No newline at end of file diff --git a/roles/docker-mastodon/templates/mastodon.conf.j2 b/roles/docker-mastodon/templates/mastodon.conf.j2 index f20fc840..e983d022 100644 --- a/roles/docker-mastodon/templates/mastodon.conf.j2 +++ b/roles/docker-mastodon/templates/mastodon.conf.j2 @@ -8,7 +8,7 @@ server { {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking %} + {% if nginx_matomo_tracking | bool %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} diff --git a/roles/docker-nextcloud/templates/nextcloud.conf.j2 b/roles/docker-nextcloud/templates/nextcloud.conf.j2 index 6945a385..007fcfe7 100644 --- a/roles/docker-nextcloud/templates/nextcloud.conf.j2 +++ b/roles/docker-nextcloud/templates/nextcloud.conf.j2 @@ -4,7 +4,7 @@ server {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking %} + {% if nginx_matomo_tracking | bool %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} diff --git a/roles/docker-peertube/templates/peertube.conf.j2 b/roles/docker-peertube/templates/peertube.conf.j2 index ec84d8bc..ece8161e 100644 --- a/roles/docker-peertube/templates/peertube.conf.j2 +++ b/roles/docker-peertube/templates/peertube.conf.j2 @@ -3,7 +3,7 @@ server { {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking %} + {% if nginx_matomo_tracking | bool %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} diff --git a/roles/heal-docker/tasks/main.yml b/roles/heal-docker/tasks/main.yml index e306af78..8c4c2c44 100644 --- a/roles/heal-docker/tasks/main.yml +++ b/roles/heal-docker/tasks/main.yml @@ -23,7 +23,7 @@ src: heal-docker.timer.j2 dest: "/etc/systemd/system/heal-docker.timer" register: heal_docker_timer - changed_when: heal_docker_timer.changed or activate_all_timers + changed_when: heal_docker_timer.changed or activate_all_timers | bool notify: restart heal-docker.timer when: run_once_heal_docker is not defined diff --git a/roles/health-btrfs/tasks/main.yml b/roles/health-btrfs/tasks/main.yml index aa05a697..cc7d27fc 100644 --- a/roles/health-btrfs/tasks/main.yml +++ b/roles/health-btrfs/tasks/main.yml @@ -20,5 +20,5 @@ src: health-btrfs.timer.j2 dest: "/etc/systemd/system/health-btrfs.timer" register: health_btrs_timer - changed_when: health_btrs_timer.changed or activate_all_timers + changed_when: health_btrs_timer.changed or activate_all_timers | bool notify: restart health-btrfs.timer diff --git a/roles/health-disc-space/tasks/main.yml b/roles/health-disc-space/tasks/main.yml index eca7f270..e17c0d6f 100644 --- a/roles/health-disc-space/tasks/main.yml +++ b/roles/health-disc-space/tasks/main.yml @@ -20,5 +20,5 @@ src: health-disc-space.timer.j2 dest: /etc/systemd/system/health-disc-space.timer register: health_disc_space_timer - changed_when: health_disc_space_timer.changed or activate_all_timers + changed_when: health_disc_space_timer.changed or activate_all_timers | bool notify: restart health-disc-space.timer diff --git a/roles/health-docker-container/tasks/main.yml b/roles/health-docker-container/tasks/main.yml index 89e3953d..8fc8182a 100644 --- a/roles/health-docker-container/tasks/main.yml +++ b/roles/health-docker-container/tasks/main.yml @@ -21,7 +21,7 @@ src: health-docker-container.timer.j2 dest: "/etc/systemd/system/health-docker-container.timer" register: health_docker_container_timer - changed_when: health_docker_container_timer.changed or activate_all_timers + changed_when: health_docker_container_timer.changed or activate_all_timers | bool notify: restart health-docker-container.timer when: run_once_health_docker_container is not defined diff --git a/roles/health-docker-volumes/tasks/main.yml b/roles/health-docker-volumes/tasks/main.yml index 138fa41d..dfd6838c 100644 --- a/roles/health-docker-volumes/tasks/main.yml +++ b/roles/health-docker-volumes/tasks/main.yml @@ -21,7 +21,7 @@ src: health-docker-volumes.timer.j2 dest: "/etc/systemd/system/health-docker-volumes.timer" register: health_docker_volumes_timer - changed_when: health_docker_volumes_timer.changed or activate_all_timers + changed_when: health_docker_volumes_timer.changed or activate_all_timers | bool notify: restart health-docker-volumes.timer when: run_once_health_docker_volumes is not defined diff --git a/roles/health-journalctl/tasks/main.yml b/roles/health-journalctl/tasks/main.yml index 9c937b58..78aaeb7b 100644 --- a/roles/health-journalctl/tasks/main.yml +++ b/roles/health-journalctl/tasks/main.yml @@ -20,5 +20,5 @@ src: health-journalctl.timer.j2 dest: /etc/systemd/system/health-journalctl.timer register: health_journalctl_timer - changed_when: health_journalctl_timer.changed or activate_all_timers + changed_when: health_journalctl_timer.changed or activate_all_timers | bool notify: restart health-journalctl.timer diff --git a/roles/health-nginx/tasks/main.yml b/roles/health-nginx/tasks/main.yml index 11757eed..7810ef3d 100644 --- a/roles/health-nginx/tasks/main.yml +++ b/roles/health-nginx/tasks/main.yml @@ -29,7 +29,7 @@ src: health-nginx.timer.j2 dest: "/etc/systemd/system/health-nginx.timer" register: health_nginx_timer - changed_when: health_nginx_timer.changed or activate_all_timers + changed_when: health_nginx_timer.changed or activate_all_timers | bool notify: restart health-nginx.timer when: run_once_health_nginx is not defined diff --git a/roles/health-nginx/templates/health-nginx.py.j2 b/roles/health-nginx/templates/health-nginx.py.j2 index 91945a8f..c7f51eaf 100644 --- a/roles/health-nginx/templates/health-nginx.py.j2 +++ b/roles/health-nginx/templates/health-nginx.py.j2 @@ -31,7 +31,7 @@ for filename in os.listdir(config_path): # Determine expected status codes based on the domain if domain == '{{domain_listmonk}}': expected_statuses = [401] -{% if nginx_matomo_tracking %} +{% if nginx_matomo_tracking | bool %} elif parts[0] == 'www' or domain in redirected_domains: expected_statuses = [301] {% endif %} diff --git a/roles/nginx-certbot/tasks/main.yml b/roles/nginx-certbot/tasks/main.yml index 767698b6..29b5e0b9 100644 --- a/roles/nginx-certbot/tasks/main.yml +++ b/roles/nginx-certbot/tasks/main.yml @@ -16,7 +16,7 @@ src: certbot.timer.j2 dest: /etc/systemd/system/certbot.timer register: certbot_timer - changed_when: certbot_timer.changed or activate_all_timers + changed_when: certbot_timer.changed or activate_all_timers | bool notify: restart certbot timer when: run_once_nginx_certbot is not defined diff --git a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 index 051c683e..e5dde64e 100644 --- a/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 +++ b/roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 @@ -3,7 +3,7 @@ server server_name {{domain}}; # Include Matomo Tracking Code - {% if nginx_matomo_tracking %} + {% if nginx_matomo_tracking | bool %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} diff --git a/roles/nginx-homepage/templates/homepage.nginx.conf.j2 b/roles/nginx-homepage/templates/homepage.nginx.conf.j2 index 4c03694e..19406858 100644 --- a/roles/nginx-homepage/templates/homepage.nginx.conf.j2 +++ b/roles/nginx-homepage/templates/homepage.nginx.conf.j2 @@ -5,7 +5,7 @@ server {% include 'roles/letsencrypt/templates/ssl_header.j2' %} - {% if nginx_matomo_tracking %} + {% if nginx_matomo_tracking | bool %} {% include 'roles/nginx-matomo-tracking/templates/matomo-tracking.conf.j2' %} {% endif %} diff --git a/roles/update-docker/tasks/main.yml b/roles/update-docker/tasks/main.yml index 4b5bc5ef..c0576bf5 100644 --- a/roles/update-docker/tasks/main.yml +++ b/roles/update-docker/tasks/main.yml @@ -2,7 +2,7 @@ systemd: name: backup-docker-to-local-everything.service state: started - when: force_backup_before_update + when: force_backup_before_update | bool - name: create {{update_docker_script}} copy: diff --git a/tasks/implement-matomo-tracking.yml b/tasks/implement-matomo-tracking.yml index fe4636ac..bbebfd24 100644 --- a/tasks/implement-matomo-tracking.yml +++ b/tasks/implement-matomo-tracking.yml @@ -1,4 +1,4 @@ - name: Activate NGINX matomo tracking include_role: name: nginx-matomo-tracking - when: nginx_matomo_tracking and domain is defined \ No newline at end of file + when: nginx_matomo_tracking | bool and domain is defined \ No newline at end of file diff --git a/templates/docker-compose-networks.yml.j2 b/templates/docker-compose-networks.yml.j2 index adeb34f1..8d760849 100644 --- a/templates/docker-compose-networks.yml.j2 +++ b/templates/docker-compose-networks.yml.j2 @@ -1,6 +1,6 @@ # This template needs to be included in docker-compose.yml networks: -{% if enable_central_database %} +{% if enable_central_database | bool %} central_{{ database_type }}_network: external: true {% endif %} diff --git a/templates/docker-compose-volumes-just-database.yml.j2 b/templates/docker-compose-volumes-just-database.yml.j2 index 23aa6977..0e80e052 100644 --- a/templates/docker-compose-volumes-just-database.yml.j2 +++ b/templates/docker-compose-volumes-just-database.yml.j2 @@ -1,5 +1,5 @@ # This needs to be included in docker-compose.yml which just contain a database volume -{% if not enable_central_database %} +{% if not enable_central_database | bool %} volumes: database: {% endif %} \ No newline at end of file diff --git a/templates/docker-compose-volumes.yml.j2 b/templates/docker-compose-volumes.yml.j2 index 4b4c3f3a..ece146f3 100644 --- a/templates/docker-compose-volumes.yml.j2 +++ b/templates/docker-compose-volumes.yml.j2 @@ -1,5 +1,5 @@ # This template needs to be included in docker-compose.yml which contain a database and additional volumes volumes: -{% if not enable_central_database %} +{% if not enable_central_database | bool %} database: {% endif %} \ No newline at end of file diff --git a/templates/docker-container-depends-on-also-database.yml.j2 b/templates/docker-container-depends-on-also-database.yml.j2 index 809268e7..8eda1cf7 100644 --- a/templates/docker-container-depends-on-also-database.yml.j2 +++ b/templates/docker-container-depends-on-also-database.yml.j2 @@ -1,6 +1,6 @@ # This template needs to be included in docker-compose.yml containers which depend on a database and additional containers depends_on: -{% if enable_central_database %} +{% if enable_central_database | bool %} database: condition: service_healthy {% endif %} \ No newline at end of file diff --git a/templates/docker-container-depends-on-database-redis.yml.j2 b/templates/docker-container-depends-on-database-redis.yml.j2 index c73f8f77..18b5150c 100644 --- a/templates/docker-container-depends-on-database-redis.yml.j2 +++ b/templates/docker-container-depends-on-database-redis.yml.j2 @@ -1,6 +1,6 @@ # This template needs to be included in docker-compose.yml contaienrs, which depend on a database, redis and optional additional volumes depends_on: -{% if enable_central_database %} +{% if enable_central_database | bool %} database: condition: service_healthy {% endif %} diff --git a/templates/docker-container-depends-on-just-database.yml.j2 b/templates/docker-container-depends-on-just-database.yml.j2 index 0b000dbf..d5712e2d 100644 --- a/templates/docker-container-depends-on-just-database.yml.j2 +++ b/templates/docker-container-depends-on-just-database.yml.j2 @@ -1,5 +1,5 @@ # This template needs to be included in docker-compose.yml contaienrs, which just depend on a database -{% if enable_central_database %} +{% if enable_central_database | bool %} depends_on: database: condition: service_healthy diff --git a/templates/docker-container-networks.yml.j2 b/templates/docker-container-networks.yml.j2 index d99c2747..6d69a2e7 100644 --- a/templates/docker-container-networks.yml.j2 +++ b/templates/docker-container-networks.yml.j2 @@ -1,6 +1,6 @@ # This template needs to be included in docker-compose.yml containers networks: - {{docker_compose_project_name}}_network -{% if enable_central_database %} +{% if enable_central_database | bool %} - central_{{ database_type }}_network {% endif %} \ No newline at end of file diff --git a/templates/docker-service-mariadb.yml.j2 b/templates/docker-service-mariadb.yml.j2 index 9e87dcf3..5f249e37 100644 --- a/templates/docker-service-mariadb.yml.j2 +++ b/templates/docker-service-mariadb.yml.j2 @@ -1,5 +1,5 @@ # This template needs to be included in docker-compose.yml, which depend on a mariadb database -{% if not enable_central_database %} +{% if not enable_central_database | bool %} database: logging: driver: journald diff --git a/templates/docker-service-postgres.yml.j2 b/templates/docker-service-postgres.yml.j2 index 54acbbb4..b5159a17 100644 --- a/templates/docker-service-postgres.yml.j2 +++ b/templates/docker-service-postgres.yml.j2 @@ -1,5 +1,5 @@ # This template needs to be included in docker-compose.yml, which depend on a postgres database -{% if not enable_central_database %} +{% if not enable_central_database | bool %} database: image: postgres:{{database_version}}-alpine environment: