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

@ -7,8 +7,8 @@
- name: "For '{{ application_id }}': Load database variables"
include_vars: "{{ item }}"
loop:
- "{{ DOCKER_VARS_FILE }}" # Important to load docker variables first so that database can use them
- "{{ cmp_db_docker_vars_file_db }}" # Important to load them before docker role so that backup can use them
- "{{ DOCKER_VARS_FILE }}" # Important to load docker variables first so that database can use them
- "{{ cmp_db_docker_vars_file_db }}" # Important to load them before docker role so that backup can use them
- name: "For '{{ application_id }}': Load cmp-docker-oauth2"
include_role:

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 }}"
notify: restart openresty
- name: flush nginx service
meta: flush_handlers
- name: run {{ role_name }} once
set_fact:
run_once_srv_web_7_4_core: true
- include_tasks: utils/run_once.yml
when: run_once_srv_web_7_4_core is not defined

View File

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

View File

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

View File

@ -62,4 +62,4 @@
notify: docker compose up
- include_tasks: utils/run_once.yml
when: run_once_web_app_port_ui is not defined
when: run_once_web_app_port_ui is not defined

View File

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

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