Newer
Older
- name: "create temporary download directory"
tempfile:
state: directory
suffix: "_nextcloud_new"
register: _tmp_new_nextcloud
changed_when: False
- name: "retrieving nextcloud version {{ app_version }} in {{ _tmp_new_nextcloud.path }}"
unarchive:
src: "https://download.nextcloud.com/server/releases/nextcloud-{{ app_version }}.tar.bz2"
dest: "{{ _tmp_new_nextcloud.path }}"
remote_src: True
group: "www-data"
owner: "www-data"
- name: "disable site for {{ app_domain }}"
file:
state: absent
path: "/etc/{{ rev_proxy }}/sites-enabled/{{ app_instance_id }}.conf"
- name: "reload {{ rev_proxy }}"
service: name={{ rev_proxy }} state=reloaded
- name: "create dir for backup current version {{ backup_version_dir | mandatory }}/{{ app_instance_id | mandatory }}/{{ app_old_version | mandatory }}"
path: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}"
- name: "create {{ rev_proxy }} dir for backup current version {{ backup_version_dir | mandatory }}/{{ app_instance_id | mandatory }}/{{ app_old_version | mandatory }}"
path: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/{{ rev_proxy }}"
- name: "create app dir for backup current version {{ backup_version_dir | mandatory }}/{{ app_instance_id | mandatory }}/{{ app_old_version | mandatory }}"
path: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app"
- name: "create sql dir for backup current version {{ backup_version_dir | mandatory }}/{{ app_instance_id | mandatory }}/{{ app_old_version | mandatory }}"
path: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/sql"
state: directory
mode: 0777
- name: "backup {{ rev_proxy }} config"
command: "cp /etc/{{ rev_proxy }}/sites-available/{{ app_instance_id }}.conf {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/{{ rev_proxy }}"
creates: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/{{ rev_proxy }}/{{ app_instance_id }}.conf"
command: "rsync -aAx --del {{ www_root }}/{{ app_instance_id}} {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app"
creates: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app/{{ app_instance_id }}"
shell: "/usr/bin/pg_dump {{ database_name }} > {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/sql/{{ database_name }}.sql"
become_user: "postgres"
vars:
ansible_ssh_pipelining: true
args:
creates: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/sql/{{ database_name }}.sql"
shell: "php {{ www_root }}/{{ app_instance_id}}/occ config:list > {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/config.list"
become_user: "www-data"
vars:
ansible_ssh_pipelining: true
args:
creates: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/config.list"
shell: "php {{ www_root }}/{{ app_instance_id}}/occ app:list > {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app.list"
become_user: "www-data"
vars:
ansible_ssh_pipelining: true
args:
creates: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app.list"
- name: "remove {{ www_root }}/{{ app_instance_id }}"
file:
path: "{{ www_root }}/{{ app_instance_id }}"
state: absent
- name: "Move {{ _tmp_new_nextcloud.path }}/nextcloud to {{ www_root }}/{{ app_instance_id }}"
command: "/bin/mv {{ _tmp_new_nextcloud.path }}/nextcloud {{ www_root }}/{{ app_instance_id }}"
- name: "remove {{ _tmp_new_nextcloud.path }}"
file:
path: "{{ _tmp_new_nextcloud.path }}"
state: absent
changed_when: False
- name: "restore config.php"
copy:
src: "{{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app/{{ app_instance_id}}/config/config.php"
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
dest: "{{ www_root }}/{{ app_instance_id }}/config/config.php"
remote_src: yes
backup: yes
# cron task or something ? may log while migrating
- name: "remove default data directory"
file:
state: absent
path: "{{ www_root }}/{{ app_instance_id }}/data"
- name: "www-data owner of {{ www_root }}/{{ app_instance_id }}"
file:
state: directory
path: "{{ www_root }}/{{ app_instance_id }}"
recurse: yes
owner: "www-data"
group: "www-data"
- name: "chmod 750 for directories"
command: "find {{ www_root }}/{{ app_instance_id }}/ -type d -exec chmod 750 {} \\;"
- name: "chmod 640 for files"
command: "find {{ www_root }}/{{ app_instance_id }}/ -type f -exec chmod 640 {} \\;"
- name: "enable site for {{ app_domain }}"
file:
state: link
path: "/etc/{{ rev_proxy }}/sites-enabled/{{ app_instance_id }}.conf"
src: "/etc/{{ rev_proxy }}/sites-available/{{ app_instance_id }}.conf"
- name: "ensure presence of {{ base_prod_options }}/nextcloud/"
file:
path: "{{ base_prod_options }}/nextcloud/"
state: directory
- name: "template for app enable script"
template:
src: "nextcloud_app_enable.j2"
dest: "{{ base_prod_options }}/nextcloud/nextcloud_app_enable.py"
mode: 0700
- name: "restore apps"
command: "{{ base_prod_options }}/nextcloud/nextcloud_app_enable.py {{ backup_version_dir }}/{{ app_instance_id }}/{{ app_old_version }}/app.list {{ www_root }}/{{ app_instance_id }}"
- name: "reload {{ rev_proxy }}"
service: name={{ rev_proxy }} state=reloaded