diff --git a/group_vars/all b/group_vars/all index 02ddd645..14affe16 100644 --- a/group_vars/all +++ b/group_vars/all @@ -52,7 +52,7 @@ domains_mastodon_alternates: [] domain_matomo: "matomo.{{top_domain}}" domain_mediawiki: "wiki.{{top_domain}}" domain_nextcloud: "cloud.{{top_domain}}" -domain_pixelfed: "pictures.{{top_domain}}" +domain_pixelfed: "pictures.{{top_domain}}" domains_pixelfed: [] domain_peertube: "videos.{{top_domain}}" domains_peertube: [] diff --git a/roles/health-nginx/tasks/main.yml b/roles/health-nginx/tasks/main.yml index 7b73990b..be67be18 100644 --- a/roles/health-nginx/tasks/main.yml +++ b/roles/health-nginx/tasks/main.yml @@ -12,8 +12,8 @@ when: run_once_health_nginx is not defined - name: create health-nginx.py - copy: - src: health-nginx.py + template: + src: health-nginx.py.j2 dest: "{{ health_nginx_folder }}health-nginx.py" when: run_once_health_nginx is not defined diff --git a/roles/health-nginx/files/health-nginx.py b/roles/health-nginx/templates/health-nginx.py.j2 similarity index 77% rename from roles/health-nginx/files/health-nginx.py rename to roles/health-nginx/templates/health-nginx.py.j2 index ee9b374a..051a85c0 100644 --- a/roles/health-nginx/files/health-nginx.py +++ b/roles/health-nginx/templates/health-nginx.py.j2 @@ -3,13 +3,8 @@ import requests import sys import re -# Set up argument parser -parser = argparse.ArgumentParser(description='Check if domains of nginx configuration files respond with the correct status code.') -parser.add_argument('config_path', help='Path to the nginx configuration directory') -args = parser.parse_args() - -# Use the provided argument for the config path -config_path = args.config_path +# file in which fqdn server configs are deposit +config_path = {{nginx_servers_directory}} # Initialize the error counter error_counter = 0 @@ -32,11 +27,13 @@ for filename in os.listdir(config_path): # Determine expected status codes based on subdomain if len(parts) == 3: - if parts[0] == 'listmonk': + if parts[0] == '{{domain_listmonk}}': expected_statuses = [401] - elif parts[0] == 'www': + {% if nginx_matomo_tracking | bool %} + elif parts[0] == '{{nginx_www_redirect}}': expected_statuses = [200,301] - elif parts[0] == 's': + {% endif %} + elif parts[0] == '{{domain_yourls}}': expected_statuses = [403] try: diff --git a/roles/health-nginx/templates/health-nginx.service.j2 b/roles/health-nginx/templates/health-nginx.service.j2 index 20cbc9c1..e17335ed 100644 --- a/roles/health-nginx/templates/health-nginx.service.j2 +++ b/roles/health-nginx/templates/health-nginx.service.j2 @@ -4,4 +4,4 @@ OnFailure=systemd-notifier@%n.service [Service] Type=oneshot -ExecStart=/usr/bin/python3 {{ health_nginx_folder }}health-nginx.py {{nginx_servers_directory}} +ExecStart=/usr/bin/python3 {{ health_nginx_folder }}health-nginx.py