feat(server): allow configuring nextcloud settings by populating nextcloud_extra_config
This commit is contained in:
parent
feadc801d5
commit
e9715e31bf
30
roles/server/tasks/configure-single-setting.yml
Normal file
30
roles/server/tasks/configure-single-setting.yml
Normal 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(" "))
|
||||||
|
}}
|
@ -135,40 +135,10 @@
|
|||||||
state: started
|
state: started
|
||||||
when: nextcloud_background_job_mode == 'cron'
|
when: nextcloud_background_job_mode == 'cron'
|
||||||
|
|
||||||
- name: Check nextcloud background job mode
|
- name: Configure nextcloud
|
||||||
community.docker.docker_container_exec:
|
include_tasks:
|
||||||
container: "{{ nextcloud_container_name }}"
|
file: configure-single-setting.yml
|
||||||
command: "{{ nextcloud_occ_command }} config:app:get core backgroundjobs_mode"
|
vars:
|
||||||
user: "{{ nextcloud_user_info.uid }}"
|
key: "{{ item.key | replace('[', '.') | replace(']', '.') }}"
|
||||||
tty: yes
|
value: "{{ item.value }}"
|
||||||
register: nextcloud_current_backgroundjob_mode
|
loop: "{{ lookup('ansible.utils.to_paths', nextcloud_config ) | dict2items }}"
|
||||||
# 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
|
|
||||||
|
@ -25,5 +25,18 @@ nextcloud_container_base_environment_yaml: |+2
|
|||||||
PHP_MEMORY_LIMIT: "{{ nextcloud_php_memory_limit }}"
|
PHP_MEMORY_LIMIT: "{{ nextcloud_php_memory_limit }}"
|
||||||
PHP_UPLOAD_LIMIT: "{{ nextcloud_php_upload_limit }}"
|
PHP_UPLOAD_LIMIT: "{{ nextcloud_php_upload_limit }}"
|
||||||
|
|
||||||
|
nextcloud_config: "{{ nextcloud_base_config | combine(nextcloud_extra_config|default({}), recursive=True, list_merge='append') }}"
|
||||||
|
nextcloud_base_config:
|
||||||
|
system:
|
||||||
|
# TODO: needs to have conditions as f.ex. sqlite doesn't have a user
|
||||||
|
dbhost: "{{ nextcloud_database_host }}"
|
||||||
|
dbuser: "{{ nextcloud_database_user }}"
|
||||||
|
dbpassword: "{{ nextcloud_database_pass }}"
|
||||||
|
dbname: "{{ nextcloud_database_name }}"
|
||||||
|
#dbtype: "{{ nextcloud_db_types[nextcloud_database_type] }}"
|
||||||
|
app:
|
||||||
|
core:
|
||||||
|
backgroundjobs_mode: "{{ nextcloud_background_job_mode }}"
|
||||||
|
|
||||||
nextcloud_occ_command: "php occ"
|
nextcloud_occ_command: "php occ"
|
||||||
nextcloud_container_php_socket_path: /var/run/php
|
nextcloud_container_php_socket_path: /var/run/php
|
||||||
|
Loading…
Reference in New Issue
Block a user