05_system_config.ymlΒΆ

---
- name: βš™οΈ Load System Nextcloud configuration variables
  include_vars:
    file: system.yml

- name: "πŸ“Œ Apply Nextcloud system configs (batched shell)"
  ansible.builtin.shell: |
    set -euo pipefail
    {% for item in nextcloud_system_config %}
    {{ NEXTCLOUD_DOCKER_EXEC_OCC }} \
      config:system:set {{ item.parameter }}{% if item.type is defined %} --type {{ item.type }}{% endif %} \
      --value '{{ (item.value | string) | regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
    {% endfor %}
    {% for key in nextcloud_system_config_absent %}
    if {{ NEXTCLOUD_DOCKER_EXEC_OCC }} config:system:get {{ key }} >/dev/null; then
      {{ NEXTCLOUD_DOCKER_EXEC_OCC }} config:system:delete {{ key }}
    fi
    {% endfor %}
  args:
    executable: /bin/bash
  register: syscfg_shell
  changed_when: >
    ( ((syscfg_shell.stdout | default('')) ~ (syscfg_shell.stderr | default('')))
      is search(' set to | deleted') )
  failed_when: syscfg_shell.rc != 0
  retries: 3
  delay: 5
  until: syscfg_shell.rc == 0

- name: "πŸ” Trust the internal Root CA in Nextcloud's own HTTP client bundle"
  ansible.builtin.shell: >
    {{ NEXTCLOUD_DOCKER_EXEC_OCC }}
    security:certificates:import {{ CA_TRUST.inject_cert_container | quote }}
  changed_when: false
  when: lookup('tls', application_id, 'mode') == 'self_signed'