forked from jakub/ansible
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
# nextcloud/check_stack_nextcloud.yml
|
|
|
|
- name: Run Nextcloud maintenance
|
|
hosts: nextcloud
|
|
gather_facts: false
|
|
become: true
|
|
|
|
vars:
|
|
vm_commands:
|
|
- "docker exec -u www-data nextcloud php -f /var/www/html/cron.php"
|
|
- "docker exec -u www-data nextcloud php occ app:update --all"
|
|
- "docker exec -u www-data nextcloud php occ maintenance:repair --include-expensive"
|
|
- "docker exec -u www-data nextcloud php occ status"
|
|
- "set -o pipefail; timeout 180s bash -x /data/compose/nextcloud/stack-health.sh </dev/null"
|
|
|
|
tasks:
|
|
- name: Run Nextcloud commands
|
|
ansible.builtin.shell:
|
|
cmd: "{{ item }}"
|
|
executable: /bin/bash
|
|
loop: "{{ vm_commands }}"
|
|
register: vm_cmds
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Show command outputs
|
|
ansible.builtin.debug:
|
|
msg: |
|
|
CMD: {{ item.item }}
|
|
RC: {{ item.rc }}
|
|
STDOUT:
|
|
{{ item.stdout | default('') }}
|
|
STDERR:
|
|
{{ item.stderr | default('') }}
|
|
loop: "{{ vm_cmds.results }}"
|
|
|
|
- name: Fail when a command failed
|
|
ansible.builtin.assert:
|
|
that:
|
|
- item.rc == 0
|
|
fail_msg: "Command failed: {{ item.item }} (rc={{ item.rc }})"
|
|
quiet: true
|
|
loop: "{{ vm_cmds.results }}"
|