mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-12-07 09:56:41 +00:00
Restructured Handler Logic
This commit is contained in:
@@ -5,5 +5,6 @@
|
||||
vars:
|
||||
docker_compose_flush_handlers: true
|
||||
docker_git_repository_pull: false # Deactivated here to deactivate inhirement
|
||||
database_type: "" # Deactivate Database for openresty
|
||||
- include_tasks: utils/once/flag.yml
|
||||
when: run_once_svc_prx_openresty is not defined
|
||||
@@ -1,10 +1,7 @@
|
||||
# General
|
||||
application_id: "svc-prx-openresty"
|
||||
|
||||
# Deactivate Database for openresty
|
||||
database_type: ""
|
||||
|
||||
# Openresty
|
||||
OPENRESTY_IMAGE: "openresty/openresty"
|
||||
OPENRESTY_VERSION: "alpine"
|
||||
OPENRESTY_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.openresty.name') }}"
|
||||
OPENRESTY_CONTAINER: "{{ applications | get_app_conf('svc-prx-openresty', 'docker.services.openresty.name') }}"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
- block:
|
||||
- name: Include dependency 'sys-svc-webserver-https'
|
||||
include_role:
|
||||
name: sys-svc-webserver-https
|
||||
when: run_once_sys_svc_webserver_https is not defined
|
||||
- include_tasks: utils/once/flag.yml
|
||||
- name: Include dependency 'sys-svc-webserver-https'
|
||||
include_role:
|
||||
name: sys-svc-webserver-https
|
||||
when: run_once_sys_svc_webserver_https is not defined
|
||||
- include_tasks: utils/once/flag.yml
|
||||
when: run_once_sys_stk_front_base is not defined
|
||||
|
||||
- include_tasks: "01_cloudflare.yml"
|
||||
@@ -12,4 +12,4 @@
|
||||
- name: "Reinitialize OpenResty Handler"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "svc-prx-openresty"
|
||||
handler_role_name: "svc-prx-openresty"
|
||||
@@ -1,5 +1,2 @@
|
||||
# default vhost flavour
|
||||
vhost_flavour: "basic" # valid: basic, ws_generic
|
||||
|
||||
# Enable / Disable Proxy during development, for faster Debugging
|
||||
SYS_STK_FRONT_PROXY_ENABLED: true
|
||||
@@ -1,44 +0,0 @@
|
||||
- name: Front bootstrap
|
||||
include_role:
|
||||
name: sys-stk-front-base
|
||||
|
||||
- name: "include role for '{{ domain }}' to receive certificates and do the modification routines"
|
||||
include_role:
|
||||
name: sys-util-csp-cert
|
||||
|
||||
- name: "Reinitialize OpenResty Handler"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "svc-prx-openresty"
|
||||
|
||||
- name: "Copy nginx config to '{{ front_proxy_domain_conf_dst }}'"
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ front_proxy_domain_conf_dst }}"
|
||||
register: nginx_conf
|
||||
notify: restart openresty
|
||||
vars:
|
||||
nginx_template_candidates:
|
||||
- "{{ application_id | abs_role_path_by_application_id }}/templates/proxy.conf.j2"
|
||||
- "roles/sys-svc-proxy/templates/vhost/{{ vhost_flavour }}.conf.j2"
|
||||
with_first_found: "{{ nginx_template_candidates }}"
|
||||
|
||||
- block:
|
||||
- name: "Check if {{ domains | get_domain(application_id) }} is reachable (only if config unchanged)"
|
||||
uri:
|
||||
url: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
|
||||
register: site_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Restart nginx if site is down
|
||||
command:
|
||||
cmd: "true"
|
||||
notify: restart openresty
|
||||
when:
|
||||
- site_check.status is defined
|
||||
- not site_check.status in [200,301,302]
|
||||
when: not nginx_conf.changed
|
||||
|
||||
- name: "Restart Webserver for '{{ front_proxy_domain_conf_dst }}'"
|
||||
meta: flush_handlers
|
||||
@@ -1,5 +1,41 @@
|
||||
# run_once_sys_stk_front_proxy: deactivated
|
||||
|
||||
- name: "Load Proxy procedures if Proxy is enabled"
|
||||
include_tasks: "01_core.yml"
|
||||
when: SYS_STK_FRONT_PROXY_ENABLED | bool
|
||||
- name: Front bootstrap
|
||||
include_role:
|
||||
name: sys-stk-front-base
|
||||
|
||||
- name: "include role for '{{ domain }}' to receive certificates and do the modification routines"
|
||||
include_role:
|
||||
name: sys-util-csp-cert
|
||||
|
||||
- name: "Copy nginx config to '{{ front_proxy_domain_conf_dst }}'"
|
||||
template:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ front_proxy_domain_conf_dst }}"
|
||||
register: nginx_conf
|
||||
notify: restart openresty
|
||||
vars:
|
||||
nginx_template_candidates:
|
||||
- "{{ application_id | abs_role_path_by_application_id }}/templates/proxy.conf.j2"
|
||||
- "roles/sys-svc-proxy/templates/vhost/{{ vhost_flavour }}.conf.j2"
|
||||
with_first_found: "{{ nginx_template_candidates }}"
|
||||
|
||||
- block:
|
||||
- name: "Check if {{ domains | get_domain(application_id) }} is reachable (only if config unchanged)"
|
||||
uri:
|
||||
url: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
|
||||
register: site_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Restart nginx if site is down
|
||||
command:
|
||||
cmd: "true"
|
||||
notify: restart openresty
|
||||
when:
|
||||
- site_check.status is defined
|
||||
- not site_check.status in [200,301,302]
|
||||
when: not nginx_conf.changed
|
||||
|
||||
- name: "Restart Webserver for '{{ front_proxy_domain_conf_dst }}'"
|
||||
meta: flush_handlers
|
||||
@@ -1,10 +1,4 @@
|
||||
# run_once_sys_stk_full_stateful: deactivated
|
||||
|
||||
- name: "Reinitialize OpenResty Handler"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "svc-prx-openresty"
|
||||
|
||||
- name: "For '{{ application_id }}': include role sys-stk-front-proxy"
|
||||
include_role:
|
||||
name: sys-stk-front-proxy
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
- run_once_sys_svc_cdn is not defined
|
||||
|
||||
- name: Overwritte CDN handlers with neutral handlers
|
||||
ansible.builtin.include_tasks: "{{ [ playbook_dir, 'tasks/utils/load_handlers.yml'] | path_join }}"
|
||||
ansible.builtin.include_tasks: "tasks/utils/load_handlers.yml"
|
||||
loop:
|
||||
- svc-prx-openresty
|
||||
- docker-compose
|
||||
|
||||
@@ -5,11 +5,6 @@
|
||||
patterns: "*.{{ domain }}.conf"
|
||||
register: find_result
|
||||
|
||||
- name: "Reinitialize OpenResty Handler"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "svc-prx-openresty"
|
||||
|
||||
- name: Remove wildcard nginx configs for {{ domain }}
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
|
||||
@@ -11,31 +11,20 @@
|
||||
- name: "Load variables from {{ DOCKER_VARS_FILE }} for {{ role_name }}/{{ application_id }}"
|
||||
include_vars: "{{ DOCKER_VARS_FILE }}"
|
||||
|
||||
- name: "Load docker compose & openresty handlers"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
loop:
|
||||
- docker-compose
|
||||
- svc-prx-openresty
|
||||
loop_control:
|
||||
loop_var: handler_role_name
|
||||
vars:
|
||||
application_id: svc-prx-openresty # Required to use correct config path at handlers
|
||||
|
||||
- name: "Include tasks to create directories"
|
||||
include_tasks: 04_directories.yml
|
||||
|
||||
- name: Include OpenResty (Once)
|
||||
include_tasks: "utils/load_app.yml"
|
||||
vars:
|
||||
load_app_id: svc-prx-openresty
|
||||
|
||||
- name: Create NGINX Base Config
|
||||
template:
|
||||
src: nginx.conf.j2
|
||||
dest: "{{ NGINX.FILES.CONFIGURATION }}"
|
||||
notify: restart openresty
|
||||
|
||||
- name: Include OpenResty (Once)
|
||||
include_tasks: "utils/load_app.yml"
|
||||
vars:
|
||||
load_app_id: svc-prx-openresty
|
||||
when: run_once_svc_prx_openresty is not defined
|
||||
|
||||
- name: Include health dependencies
|
||||
include_role:
|
||||
name: "{{ item }}"
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
---
|
||||
- include_tasks: 01_core.yml
|
||||
when: run_once_sys_svc_webserver_core is not defined
|
||||
|
||||
- name: "Provide OpenResty Handlers for Webserver"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: svc-prx-openresty
|
||||
when: run_once_sys_svc_webserver_core is defined
|
||||
@@ -1,7 +1,10 @@
|
||||
- include_tasks: utils/load_handlers.yml
|
||||
- name: "Reset Docker Compose Handler for Keycloak"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "docker-compose"
|
||||
- ansible.builtin.include_vars:
|
||||
|
||||
- name: Load Variables for Keycloak
|
||||
ansible.builtin.include_vars:
|
||||
file: "{{ item }}"
|
||||
loop:
|
||||
- "{{ playbook_dir }}/roles/docker-compose/vars/docker-compose.yml"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
vars:
|
||||
application_id: 'web-svc-cdn'
|
||||
|
||||
- include_tasks: utils/load_handlers.yml
|
||||
- name: "Reset docker compose Handler for CDN"
|
||||
include_tasks: utils/load_handlers.yml
|
||||
vars:
|
||||
handler_role_name: "docker-compose"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- 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"
|
||||
vars:
|
||||
application_id: "{{ handler_role_name }}"
|
||||
- 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"
|
||||
vars:
|
||||
application_id: "{{ handler_role_name }}"
|
||||
Reference in New Issue
Block a user