1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/nextcloud/tasks/main.yml

176 lines
5.5 KiB
YAML
Raw Normal View History

2018-10-31 07:12:14 +00:00
- name: Does /opt/nextcloud/version.php exist?
stat:
path: "{{ nextcloud_prefix }}/nextcloud/version.php"
2017-05-29 22:02:55 +00:00
register: nextcloud_page
2018-10-29 09:00:07 +00:00
- name: FORCE INSTALL OR REINSTALL OR UPGRADE IF {{ nextcloud_prefix }}/nextcloud/version.php DOESN'T EXIST
set_fact:
nextcloud_force_install: True
when: not nextcloud_page.stat.exists
# - debug:
2018-10-29 09:00:07 +00:00
# var: nextcloud_force_install
2017-05-29 22:02:55 +00:00
2018-10-29 09:00:07 +00:00
# - debug:
# msg: "nextcloud_force_install: {{ nextcloud_force_install }}"
2017-05-29 22:02:55 +00:00
2018-10-29 07:18:58 +00:00
- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }}
get_url:
url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}"
dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}"
2017-12-08 06:42:39 +00:00
timeout: "{{ download_timeout }}"
2019-01-10 17:44:24 +00:00
force: yes
2018-10-29 07:18:58 +00:00
#validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954
when: internet_available and nextcloud_force_install
2018-10-29 07:18:58 +00:00
#async: 1800
#poll: 10
2017-05-29 22:02:55 +00:00
tags:
- download
2018-10-28 17:22:47 +00:00
# Ubuntu and Debian treat names differently
- name: Install 3 php packages (debian)
package:
2018-10-28 17:22:47 +00:00
name:
- "libapache2-mod-php{{ php_version }}"
- "php{{ php_version }}-mbstring"
- "php{{ php_version }}-zip"
state: present
when: is_debian
2018-10-28 17:22:47 +00:00
# Ubuntu and Debian treat names differently
- name: Install 4 php packages (ubuntu)
package:
2018-10-28 17:22:47 +00:00
name:
- libapache2-mod-php
- php-imagick
- php-zip
- php-mbstring
state: present
when: is_ubuntu
2018-10-28 17:22:47 +00:00
- name: Install 5 more php packages (debuntu)
package:
2018-10-28 17:22:47 +00:00
name:
- "php{{ php_version }}-gd"
- "php{{ php_version }}-json"
- "php{{ php_version }}-mysql"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-intl"
state: present
2018-04-28 20:45:08 +00:00
when: is_debuntu
2018-04-28 18:50:14 +00:00
2019-01-13 12:55:48 +00:00
- name: 'Install php{{ php_version }}-mcrypt IF this is a "pre-2018" distro in the debuntu family. NOTE: PHP 7.1 deprecated mcrypt 1-Dec-2016 and PHP 7.2 dropped it completely 30-Nov-2017, as it should no longer be nec.'
2018-04-28 18:50:14 +00:00
package:
2018-04-28 20:45:08 +00:00
name: "php{{ php_version }}-mcrypt"
2018-04-28 18:50:14 +00:00
state: present
2019-01-15 18:48:52 +00:00
when: is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17
2019-01-13 08:46:37 +00:00
# NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/<OS>.yml
2019-01-13 11:06:16 +00:00
# DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!)
# we need to install the rpm in order to get the dependencies
# but we only need to do this the first time
2018-10-28 17:22:47 +00:00
- name: Install 7 php packages (redhat)
package:
2018-10-28 17:22:47 +00:00
name:
- php
- php-gd
- php-json
- php-mysql
- php-curl
- php-intl
- php-mcrypt
# CentOS does not have a package for php-imagick
#- php-imagick
state: present
2017-05-30 02:37:12 +00:00
when: is_redhat
2018-10-31 18:17:43 +00:00
- name: Unarchive {{ nextcloud_src_file }} to permanent location {{ nextcloud_prefix }}/nextcloud # e.g. unpack nextcloud_latest-14.tar.bz2 to /opt/nextcloud
unarchive:
src: "{{ downloads_dir }}/{{ nextcloud_src_file }}"
dest: "{{ nextcloud_prefix }}"
2018-10-28 20:44:32 +00:00
#creates: "{{ nextcloud_prefix }}/nextcloud/version.php"
when: nextcloud_force_install
2017-05-29 22:02:55 +00:00
2018-10-29 09:00:07 +00:00
- name: Create dir /etc/nextcloud (centos) for a subsequent config dir that's symlinked to /etc/nextcloud ?
file:
path: /etc/nextcloud
state: directory
2017-05-30 02:37:12 +00:00
when: is_centos
2017-05-29 22:02:55 +00:00
2018-10-29 09:00:07 +00:00
- name: Install {{ nextcloud_prefix }}/nextcloud/config/autoconfig.php from template (centos)
template:
src: autoconfig.php.j2
dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: 0640
2017-05-30 02:37:12 +00:00
when: is_centos
2017-05-29 22:02:55 +00:00
2018-10-29 09:00:07 +00:00
- name: chown -R {{ apache_user }}:{{ apache_user }} {{ nextcloud_prefix }}/nextcloud
file:
path: "{{ nextcloud_prefix }}/nextcloud"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
recurse: yes
state: directory
2017-05-29 22:02:55 +00:00
2018-10-29 09:00:07 +00:00
- name: Create data directory {{ nextcloud_data_dir }} # /opt/nextcloud/data
file:
2018-10-29 09:00:07 +00:00
path: "{{ nextcloud_data_dir }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: 0750
state: directory
2017-05-29 22:02:55 +00:00
2018-10-29 09:21:15 +00:00
- name: 'Create MySQL database with name: {{ nextcloud_dbname }}'
mysql_db:
name: "{{ nextcloud_dbname }}"
2017-05-29 22:02:55 +00:00
when: mysql_enabled and nextcloud_enabled
2018-10-29 09:00:07 +00:00
- name: Add username/password to the MySQL database (associated with trusted IP's like localhost)
mysql_user:
name: "{{ nextcloud_dbuser }}"
host: "{{ item }}"
password: "{{ nextcloud_dbpassword }}"
priv: "{{ nextcloud_dbname }}.*:ALL,GRANT"
with_items:
2018-02-06 21:44:06 +00:00
- "{{ nextcloud_dbhost }}"
- 127.0.0.1
- ::1
- localhost
when: mysql_enabled and nextcloud_enabled
2018-10-29 09:00:07 +00:00
# Appears unnec as nextcloud_enabled.yml (just below) does the same
#- name: Restart Apache
# service:
# name: "{{ apache_service }}"
# state: restarted
## when: nextcloud_enabled # taken care of by nextcloud_enabled.yml below
# when: not nextcloud_enabled
2018-10-29 09:00:07 +00:00
# Enables or disable Nextcloud!
2017-11-05 05:44:34 +00:00
- include_tasks: nextcloud_enabled.yml
2017-05-29 22:02:55 +00:00
2018-10-31 07:12:14 +00:00
- name: Add 'nextcloud' variable values to {{ iiab_ini_file }}
2017-11-27 01:12:09 +00:00
ini_file:
2018-10-31 07:12:14 +00:00
path: "{{ iiab_ini_file }}"
2017-11-27 01:12:09 +00:00
section: Nextcloud
option: "{{ item.option }}"
value: "{{ item.value }}"
2017-05-29 22:02:55 +00:00
with_items:
2017-12-08 06:42:39 +00:00
- option: name
value: Nextcloud
- option: description
value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."'
- option: path
value: "{{ nextcloud_prefix }}/nextcloud"
2018-10-29 09:00:07 +00:00
- option: nextcloud_force_install
value: "{{ nextcloud_force_install }}"
- option: nextcloud_orig_src_file
value: "{{ nextcloud_orig_src_file }}"
- option: nextcloud_src_file
2017-12-08 06:42:39 +00:00
value: "{{ nextcloud_src_file }}"
2018-10-29 09:00:07 +00:00
- option: nextcloud_enabled
2017-12-08 06:42:39 +00:00
value: "{{ nextcloud_enabled }}"