mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-08 11:17:17 +02:00
Refactor CDN and run_once handling
- Move run_once include from main.yml to 01_core.yml in desk-gnome-caffeine and desk-ssh - Introduce sys-svc-cdn/01_core.yml to handle shared/vendor dirs once and role dirs per run - Replace cdn.* with cdn_paths_all.* across inj roles - Split cdn_dirs into cdn_dirs_role and CDN_DIRS_GLOBAL - Ensure cdn_urls uses cdn_paths_all Details: https://chatgpt.com/share/68b58d64-1e28-800f-8907-36926a9e9a9b
This commit is contained in:
@@ -19,3 +19,5 @@
|
|||||||
template:
|
template:
|
||||||
src: caffeine.desktop.j2
|
src: caffeine.desktop.j2
|
||||||
dest: "{{auto_start_directory}}caffeine.desktop"
|
dest: "{{auto_start_directory}}caffeine.desktop"
|
||||||
|
|
||||||
|
- include_tasks: utils/run_once.yml
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
- block:
|
- block:
|
||||||
- include_tasks: 01_core.yml
|
- include_tasks: 01_core.yml
|
||||||
- include_tasks: utils/run_once.yml
|
|
||||||
when: run_once_desk_gnome_caffeine is not defined
|
when: run_once_desk_gnome_caffeine is not defined
|
||||||
|
@@ -48,4 +48,6 @@
|
|||||||
state: present
|
state: present
|
||||||
create: yes
|
create: yes
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
become: false
|
become: false
|
||||||
|
|
||||||
|
- include_tasks: utils/run_once.yml
|
@@ -1,4 +1,3 @@
|
|||||||
- block:
|
- block:
|
||||||
- include_tasks: 01_core.yml
|
- include_tasks: 01_core.yml
|
||||||
- include_tasks: utils/run_once.yml
|
|
||||||
when: run_once_desk_ssh is not defined
|
when: run_once_desk_ssh is not defined
|
@@ -14,7 +14,7 @@
|
|||||||
- name: Deploy default CSS files
|
- name: Deploy default CSS files
|
||||||
template:
|
template:
|
||||||
src: "{{ ['css', item ~ '.j2'] | path_join }}"
|
src: "{{ ['css', item ~ '.j2'] | path_join }}"
|
||||||
dest: "{{ [cdn.shared.css, item] | path_join }}"
|
dest: "{{ [cdn_paths_all.shared.css, item] | path_join }}"
|
||||||
owner: "{{ NGINX.USER }}"
|
owner: "{{ NGINX.USER }}"
|
||||||
group: "{{ NGINX.USER }}"
|
group: "{{ NGINX.USER }}"
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
|
@@ -5,4 +5,4 @@ CSS_COUNT: 7
|
|||||||
CSS_SHADES: 100
|
CSS_SHADES: 100
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
css_app_dst: "{{ [cdn.role.release.css, 'style.css'] | path_join }}"
|
css_app_dst: "{{ [cdn_paths_all.role.release.css, 'style.css'] | path_join }}"
|
@@ -1,2 +1,2 @@
|
|||||||
INJ_DESKTOP_JS_FILE_NAME: "iframe-handler.js"
|
INJ_DESKTOP_JS_FILE_NAME: "iframe-handler.js"
|
||||||
INJ_DESKTOP_JS_FILE_DESTINATION: "{{ [cdn.shared.js, INJ_DESKTOP_JS_FILE_NAME] | path_join }}"
|
INJ_DESKTOP_JS_FILE_DESTINATION: "{{ [cdn_paths_all.shared.js, INJ_DESKTOP_JS_FILE_NAME] | path_join }}"
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
INJ_LOGOUT_JS_FILE_NAME: "logout.js"
|
INJ_LOGOUT_JS_FILE_NAME: "logout.js"
|
||||||
INJ_LOGOUT_JS_DESTINATION: "{{ [cdn.shared.js, INJ_LOGOUT_JS_FILE_NAME] | path_join }}"
|
INJ_LOGOUT_JS_DESTINATION: "{{ [cdn_paths_all.shared.js, INJ_LOGOUT_JS_FILE_NAME] | path_join }}"
|
||||||
|
30
roles/sys-svc-cdn/tasks/01_core.yml
Normal file
30
roles/sys-svc-cdn/tasks/01_core.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
- name: "Load CDN for '{{ domain }}'"
|
||||||
|
include_role:
|
||||||
|
name: web-svc-cdn
|
||||||
|
public: false
|
||||||
|
when:
|
||||||
|
- application_id != 'web-svc-cdn'
|
||||||
|
- run_once_web_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 }}"
|
||||||
|
loop:
|
||||||
|
- svc-prx-openresty
|
||||||
|
- docker-compose
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item }}"
|
||||||
|
vars:
|
||||||
|
handler_role_name: "{{ item }}"
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
# Only-once creations (shared root and vendor)
|
||||||
|
# ------------------------------------------------------------------
|
||||||
|
- name: Ensure shared root and vendor exist (run once)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ NGINX.USER }}"
|
||||||
|
group: "{{ NGINX.USER }}"
|
||||||
|
mode: "0755"
|
||||||
|
loop: "{{ CDN_DIRS_GLOBAL }}"
|
||||||
|
- include_tasks: utils/run_once.yml
|
@@ -1,25 +1,6 @@
|
|||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
- name: "Load CDN for '{{ domain }}'"
|
- include_tasks: 01_core.yml
|
||||||
include_role:
|
|
||||||
name: web-svc-cdn
|
|
||||||
public: false
|
|
||||||
when:
|
|
||||||
#- inj_enabled.logout
|
|
||||||
#- inj_enabled.desktop
|
|
||||||
- application_id != 'web-svc-cdn'
|
|
||||||
- run_once_web_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 }}"
|
|
||||||
loop:
|
|
||||||
- svc-prx-openresty
|
|
||||||
- docker-compose
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item }}"
|
|
||||||
vars:
|
|
||||||
handler_role_name: "{{ item }}"
|
|
||||||
- include_tasks: utils/run_once.yml
|
|
||||||
when:
|
when:
|
||||||
- run_once_sys_svc_cdn is not defined
|
- run_once_sys_svc_cdn is not defined
|
||||||
|
|
||||||
@@ -30,12 +11,12 @@
|
|||||||
owner: "{{ NGINX.USER }}"
|
owner: "{{ NGINX.USER }}"
|
||||||
group: "{{ NGINX.USER }}"
|
group: "{{ NGINX.USER }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
loop: "{{ cdn_dirs }}"
|
loop: "{{ cdn_dirs_role }}"
|
||||||
|
|
||||||
- name: Ensure 'latest' symlink points to current release
|
- name: Ensure 'latest' symlink points to current release
|
||||||
file:
|
file:
|
||||||
src: "{{ cdn.role.release.root }}"
|
src: "{{ cdn_paths_all.role.release.root }}"
|
||||||
dest: "{{ [cdn.role.root, 'latest'] | path_join }}"
|
dest: "{{ [cdn_paths_all.role.root, 'latest'] | path_join }}"
|
||||||
state: link
|
state: link
|
||||||
force: true
|
force: true
|
||||||
when: CDN_VERSION != 'latest'
|
when: CDN_VERSION != 'latest'
|
||||||
|
@@ -1,19 +1,22 @@
|
|||||||
# Base CDN root (shared across all roles)
|
# Base CDN root (shared across all roles)
|
||||||
CDN_ROOT: "{{ NGINX.DIRECTORIES.DATA.CDN }}"
|
CDN_ROOT: "{{ NGINX.DIRECTORIES.DATA.CDN }}"
|
||||||
|
|
||||||
# Default version identifier: UTC timestamp
|
# Default version identifier: UTC timestamp
|
||||||
CDN_VERSION: "latest" # Latest is used atm because timestamp based would just lead to an unneccessary overhead
|
CDN_VERSION: "latest" # Latest is used atm because timestamp based would just lead to an unneccessary overhead
|
||||||
|
|
||||||
# Base Url to deliver the files
|
# Base Url to deliver the files
|
||||||
CDN_BASE_URL: "{{ domains | get_url('web-svc-cdn', WEB_PROTOCOL) }}"
|
CDN_BASE_URL: "{{ domains | get_url('web-svc-cdn', WEB_PROTOCOL) }}"
|
||||||
|
|
||||||
# Role specific CDN paths
|
# Role specific CDN paths
|
||||||
|
|
||||||
## Build CDN path structure (via filter)
|
## Build CDN path structure (via filter)
|
||||||
cdn: "{{ CDN_ROOT | cdn_paths(application_id, CDN_VERSION) }}"
|
cdn_paths_all: "{{ CDN_ROOT | cdn_paths(application_id, CDN_VERSION) }}"
|
||||||
|
|
||||||
|
## Global CDN dirs
|
||||||
|
CDN_DIRS_GLOBAL: "{{ (cdn_paths_all.shared | cdn_dirs) + [cdn_paths_all.vendor] }}"
|
||||||
|
|
||||||
## Flatten CDN dict to list of all string paths
|
## Flatten CDN dict to list of all string paths
|
||||||
cdn_dirs: "{{ cdn | cdn_dirs }}"
|
cdn_dirs_role: "{{ cdn_paths_all.role | cdn_dirs }}"
|
||||||
|
|
||||||
# Dictionary with all urls
|
# Dictionary with all urls
|
||||||
cdn_urls: "{{ cdn | cdn_urls(CDN_BASE_URL) }}"
|
cdn_urls: "{{ cdn_paths_all | cdn_urls(CDN_BASE_URL) }}"
|
||||||
|
Reference in New Issue
Block a user