mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 10:19:09 +00:00 
			
		
		
		
	Refactored server roles for better readability
This commit is contained in:
		
							
								
								
									
										53
									
								
								roles/sys-svc-webserver/tasks/01_core.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								roles/sys-svc-webserver/tasks/01_core.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| - name: "cleanup (if enabled)" | ||||
|   include_tasks: 02_cleanup.yml | ||||
|   when: > | ||||
|     MODE_CLEANUP | bool or | ||||
|     MODE_RESET | bool | ||||
|  | ||||
| - name: "reset (if enabled)" | ||||
|   include_tasks: 03_reset.yml | ||||
|   when: MODE_RESET | bool | ||||
|  | ||||
| - name: "Load variables from {{ DOCKER_VARS_FILE }} for {{ role_name }}/{{ application_id }}" | ||||
|   include_vars: "{{ DOCKER_VARS_FILE }}" | ||||
|  | ||||
| - name: "Load docker compose handlers" | ||||
|   include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml" | ||||
|   vars: | ||||
|     handler_role_name: "docker-compose" | ||||
|  | ||||
| - name: "Include tasks to create directories" | ||||
|   include_tasks: 04_directories.yml | ||||
|  | ||||
| - name: create nginx config file | ||||
|   template:  | ||||
|     src:  nginx.conf.j2 | ||||
|     dest: "{{ NGINX.FILES.CONFIGURATION }}" | ||||
|   notify: docker compose up | ||||
|  | ||||
| - name: Include openresty | ||||
|   # Outside of run_once block is necessary for handler loading | ||||
|   # Otherwise the when: condition from the block is added to the handlers | ||||
|   # Inside openresty their is a validation that it doesn't run multiple times | ||||
|   include_role: | ||||
|     name: svc-prx-openresty | ||||
|  | ||||
|     # Explicit set to guaranty that application_id will not be overwritten. | ||||
|     # Should be anyhow the default case | ||||
|     public: false | ||||
|  | ||||
|   vars: | ||||
|     # Flush openresty handler on first run, so that openresty is up, before openresty related handlers are triggered | ||||
|     flush_handlers: true | ||||
|   when: run_once_svc_prx_openresty is not defined | ||||
|  | ||||
| - name: Include health dependencies | ||||
|   include_role: | ||||
|     name: "{{ item }}" | ||||
|   loop: | ||||
|     - sys-ctl-hlth-webserver | ||||
|     - sys-ctl-hlth-csp | ||||
|   vars: | ||||
|     flush_handlers: false | ||||
|  | ||||
| - include_tasks: utils/run_once.yml | ||||
							
								
								
									
										8
									
								
								roles/sys-svc-webserver/tasks/02_cleanup.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								roles/sys-svc-webserver/tasks/02_cleanup.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| - name: Cleanup all NGINX cache directories | ||||
|   become: true | ||||
|   ansible.builtin.file: | ||||
|     path: "{{ item.value }}" | ||||
|     state: absent | ||||
|   loop: "{{ NGINX.DIRECTORIES.CACHE | dict2items }}" | ||||
|   loop_control: | ||||
|     label: "{{ item.key }}" | ||||
							
								
								
									
										9
									
								
								roles/sys-svc-webserver/tasks/03_reset.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								roles/sys-svc-webserver/tasks/03_reset.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| - name: Delete NGINX config paths | ||||
|   file: | ||||
|     path: "{{ item }}" | ||||
|     state: absent | ||||
|   loop: | ||||
|     - "{{ NGINX.DIRECTORIES.CONFIGURATION }}" | ||||
|     - "{{ NGINX.FILES.CONFIGURATION }}" | ||||
|   loop_control: | ||||
|     label: "{{ item }}" | ||||
							
								
								
									
										36
									
								
								roles/sys-svc-webserver/tasks/04_directories.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								roles/sys-svc-webserver/tasks/04_directories.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| - name: Ensure nginx configuration directories are present | ||||
|   file: | ||||
|     path: "{{ item }}" | ||||
|     state: directory | ||||
|     owner: "{{ NGINX.USER }}" | ||||
|     group: "{{ NGINX.USER }}" | ||||
|     mode: '0755' | ||||
|     recurse: yes | ||||
|   loop: > | ||||
|     {{ | ||||
|       ( NGINX.DIRECTORIES.HTTP.values() | list ) + | ||||
|       [ NGINX.DIRECTORIES.STREAMS ]  | ||||
|     }} | ||||
|  | ||||
| - name: Ensure all NGINX cache directories exist | ||||
|   become: true | ||||
|   ansible.builtin.file: | ||||
|     path: "{{ item.value }}" | ||||
|     state: directory | ||||
|     owner: "{{ NGINX.USER }}" | ||||
|     group: "{{ NGINX.USER }}" | ||||
|     mode: '0700' | ||||
|   loop: "{{ NGINX.DIRECTORIES.CACHE | dict2items }}" | ||||
|   loop_control: | ||||
|     label: "{{ item.key }}" | ||||
|  | ||||
| - name: Ensure nginx data storage directories are present | ||||
|   file: | ||||
|     path: "{{ item }}" | ||||
|     state: directory | ||||
|     recurse: yes | ||||
|     owner: "{{ NGINX.USER }}" | ||||
|     group: "{{ NGINX.USER }}" | ||||
|     mode:  '0755' | ||||
|   loop: > | ||||
|     {{ NGINX.DIRECTORIES.DATA.values() | list }} | ||||
							
								
								
									
										4
									
								
								roles/sys-svc-webserver/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								roles/sys-svc-webserver/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| --- | ||||
| - block: | ||||
|   - include_tasks: 01_core.yml | ||||
|   when: run_once_sys_svc_webserver is not defined | ||||
		Reference in New Issue
	
	Block a user