ansible/roles/nextcloud/tasks/core/install.yml

81 lines
2.4 KiB
YAML
Raw Normal View History

2020-11-01 04:55:05 -06:00
---
# These tasks install Nextcloud if it is not installed on the system already.
# They should run only once.
- name: Install unzip
package:
name: unzip
state: present
when: download_file_type == '.zip'
- name: Install dependencies
package:
name: "{{ package }}"
loop: "{{ packages }}"
loop_control:
loop_var: package
vars:
packages:
- imagemagick
- name: Check if nextcloud is already installed
stat:
path: "{{ nextcloud_installation_dir }}/updater/updater.phar"
register: _result
- name: Download nextcloud
unarchive:
src: "{{ nextcloud_download_url }}"
dest: "{{ nextcloud_installation_parent_dir }}"
remote_src: true
owner: "{{ nextcloud_file_owner }}"
group: "{{ nextcloud_file_owner }}"
register: _result
when: not _result.stat.exists
- name: Install nextcloud
block:
# When extracting the downloaded nextcloud archive, the files are placed
# under a nextcloud folder. Here, we rename this folder if the user has
# specified a different folder.
- name: Move nextcloud folder
command: >-
mv
"{{ nextcloud_installation_parent_dir }}/nextcloud"
"{{ nextcloud_installation_dir }}"
when:
- _result is not skipped
- nextcloud_installation_dir | basename != "nextcloud"
- name: Create nextcloud data folder
file:
path: "{{ nextcloud_data_dir }}"
state: directory
owner: "{{ nextcloud_file_owner }}"
group: "{{ nextcloud_file_owner }}"
mode: 0o750
- name: Install nextcloud
command: >-
php occ maintenance:install
--no-interaction
--database "{{ nextcloud_database.backend }}"
--database-name "{{ nextcloud_database.name }}"
--database-user "{{ nextcloud_database.user }}"
--database-pass "{{ nextcloud_database.pass }}"
--database-host "{{ nextcloud_database.host }}"
--database-port "{{ nextcloud_database.port }}"
--database-table-prefix "{{ nextcloud_database.prefix }}"
--admin-user "{{ nextcloud_admin_user }}"
--admin-pass "{{ nextcloud_admin_pass }}"
--data-dir "{{ nextcloud_data_dir }}"
args:
chdir: "{{ nextcloud_installation_dir }}"
creates: "{{ nextcloud_installation_dir }}/config/config.php"
become: true
become_user: "{{ nextcloud_file_owner }}"
notify: nextcloud set file permissions
when: _result is not skipped