You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
3.9 KiB
YAML

---
- name: Install required dependencies
apt:
state: present
name:
# For Office / Video Previews
- ffmpeg
- libreoffice
# For SMB Access
- smbclient
# For SVG support
- libmagickcore-6.q16-6-extra
# PHP Dependencies
- php-apcu
- php-bz2
- php-curl
# - php-dom
# - php-fileinfo
- php-gd
# - php-iconv
- php-imagick
- php-intl
- php-json
- php-mbstring
# - php-mcrypt
- php-mysql
# - php-posix
- php-redis
# - php-simplexml
- php-xml
# - php-xmlreader
# - php-xmlwriter
- php-zip
# TODO Redis
- name: Check if Nextcloud is already downloaded
stat:
path: "{{ nextcloud_installation_directory }}/index.php"
register: nextcloud_installed
check_mode: no
- name: Download Nextcloud
include_tasks: install.yml
when: not nextcloud_installed.stat.exists
- name: Create data directory
file:
state: directory
path: "{{ nextcloud_data_directory }}"
owner: "{{ system_user }}"
group: "{{ system_user }}"
mode: "u=rwx,g=rx,o="
- name: Install Nextcloud
become_user: "{{ system_user }}"
command: >-
/usr/bin/php occ maintenance:install
--database mysql
--database-name {{ database_name | quote }}
--database-user {{ database_user | quote }}
--database-pass {{ database_pass | quote }}
--database-table-prefix oc_
--admin-user {{ nextcloud_admin_user | quote }}
--admin-pass {{ nextcloud_admin_pass | quote }}
--data-dir {{ nextcloud_data_directory | quote }}
args:
chdir: "{{ nextcloud_installation_directory }}"
creates: "{{ nextcloud_config }}"
- name: Configure Nextcloud default domain
become_user: "{{ system_user }}"
lineinfile:
path: "{{ nextcloud_config }}"
firstmatch: yes
insertafter: "array \\("
regexp: "^(\\s*)0 => '([^.]\\.)+[^.]*',$"
line: " 0 => '{{ domain }}',"
validate: /usr/bin/php %s
- name: Configure Nextcloud default domain for cli
become_user: "{{ system_user }}"
lineinfile:
path: "{{ nextcloud_config }}"
firstmatch: yes
insertafter: "'version'"
regexp: "^(\\s*)'overwrite.cli.url' => '.*',$"
line: " 'overwrite.cli.url' => 'https://{{ domain }}',"
validate: /usr/bin/php %s
- name: Add additional entries to Nextcloud config
become_user: "{{ system_user }}"
blockinfile:
path: "{{ nextcloud_config }}"
insertbefore: "^\\);"
block: |
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => '{{ redis_socket_path }}',
'port' => 0,
],
validate: /usr/bin/php %s
- name: Install Nextcloud apps
become_user: "{{ system_user }}"
command: "/usr/bin/php occ app:install {{ item | quote }}"
args:
chdir: "{{ nextcloud_installation_directory }}"
register: nextcloud_apps_install_results
changed_when: "'already installed' not in nextcloud_apps_install_results.stdout"
failed_when: >-
nextcloud_apps_install_results.rc != 0 and
not (nextcloud_apps_install_results.rc == 1 and 'already installed' in nextcloud_apps_install_results.stdout)
loop: "{{ enabled_apps_list }}"
- name: Disable some Nextcloud apps
become_user: "{{ system_user }}"
command: "/usr/bin/php occ app:disable {{ item | quote }}"
args:
chdir: "{{ nextcloud_installation_directory }}"
register: nextcloud_apps_install_results
changed_when: "'No such app enabled: ' not in nextcloud_apps_install_results.stdout"
failed_when: nextcloud_apps_install_results.rc != 0
loop: "{{ disabled_apps_list }}"
- name: Add background cron job
cron:
name: "nextcloud cron for {{ domain }}"
minute: "*/5"
job: >-
sudo -u {{ system_user }}
/usr/bin/php
--define apc.enable_cli=1
--file {{ nextcloud_installation_directory | quote }}/cron.php