-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add playbook to upgrade nextcloud #2
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Routine to upgrade Nextcloud version | ||
# See variable NEXTCLOUD-VERSION to build your specific version | ||
|
||
- hosts: nextcloud | ||
gather_facts: yes | ||
tasks: | ||
|
||
- name: get nextcloud version | ||
community.docker.docker_container_exec: | ||
container: nextcloud-docker-app-1 | ||
user: www-data | ||
command: "php occ --version" | ||
register: result | ||
|
||
- name: Print stdout | ||
ansible.builtin.debug: | ||
var: result.stdout | ||
|
||
- name: Update NEXTCLOUD_VERSION in Dockerfile | ||
ansible.builtin.lineinfile: | ||
path: /root/projects/nextcloud-docker/.docker/app/Dockerfile | ||
regexp: '^ARG NEXTCLOUD_VERSION=.*' | ||
line: 'ARG NEXTCLOUD_VERSION=30-fpm' | ||
state: present | ||
become: true | ||
|
||
- name: Build images | ||
community.docker.docker_compose_v2: | ||
project_src: /root/projects/nextcloud-docker | ||
build: always | ||
register: output | ||
Comment on lines
+27
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acho que não precisa ser build always mas o que precisa é fazer o pull da imagem. O build só é feito quando o hash da imagem é diferente do hash do último build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acho que se está rodando essa playbook é para buildar mesmo. O que consigo pensar é verificar a versão atual que está em execução e a versão que foi lançada (se foi). A partir disso tomar uma decisão. Pode ser uma playbook a parte, bastando importar. O que acha? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. É um bom caminho pensando em poupar tempo de execução do playbook. |
||
|
||
- name: Show results | ||
ansible.builtin.debug: | ||
var: output | ||
|
||
- name: Enable maintenance mode | ||
community.docker.docker_container_exec: | ||
container: nextcloud-docker-app-1 | ||
user: www-data | ||
command: "php occ maintenance:mode --on" | ||
register: result | ||
|
||
|
||
- name: Restart containers | ||
community.docker.docker_compose_v2: | ||
project_src: /root/projects/nextcloud-docker | ||
state: restarted | ||
recreate: always | ||
register: output | ||
|
||
- name: Show results | ||
ansible.builtin.debug: | ||
var: output | ||
|
||
- name: Run aditional occ commands | ||
community.docker.docker_container_exec: | ||
container: nextcloud-docker-app-1 | ||
user: www-data | ||
command: "php occ {{ item }}" | ||
loop: | ||
- db:add-missing-columns | ||
- db:add-missing-indices | ||
- db:add-missing-primary-keys | ||
- maintenance:repair --include-expensive | ||
- config:system:set maintenance_window_start --type=integer --value=1 | ||
- app:update --all | ||
|
||
- name: Disable nextcloud maintenance mode | ||
community.docker.docker_container_exec: | ||
container: nextcloud-docker-app-1 | ||
user: www-data | ||
command: "php occ maintenance:mode --off" | ||
register: result | ||
|
||
- name: Get nextcloud version | ||
community.docker.docker_container_exec: | ||
container: nextcloud-docker-app-1 | ||
user: www-data | ||
command: "php occ --version" | ||
register: result | ||
|
||
- name: Print stdout | ||
ansible.builtin.debug: | ||
var: result.stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isto é uma environment, não é para ser alterado no Dockerfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A ideia seria fazer o upgrade de versão, mas, acabei mudando para 'stable-fpm' pois achei um risco. Acho que passar com o parâmetro
--build-arg
, quando quiser fazer upgrade de versão, é mais seguro. O que acha?