implement upgrade

main
n0emis 3 years ago
parent d4bcf4f68e
commit ab3db12fca
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -18,6 +18,7 @@ nextcloud_datadir: "/var/www/nextcloud/data"
# nextcloud_db_password
# nextcloud_admin_password
nextcloud_config: []
# nextcloud_config:
# - key: foobar
# value: baz

@ -7,39 +7,25 @@
group: "{{ nextcloud_group }}"
loop:
- "{{ nextcloud_directory }}"
- "{{ nextcloud_directory }}/nextcloud-{{ nextcloud_version }}"
- "{{ nextcloud_install_directory }}"
- "{{ nextcloud_datadir }}"
- name: Download Nextcloud release
get_url:
url: "{{ nextcloud_download }}"
dest: "{{ nextcloud_directory }}/nextcloud-{{ nextcloud_version }}.tar.bz2"
owner: "{{ nextcloud_user }}"
group: "{{ nextcloud_group }}"
- name: Get current installed nextcloud version
stat:
path: "{{ nextcloud_directory }}/current"
register: nc_current
- name: Extract the nextcloud release
- name: Download and extract the nextcloud release
become: yes
become_user: "{{ nextcloud_user }}"
unarchive:
src: "{{ nextcloud_directory }}/nextcloud-{{ nextcloud_version }}.tar.bz2"
src: "{{ nextcloud_download }}"
dest: "{{ nextcloud_install_directory }}"
remote_src: yes
extra_opts:
- "--strip-components=1"
when: not nc_current.stat.lnk_target is defined or nc_current.stat.lnk_target != nextcloud_install_directory
# TODO: Detect older installed releases
# TODO: copy old nextcloud config
# TODO: only run if not newly installed and when nc should be updated
- name: Put nextcloud into maintenance mode
become: yes
become_user: "{{ nextcloud_user }}"
command: "php occ maintenance:mode --on"
args:
chdir: "{{ nextcloud_directory }}/current"
ignore_errors: yes
# TODO: only run if newly installed, then remove ignore_error
- name: Generate nextcloud config file
become: yes
become_user: "{{ nextcloud_user }}"
@ -56,8 +42,14 @@
args:
chdir: "{{ nextcloud_install_directory }}"
creates: "{{ nextcloud_install_directory }}/config/config.php"
ignore_errors: yes
register: setup_nc
when: not nc_current.stat.lnk_target is defined
- name: Copy old nextcloud config
copy:
src: "{{ nextcloud_directory }}/current/config/config.php"
dest: "{{ nextcloud_install_directory }}/config/config.php"
remote_src: yes
when: not nc_current.stat.lnk_target is defined or nc_current.stat.lnk_target != nextcloud_install_directory
- name: Configure nextcloud
become: yes
@ -67,7 +59,16 @@
chdir: "{{ nextcloud_install_directory }}"
loop: "{{ nextcloud_config }}"
# TODO: run update command
# TODO: install apps
- name: Put nextcloud into maintenance mode
become: yes
become_user: "{{ nextcloud_user }}"
command: "php occ maintenance:mode --on"
args:
chdir: "{{ nextcloud_directory }}/current"
ignore_errors: yes
when: nc_current.stat.lnk_target is defined and nc_current.stat.lnk_target != nextcloud_install_directory
- name: Symlink current nextcloud version
become: yes
@ -79,6 +80,15 @@
group: "{{ nextcloud_group }}"
state: link
- name: Put nextcloud into maintenance mode
become: yes
become_user: "{{ nextcloud_user }}"
command: "php occ upgrade --no-interaction"
args:
chdir: "{{ nextcloud_directory }}/current"
ignore_errors: yes
when: nc_current.stat.lnk_target is defined and nc_current.stat.lnk_target != nextcloud_install_directory
- name: Take nextcloud out of maintenance mode
become: yes
become_user: "{{ nextcloud_user }}"

Loading…
Cancel
Save