nextcloud(role): remove async → use batched shell; more robust changed_when/failed_when; fix quoting; refactor plugin routines; clean up vars

• 02_add_missing_indices.yml: switched to shell (+ansible_command_timeout), removed async/poll.

• 04_system_config.yml: batch OCC calls (set -euo pipefail, /bin/bash), safer quoting, change detection via ' set to '.

• 05_plugin.yml: disable task with stricter failed_when/changed_when (combine stdout+stderr).

• 06_plugin_routines.yml: disable incompatible plugins in a single batch; no async_status; robust changed_when.

• 07_plugin_enable_and_configure.yml: batch config:app:set, safe quoting, clear changed_when/failed_when.

• config/main.yml & vars/main.yml: removed performance.async.wait_for and nextcloud_wait_for_async_enabled.
This commit is contained in:
2025-08-13 18:15:50 +02:00
parent 567b1365c0
commit e2014b9b59
7 changed files with 60 additions and 115 deletions

View File

@@ -15,41 +15,22 @@
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 }}"
- name: "Set plugin configuration (batched shell, no async)"
ansible.builtin.shell: |
set -euo pipefail
{% for item in (plugin_configuration | default([])) %}
{{ nextcloud_docker_exec_occ }} \
config:app:set {{ item.appid }} {{ item.configkey }} \
--value '{{ ( (item.configvalue | to_json) if (item.configvalue is mapping) else (item.configvalue | string) )
| regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
{% endfor %}
args:
executable: /bin/bash
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)
register: config_set_shell
changed_when: >
(config_set_wait.stdout is defined) and
("Config value were not updated" not in config_set_wait.stdout)
(config_set_shell.stdout | default('')) is search(' set to ')
failed_when: config_set_shell.rc != 0
- name: Check if {{nextcloud_control_node_plugin_tasks_directory}}{{ plugin_key }}.yml exists
stat: