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

181 lines
4.8 KiB
YAML
Raw Normal View History

- name: See if Nextcloud version page exists
stat:
path: "{{ nextcloud_prefix }}/nextcloud/version.php"
# path: "{{ nextcloud_prefix }}/nextcloud/index.php"
2017-05-29 22:02:55 +00:00
register: nextcloud_page
- name: FORCE INSTALL OR REINSTALL OR UPGRADE IF /opt/nextcloud/version.php DOESN'T EXIST
set_fact:
nextcloud_force_install: True
when: not nextcloud_page.stat.exists
# - debug:
# msg: "nextcloud_force_install: {{ nextcloud_force_install }}"
2017-05-29 22:02:55 +00:00
- name: Download latest Nextcloud software to /opt/iiab/download/{{ nextcloud_src_file }}
get_url:
url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}"
dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}"
force: yes
2017-12-08 06:42:39 +00:00
timeout: "{{ download_timeout }}"
when: internet_available and nextcloud_force_install
async: 900
poll: 15
2017-05-29 22:02:55 +00:00
tags:
- download
2017-11-05 05:46:47 +00:00
- name: Ubuntu and Debian treat names differently (Debian)
package:
name: "{{ item }}"
state: present
with_items:
- "libapache2-mod-php{{ php_version }}"
- "php{{ php_version }}-mbstring"
- "php{{ php_version }}-zip"
when: is_debian
2017-11-05 05:46:47 +00:00
- name: Ubuntu and Debian treat names differently (Ubuntu)
package:
name: "{{ item }}"
state: present
with_items:
2017-06-19 01:16:28 +00:00
- libapache2-mod-php
- php-imagick
- php-zip
- php-mbstring
when: is_ubuntu
2017-11-05 05:44:34 +00:00
- name: Install list of packages (debuntu)
package:
name: "{{ item }}"
state: present
with_items:
- "php{{ php_version }}-gd"
- "php{{ php_version }}-json"
- "php{{ php_version }}-mysql"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-intl"
2018-04-28 20:45:08 +00:00
when: is_debuntu
2018-04-28 18:50:14 +00:00
2018-04-28 20:45:08 +00:00
- name: In php7.2, php dropped mcrypt
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
2018-04-28 20:45:08 +00:00
when: is_debuntu and not is_ubuntu_18
# we need to install the rpm in order to get the dependencies
# but we only need to do this the first time
2017-11-05 05:44:34 +00:00
- name: Install list of packages (redhat)
package:
name: "{{ item }}"
state: present
with_items:
- php
2017-05-30 02:37:12 +00:00
- php-gd
- php-json
- php-mysql
- php-curl
- php-intl
- php-mcrypt
# centos does not have a package for php-imagick
# - php-imagick
2017-05-30 02:37:12 +00:00
when: is_redhat
2017-11-05 05:44:34 +00:00
- name: Copy it to permanent location /opt (OS's other than Fedora 18)
unarchive:
src: "{{ downloads_dir }}/{{ nextcloud_src_file }}"
dest: "{{ nextcloud_prefix }}"
# creates: "{{ nextcloud_prefix }}/nextcloud/version.php"
when: not is_F18 and nextcloud_force_install
2017-05-29 22:02:55 +00:00
# Ansible 1.4.1 does not have "creates" (but hopefully has "when")
2017-11-05 05:44:34 +00:00
- name: Copy it to permanent location /opt (Fedora 18)
unarchive:
src: "{{ downloads_dir }}/{{ nextcloud_src_file }}"
dest: "{{ nextcloud_prefix }}"
when: is_F18 and nextcloud_force_install
2017-05-29 22:02:55 +00:00
2017-10-27 13:47:06 +00:00
- name: In CentOS, the following config dir is symlink 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
2017-11-05 05:44:34 +00:00
- name: Add autoconfig file (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
2017-10-27 13:47:06 +00:00
- name: Make Apache owner
file:
path: "{{ nextcloud_prefix }}/nextcloud"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
recurse: yes
state: directory
2017-05-29 22:02:55 +00:00
- name: Create data directory library
file:
path: "{{ item }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: 0750
state: directory
2017-05-29 22:02:55 +00:00
with_items:
- "{{ nextcloud_data_dir }}"
2017-10-27 13:47:06 +00:00
- name: Create a MySQL database for Nextcloud
mysql_db:
name: "{{ nextcloud_dbname }}"
2017-05-29 22:02:55 +00:00
when: mysql_enabled and nextcloud_enabled
2017-10-27 13:47:06 +00:00
- name: Create a user to access the Nextcloud database
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
2017-10-27 13:47:06 +00:00
- name: Restart Apache, so it picks up the new aliases
service:
name: "{{ apache_service }}"
state: restarted
# when: nextcloud_enabled # taken care of by nextcloud_enabled.yml below
when: not nextcloud_enabled
2017-05-29 22:02:55 +00:00
# Enable nextcloud by copying template to httpd config
2017-05-30 02:37:12 +00:00
# following enables and disables
2017-11-05 05:44:34 +00:00
- include_tasks: nextcloud_enabled.yml
2017-05-29 22:02:55 +00:00
2017-11-27 01:05:33 +00:00
- name: Add 'nextcloud' to list of services at /etc/iiab/iiab.ini
2017-11-27 01:12:09 +00:00
ini_file:
dest: "{{ service_filelist }}"
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"
- option: source
value: "{{ nextcloud_src_file }}"
- option: enabled
value: "{{ nextcloud_enabled }}"