Refactored handlers loading

This commit is contained in:
Kevin Veen-Birkenbach 2025-08-08 19:01:12 +02:00
parent aae69ea15b
commit 22c8c395f0
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
9 changed files with 33 additions and 37 deletions

View File

@ -1,5 +0,0 @@
- name: "Load handlers without when condition. to guaranty that they are executed"
import_role:
name: docker-compose
tasks_from: helpers/none
handlers_from: main

View File

@ -49,10 +49,5 @@
dest: "{{ nginx.files.configuration }}" dest: "{{ nginx.files.configuration }}"
notify: restart openresty notify: restart openresty
- name: flush nginx service - include_tasks: utils/run_once.yml
meta: flush_handlers
- name: run {{ role_name }} once
set_fact:
run_once_srv_web_7_4_core: true
when: run_once_srv_web_7_4_core is not defined when: run_once_srv_web_7_4_core is not defined

View File

@ -25,8 +25,9 @@
- include_tasks: utils/run_once.yml - include_tasks: utils/run_once.yml
when: run_once_svc_db_postgres is not defined when: run_once_svc_db_postgres is not defined
- name: "Ensure that {{ docker_compose.directories.instance }} is up" - include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/helpers/ensure.yml" vars:
handler_role_name: "docker-compose"
- name: "Initialize database for '{{ database_name }}'" - name: "Initialize database for '{{ database_name }}'"
include_tasks: init.yml include_tasks: init.yml

View File

@ -0,0 +1 @@
# Dummy file for handler import

View File

@ -1,23 +1,22 @@
--- ---
- name: "include role for {{application_id}} to receive certs & do modification routines" - block:
- name: "include role for {{application_id}} to receive certs & do modification routines"
include_role: include_role:
name: srv-web-7-6-composer name: srv-web-7-6-composer
vars: vars:
domain: "{{ domains | get_domain(application_id) }}" domain: "{{ domains | get_domain(application_id) }}"
http_port: "{{ ports.localhost.http[application_id] }}" http_port: "{{ ports.localhost.http[application_id] }}"
when: run_once_web_svc_cdn is not defined
- name: "generate {{domains | get_domain(application_id)}}.conf" - name: "generate {{domains | get_domain(application_id)}}.conf"
template: template:
src: "nginx.conf.j2" src: "nginx.conf.j2"
dest: "{{ nginx.directories.http.servers }}{{ domains | get_domain(application_id) }}.conf" dest: "{{ nginx.directories.http.servers }}{{ domains | get_domain(application_id) }}.conf"
notify: restart openresty notify: restart openresty
- include_tasks: utils/run_once.yml
when: run_once_web_svc_cdn is not defined when: run_once_web_svc_cdn is not defined
- name: run the web svc cdn tasks once - include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
set_fact: vars:
run_once_web_svc_cdn: true handler_role_name: "docker-compose"
when: run_once_web_svc_cdn is not defined
- name: "Ensure that {{ docker_compose.directories.instance }} is up"
include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/helpers/ensure.yml"

View File

@ -0,0 +1,5 @@
- name: "Load pure handlers from '{{ handler_role_name }}' without 'when' to guaranty that they are executed"
import_role:
name: "{{ handler_role_name }}"
tasks_from: "none.yml"
handlers_from: main