You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.2 KiB
YAML
126 lines
4.2 KiB
YAML
---
|
|
- name: create nextcloud directory
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ nextcloud_user }}"
|
|
group: "{{ nextcloud_group }}"
|
|
loop:
|
|
- "{{ nextcloud_directory }}"
|
|
- "{{ nextcloud_install_directory }}"
|
|
- "{{ nextcloud_datadir }}"
|
|
|
|
- name: Get current installed nextcloud version
|
|
stat:
|
|
path: "{{ nextcloud_directory }}/current"
|
|
register: nc_current
|
|
|
|
- name: Download and extract the nextcloud release
|
|
become: yes
|
|
become_user: "{{ nextcloud_user }}"
|
|
unarchive:
|
|
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
|
|
|
|
- name: Generate nextcloud config file
|
|
become: yes
|
|
become_user: "{{ nextcloud_user }}"
|
|
command: |
|
|
php occ maintenance:install --no-interaction
|
|
--database {{ nextcloud_db_type }}
|
|
--database-host "{{ nextcloud_db_host }}" \
|
|
--database-name {{ nextcloud_db }} \
|
|
--database-user {{ nextcloud_db_user }} \
|
|
--database-pass {{ nextcloud_db_password }} \
|
|
--admin-user {{ nextcloud_admin }} \
|
|
--admin-pass {{ nextcloud_admin_password }} \
|
|
--data-dir {{ nextcloud_datadir }} \
|
|
args:
|
|
chdir: "{{ nextcloud_install_directory }}"
|
|
creates: "{{ nextcloud_install_directory }}/config/config.php"
|
|
when: not nc_current.stat.lnk_target is defined
|
|
|
|
- name: Copy old nextcloud config
|
|
become: yes
|
|
become_user: "{{ nextcloud_user }}"
|
|
copy:
|
|
src: "{{ nextcloud_directory }}/current/config/config.php"
|
|
dest: "{{ nextcloud_install_directory }}/config/config.php"
|
|
owner: "{{ nextcloud_user }}"
|
|
group: "{{ nextcloud_group }}"
|
|
remote_src: yes
|
|
when: nc_current.stat.lnk_target is defined and nc_current.stat.lnk_target != nextcloud_install_directory
|
|
|
|
- name: Configure nextcloud
|
|
become: yes
|
|
become_user: "{{ nextcloud_user }}"
|
|
command: "php occ config:system:set {{ item.key }} --value {{ item.value }}"
|
|
args:
|
|
chdir: "{{ nextcloud_install_directory }}"
|
|
loop: "{{ nextcloud_config }}"
|
|
|
|
# TODO: improve this!!! this is bad! (but it works)
|
|
- name: Install/Remove nextcloud apps
|
|
become_user: "{{ nextcloud_user }}"
|
|
command: "php occ app:{% if item.state | default('present') != 'absent' and item.state | default('present') != 'disabled' %}install{% elif item.state == 'disabled' %}disable{% else %}remove{% endif %} {{ item.name | default(item) }}"
|
|
args:
|
|
chdir: "{{ nextcloud_install_directory }}"
|
|
ignore_errors: yes
|
|
loop: "{{ nextcloud_apps }}"
|
|
|
|
- name: Make sure nextcloud apps are enabled
|
|
become_user: "{{ nextcloud_user }}"
|
|
command: "php occ app:enable {{ item.name | default(item) }}"
|
|
args:
|
|
chdir: "{{ nextcloud_install_directory }}"
|
|
ignore_errors: yes
|
|
when: item.state | default('present') != 'absent' and item.state | default('present')
|
|
loop: "{{ nextcloud_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
|
|
become_user: "{{ nextcloud_user }}"
|
|
file:
|
|
src: "{{ nextcloud_install_directory }}"
|
|
dest: "{{ nextcloud_directory }}/current"
|
|
owner: "{{ nextcloud_user }}"
|
|
group: "{{ nextcloud_group }}"
|
|
state: link
|
|
|
|
- name: Run nextcloud upgrade command
|
|
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 }}"
|
|
command: "php occ maintenance:mode --off"
|
|
args:
|
|
chdir: "{{ nextcloud_directory }}/current"
|
|
ignore_errors: yes
|
|
|
|
- name: Setup nextcloud cronjob
|
|
cron:
|
|
name: "nextcloud cronjob for {{ nextcloud_directory }}"
|
|
hour: "*/5"
|
|
user: "www-data"
|
|
job: "php {{ nextcloud_directory }}/current/cron.php"
|