Explicitly handles maintenance mode around instance setup; Provides and runs database utils scripts

This commit is contained in:
Jan Beilicke 2025-04-18 21:11:32 +02:00
parent 11fe863b6d
commit 93ed612a65
4 changed files with 57 additions and 0 deletions

View file

@ -15,6 +15,25 @@
group: "{{ docker_user }}"
mode: '0644'
- name: Ensure database utils scripts directory exists
file:
path: /home/{{ docker_user }}/nextcloud/utils
state: directory
owner: '{{ docker_user }}'
group: '{{ docker_user }}'
- name: Provide database utils scripts
copy:
src: "{{ item }}"
dest: /home/{{ docker_user }}/nextcloud/utils/
owner: "{{ docker_user }}"
group: "{{ docker_user }}"
mode: '0644'
loop: "{{ nextcloud_database_utils }}"
when:
- nextcloud_database_utils is defined
- nextcloud_database_utils | length > 0
- name: Provide docker-compose.yml
template:
src: templates/docker-compose.nextcloud.yml.j2
@ -131,6 +150,11 @@
host: "{{ nextcloud_ip }}"
port: 80
- name: "docker-compose: Enable maintenance mode using occ"
shell:
chdir: /home/{{ docker_user }}/nextcloud/
cmd: docker-compose exec -T -u www-data nextcloud-app /bin/sh -c './occ maintenance:mode --on'
- name: "docker-compose: Set overwriteprotocol using occ"
shell:
chdir: /home/{{ docker_user }}/nextcloud/
@ -172,6 +196,20 @@
debug:
var: "{{ nextcloud_app_install_result }}"
- name: "docker-compose: Run database utils"
shell:
chdir: /home/{{ docker_user }}/nextcloud/
cmd: docker-compose exec -T mysqldb /bin/sh '/opt/utils/{{ item }}'
loop: "{{ nextcloud_database_utils }}"
when:
- nextcloud_database_utils is defined
- nextcloud_database_utils | length > 0
- name: "docker-compose: Disable maintenance mode using occ"
shell:
chdir: /home/{{ docker_user }}/nextcloud/
cmd: docker-compose exec -T -u www-data nextcloud-app /bin/sh -c './occ maintenance:mode --off'
- name: "Test whether Nextcloud is healthy from the outside"
when: not ansible_check_mode
become: false