Compare commits

...

2 Commits

3 changed files with 56 additions and 37 deletions

View File

@ -0,0 +1,30 @@
---
- name: Ensure {{ key }} is set to {{ value }}
block:
- name: Check value of {{ key }}
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:{{ type }}:get {{ scope }} {{ entry }}"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
register: nextcloud_current_config_entry
changed_when: false
- name: Set {{ key }} to {{ value }}
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:{{ type }}:set {{ scope }} {{ entry }} --value={{ value }} -n"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
when: nextcloud_current_config_entry.stdout != value
notify: restart-nextcloud
vars:
entry_path: "{{ key.split('.') }}"
type: "{{ entry_path | first }}"
scope: "{{ entry_path[1] if entry_path | length > 2 else '' }}"
entry: >-
{{
entry_path[1] if entry_path|length == 2 else
(entry_path[2:] | join(" "))
}}

View File

@ -135,40 +135,10 @@
state: started
when: nextcloud_background_job_mode == 'cron'
- name: Check nextcloud background job mode
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:app:get core backgroundjobs_mode"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
register: nextcloud_current_backgroundjob_mode
# As nextcloud might still be starting, retry this task
retries: 5
delay: 5
changed_when: false
- name: Set nextcloud background job mode to {{ nextcloud_background_job_mode }}
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:app:set core backgroundjobs_mode {{ nextcloud_background_job_mode }}"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
when: nextcloud_current_backgroundjob_mode.stdout != nextcloud_background_job_mode
- name: Check nextcloud database host
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:system:get dbhost"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
register: nextcloud_current_dbhost
changed_when: false
- name: Set nextcloud database host mode to {{ nextcloud_database_host }}
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:system:set dbhost --value={{ nextcloud_database_host }} --update-only -n"
user: "{{ nextcloud_user_info.uid }}"
tty: yes
when: nextcloud_current_dbhost.stdout != nextcloud_database_host
notify: restart-nextcloud
- name: Configure nextcloud
include_tasks:
file: configure-single-setting.yml
vars:
key: "{{ item.key | replace('[', '.') | replace(']', '.') }}"
value: "{{ item.value }}"
loop: "{{ lookup('ansible.utils.to_paths', nextcloud_config ) | dict2items }}"

View File

@ -25,5 +25,24 @@ nextcloud_container_base_environment_yaml: |+2
PHP_MEMORY_LIMIT: "{{ nextcloud_php_memory_limit }}"
PHP_UPLOAD_LIMIT: "{{ nextcloud_php_upload_limit }}"
nextcloud_config: "{{ nextcloud_base_config | from_yaml | combine(nextcloud_extra_config|default({}), recursive=True, list_merge='append') }}"
nextcloud_base_config: |+2
{% if nextcloud_database_type != 'sqlite' %}
system:
dbhost: "{{ nextcloud_database_host }}"
dbuser: "{{ nextcloud_database_user }}"
dbpassword: "{{ nextcloud_database_pass }}"
dbname: "{{ nextcloud_database_name }}"
dbtype: "{{ nextcloud_database_types[nextcloud_database_type] }}"
{% endif %}
app:
core:
backgroundjobs_mode: "{{ nextcloud_background_job_mode }}"
nextcloud_occ_command: "php occ"
nextcloud_container_php_socket_path: /var/run/php
nextcloud_database_types:
postgres: pgsql
mysql: mysql
mariadb: mysql
sqlite: sqlite3