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

89 lines
2.6 KiB
YAML

---
# Main tasks in Nextcloud installation
- name: Install required packages
apt:
name: '{{ required_packages }}'
state: present
notify:
- start http
- start php-fpm
- fail:
msg: Debugging
- name: Configure Nginx web server
include_tasks: http_nginx.yml
- name: Configure Redis server
include_tasks: ./redis_server.yml
when: (nextcloud_install_redis_server | bool)
- block:
- name: Configure mysql/mariadb database
include_tasks: ./db_mysql.yml
when: nextcloud_db_backend in ["mysql", "mariadb"]
- name: Configure PostgreSQL database
include_tasks: ./db_postgresql.yml
when: nextcloud_db_backend in ["pgsql"]
when: nextcloud_install_db
- name: Check Nextcloud installed
stat: "path={{ nextcloud_webroot }}/index.php"
register: nc_nextcloud_installed
- name: Downloading Nextcloud
include_tasks: ./nc_download.yml
when: not nc_nextcloud_installed.stat.exists
- name: Check Nextcloud configuration exists.
stat: path="{{ nextcloud_webroot }}/config/config.php"
register: nc_nextcloud_conf
- name: Check Nextcloud is configured
command: grep -q "{{ nextcloud_trusted_domain| 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: "[NC apps] - lists the number of apps available in the instance."
command: php occ app:list --output=json_pretty --no-warnings
args:
chdir: "{{ nextcloud_webroot }}"
become_user: "{{ nextcloud_websrv_user }}"
become: yes
become_flags: "{{ ansible_become_flags | default(omit) }}"
changed_when: false
register: nc_apps_list
- name: "[NC apps] - convert list to yaml."
set_fact: nc_available_apps="{{ nc_apps_list.stdout | from_json }}"
- name: "[NC apps] - installation."
include_tasks: ./nc_apps.yml
# do if the app is not enabled and ( (archive path is not "") or (app is disabled) )
when:
- item.key not in nc_available_apps.enabled
- (item.value is not none) or (item.key in nc_available_apps.disabled)
with_dict: "{{ 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: "{{ nextcloud_websrv_user }}"
become: yes
become_flags: "{{ ansible_become_flags | default(omit) }}"