ansible-role-nextcloud/roles/nextcloud/tasks/main.yml

82 lines
2.1 KiB
YAML

---
# Main tasks in Nextcloud installation
- name: Install required packages
apt:
name: '{{ required_packages }}'
state: present
notify:
- start http
- start php-fpm
- name: Configure Nginx web server
include_tasks: http_nginx.yml
- name: Configure Redis server
include_tasks: redis_server.yml
- name: Configure MySQL database
include_tasks: db_mysql.yml
#- name: Configure PostgreSQL database
# include_tasks: ./db_postgresql.yml
- name: Check whether Nextcloud is installed
stat:
path: '{{ nextcloud_webroot }}/index.php'
register: nc_nextcloud_installed
- name: Download Nextcloud
include_tasks: nc_download.yml
when: not nc_nextcloud_installed.stat.exists
- name: Check whether Nextcloud configuration exists
stat:
path: '{{ nextcloud_webroot }}/config/config.php'
register: nc_nextcloud_conf
- name: Check whether Nextcloud is configured
command: grep -q '{{ nextcloud_trusted_domains | first }}' {{ nextcloud_webroot }}/config/config.php
failed_when: False
changed_when: False
register: nc_nextcloud_configured
when: nc_nextcloud_conf.stat.exists
- name: Nextcloud installation
include_tasks: nc_installation.yml
when: |
(not nc_nextcloud_conf.stat.exists) or
(nc_nextcloud_configured.rc is defined and nc_nextcloud_configured.rc != 0)
- block:
- name: Lists the Nextcloud apps available
command: 'php occ app:list --output=json_pretty --no-warnings'
args:
chdir: '{{ nextcloud_webroot }}'
become_user: 'www-data'
become: yes
changed_when: false
register: nc_apps_list
- name: Convert list of apps to YAML
set_fact:
nc_available_apps: '{{ nc_apps_list.stdout | from_json }}'
- name: Install selected Nexctcloud apps
include_tasks: nc_apps.yml
when:
- item.key not in nc_available_apps.enabled
- (item.value is not none) or (item.key in nc_available_apps.disabled)
loop: '{{ nextcloud_apps }}'
when:
- nextcloud_apps is defined
- nextcloud_apps is mapping
- name: Add indices
command: 'php occ db:add-missing-indices'
args:
chdir: '{{ nextcloud_webroot }}'
become_user: 'www-data'
become: yes