Optimized blocks in roles/srv-proxy-6-6-domain/tasks/main.yml

This commit is contained in:
Kevin Veen-Birkenbach 2025-08-10 18:31:12 +02:00
parent 77816ac4e7
commit f5659a44f8
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E

View File

@ -1,7 +1,6 @@
# run_once_srv_proxy_6_6_domain: deactivated # run_once_srv_proxy_6_6_domain: deactivated
- block: - include_tasks: "01_cloudflare.yml"
- include_tasks: "01_cloudflare.yml"
when: dns_provider == "cloudflare" when: dns_provider == "cloudflare"
- include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml" - include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
@ -19,19 +18,19 @@
register: nginx_conf register: nginx_conf
notify: restart openresty notify: restart openresty
- name: "Check if {{ domains | get_domain(application_id) }} is reachable (only if config unchanged)" - block:
uri: - name: "Check if {{ domains | get_domain(application_id) }} is reachable (only if config unchanged)"
url: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}" uri:
register: site_check url: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
failed_when: false register: site_check
changed_when: false failed_when: false
when: not nginx_conf.changed changed_when: false
- name: Restart nginx if site is down - name: Restart nginx if site is down
command: command:
cmd: "true" cmd: "true"
notify: restart openresty notify: restart openresty
when: when:
- not nginx_conf.changed - site_check.status is defined
- site_check.status is defined - not site_check.status in [200,301,302]
- not site_check.status in [200,301,302] when: not nginx_conf.changed