Files
SavaneWiki/docs/Ansible/2023-10-01-nextcloud-docker-update-from-ansible.md
jf 97a9301ce3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
playbook upgrade_nc.yml passage aux modules ccommunity.docker.docker_compose_v2
2026-02-18 18:41:26 +01:00

98 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Mise à jour de Nextcloud docker par Ansible"
summary: "brief decription to sum up"
author:
- JF
date: 2023-10-01
---
# Mise à jour de Nextcloud docker par Ansible
## Prérequis
[Se connecter en SSH au Synology à laide dune clef asymétrique.](../Savaneprod/2019-09-01-access-synology-with-ssh-asymetrical-key.md)
## Le playbook
```yaml
---
- name: Mise à jour du conteneur Nextcloud
hosts: savaneprod.fr
vars:
nc_previous_version: 32.0.5
nc_version: 32.0.6
path_to_project: /volume1/nextcloud
tasks:
- name: Modification de la version dans le docker-compose
ansible.builtin.lineinfile:
path: /volume1/nextcloud/docker-compose.yaml
backrefs: true
backup: false
state: present
regexp: "^ image: nextcloud:"
line: " image: nextcloud:{{ nc_version }}"
- name: "Téléchargement de l'image nextcloud: {{ nc_version }}"
community.docker.docker_compose_v2_pull:
docker_cli: /usr/local/bin/docker
project_src: "{{ path_to_project }}"
- name: Compose down & compose up detached
# Needed on DSM : pip3 install docker-compose
community.docker.docker_compose_v2:
docker_cli: /usr/local/bin/docker
project_src: "{{ path_to_project }}"
recreate: auto
- name: Pause en attendant la remontée des conteneurs
ansible.builtin.pause:
minutes: 1
- name: "Suppression de la mention de création de compte"
tags: account
ansible.builtin.lineinfile:
path: "{{ path_to_project }}/data/config/config.php"
backup: false
state: present
insertafter: "CONFIG"
line: " 'simpleSignUpLink.shown' => false,"
- name: "Suppression de l'ancienne image : {{ nc_previous_version }}"
community.docker.docker_image_remove:
# Needed on DSM : pip3 install docker
name: nextcloud
tag: '{{ nc_previous_version }}'
- name: Modification du fichier .htaccess pour caldav Mac
tags: caldav
ansible.builtin.lineinfile:
path: /volume1/nextcloud/data/.htaccess
backup: false
state: present
search_string: "{{ item.search_string }}"
line: "{{ item.line }}"
loop:
- { search_string: 'RewriteRule ^\.well-known/carddav', line: ' RewriteRule ^\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]' }
- { search_string: 'RewriteRule ^\.well-known/caldav', line: ' RewriteRule ^\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]' }
- name: Pause avant mise à jour de la base de données
ansible.builtin.pause:
minutes: 2
- name: "Mise à jour de la base de données"
tags: db-maintenance
community.docker.docker_compose_v2_exec:
docker_cli: /usr/local/bin/docker
detach: true
project_src: "{{ path_to_project }}"
service: app
tty: true
user: www-data
command: "{{ item }}"
loop:
- "php occ db:add-missing-columns"
- "php occ db:add-missing-indices"
- "php occ db:add-missing-primary-keys"
- "php occ maintenance:repair --include-expensive"
- "php occ config:system:set maintenance_window_start --type=integer --value=1"
```