mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-04 04:08:15 +00:00 
			
		
		
		
	Implemented performance switch for Front Proxy
This commit is contained in:
		
							
								
								
									
										42
									
								
								roles/sys-stk-front-proxy/tasks/01_base.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								roles/sys-stk-front-proxy/tasks/01_base.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
- block:
 | 
			
		||||
  - name: Include dependency 'sys-svc-proxy'
 | 
			
		||||
    include_role:
 | 
			
		||||
      name: sys-svc-proxy
 | 
			
		||||
    when: run_once_sys_svc_proxy is not defined
 | 
			
		||||
  - include_tasks: utils/run_once.yml
 | 
			
		||||
  when: run_once_sys_stk_front_proxy is not defined
 | 
			
		||||
 | 
			
		||||
- include_tasks: "02_cloudflare.yml"
 | 
			
		||||
  when: DNS_PROVIDER == "cloudflare"
 | 
			
		||||
 | 
			
		||||
- include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
 | 
			
		||||
  vars:
 | 
			
		||||
    handler_role_name: "svc-prx-openresty"
 | 
			
		||||
 | 
			
		||||
- 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 {{ configuration_destination }}"
 | 
			
		||||
  template:
 | 
			
		||||
    src: "{{ vhost_template_src }}"
 | 
			
		||||
    dest: "{{ configuration_destination }}"
 | 
			
		||||
  register: nginx_conf
 | 
			
		||||
  notify: restart openresty
 | 
			
		||||
 | 
			
		||||
- 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
 | 
			
		||||
@@ -1,42 +1,3 @@
 | 
			
		||||
- block:
 | 
			
		||||
  - name: Include dependency 'sys-svc-proxy'
 | 
			
		||||
    include_role:
 | 
			
		||||
      name: sys-svc-proxy
 | 
			
		||||
    when: run_once_sys_svc_proxy is not defined
 | 
			
		||||
  - include_tasks: utils/run_once.yml
 | 
			
		||||
  when: run_once_sys_stk_front_proxy is not defined
 | 
			
		||||
 | 
			
		||||
- include_tasks: "01_cloudflare.yml"
 | 
			
		||||
  when: DNS_PROVIDER == "cloudflare"
 | 
			
		||||
 | 
			
		||||
- include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
 | 
			
		||||
  vars:
 | 
			
		||||
    handler_role_name: "svc-prx-openresty"
 | 
			
		||||
 | 
			
		||||
- 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 {{ configuration_destination }}"
 | 
			
		||||
  template:
 | 
			
		||||
    src: "{{ vhost_template_src }}"
 | 
			
		||||
    dest: "{{ configuration_destination }}"
 | 
			
		||||
  register: nginx_conf
 | 
			
		||||
  notify: restart openresty
 | 
			
		||||
 | 
			
		||||
- 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: "Load Proxy procedures if Proxy is enabled"
 | 
			
		||||
  include_tasks: "01_base.yml"
 | 
			
		||||
  when: SYS_STK_FRONT_PROXY_ENABLED | bool
 | 
			
		||||
		Reference in New Issue
	
	Block a user