mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-15 16:40:45 +02:00
• Add config.performance.async.wait_for and expose as nextcloud_wait_for_async_enabled to toggle waiting for async jobs. • Split system/admin/index maintenance into separate tasks: 02_add_missing_indices.yml, 03_admin.yml, 04_system_config.yml. • Refactor plugin flow: rename 02_plugin→05_plugin, 03_plugin_routines→06_plugin_routines, 04_plugin_enable_and_configure→07_plugin_enable_and_configure; remove old 03_plugin_routines and 05_system. • Harden async handling: filter async_status loops by ansible_job_id; conditionally wait only when nextcloud_wait_for_async_enabled; reduce delay to 1s. • Reorder main.yml to run system steps before plugin setup; keep handlers flush earlier. • env.j2: simplify get_app_conf lookups (drop extra True flag). • vars/main.yml: add nextcloud_host_nginx_path and nextcloud_wait_for_async_enabled. https://chatgpt.com/share/689c9d4a-1748-800f-b490-06a5a48dd831
63 lines
2.5 KiB
YAML
63 lines
2.5 KiB
YAML
- name: enable {{plugin_key}} nextcloud plugin
|
|
command: "{{nextcloud_docker_exec_occ}} app:enable {{plugin_key}}"
|
|
register: enable_result
|
|
changed_when: enable_result.rc == 0 and ("already enabled" not in enable_result.stdout)
|
|
|
|
- name: Check if {{nextcloud_control_node_plugin_vars_directory}}{{ plugin_key }}.yml exists
|
|
stat:
|
|
path: "{{nextcloud_control_node_plugin_vars_directory}}{{ plugin_key }}.yml"
|
|
delegate_to: localhost
|
|
become: false
|
|
register: plugin_vars_file
|
|
|
|
- name: "Load {{ plugin_key }} configuration variables"
|
|
include_vars:
|
|
file: "{{nextcloud_control_node_plugin_vars_directory}}{{ plugin_key }}.yml"
|
|
when: plugin_vars_file.stat.exists
|
|
|
|
- name: "Launch async: set {{ item.configkey }} for {{ item.appid }}"
|
|
ansible.builtin.command: >
|
|
{{ nextcloud_docker_exec_occ }} config:app:set {{ item.appid }} {{ item.configkey }}
|
|
--value '{{ item.configvalue | to_json if item.configvalue is mapping else item.configvalue }}'
|
|
loop: "{{ plugin_configuration }}"
|
|
loop_control:
|
|
label: "{{ item.appid }}:{{ item.configkey }}"
|
|
when: plugin_vars_file.stat.exists
|
|
async: 300 # max runtime per call (seconds) — adjust as needed
|
|
poll: 0 # don't wait; run in background
|
|
register: config_set_jobs
|
|
|
|
- name: "Wait for async jobs"
|
|
vars:
|
|
jobs_with_id: >-
|
|
{{ (config_set_jobs.results | default([]))
|
|
| selectattr('ansible_job_id','defined')
|
|
| list }}
|
|
ansible.builtin.async_status:
|
|
jid: "{{ item.ansible_job_id }}"
|
|
register: config_set_wait
|
|
until: config_set_wait.finished
|
|
retries: 100
|
|
delay: 1
|
|
loop: "{{ jobs_with_id }}"
|
|
loop_control:
|
|
label: "{{ item._ansible_item_label | default(item.item.appid ~ ':' ~ item.item.configkey) }}"
|
|
when:
|
|
- jobs_with_id | length > 0
|
|
- nextcloud_wait_for_async_enabled | bool
|
|
failed_when: >
|
|
(config_set_wait.rc is defined and config_set_wait.rc|int != 0)
|
|
changed_when: >
|
|
(config_set_wait.stdout is defined) and
|
|
("Config value were not updated" not in config_set_wait.stdout)
|
|
|
|
- name: Check if {{nextcloud_control_node_plugin_tasks_directory}}{{ plugin_key }}.yml exists
|
|
stat:
|
|
path: "{{nextcloud_control_node_plugin_tasks_directory}}{{ plugin_key }}.yml"
|
|
delegate_to: localhost
|
|
become: false
|
|
register: plugin_tasks_file
|
|
|
|
- name: "include {{nextcloud_control_node_plugin_tasks_directory}}{{ plugin_key }}.yml"
|
|
include_tasks: "{{nextcloud_control_node_plugin_tasks_directory}}{{ plugin_key }}.yml"
|
|
when: plugin_tasks_file.stat.exists |