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.
125 lines
3.6 KiB
YAML
125 lines
3.6 KiB
YAML
---
|
|
|
|
- name: Install required dependencies
|
|
apt:
|
|
state: present
|
|
name:
|
|
# For Office / Video Previews
|
|
- ffmpeg
|
|
- libreoffice
|
|
# 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-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
|
|
become_user: "{{ system_user }}"
|
|
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:
|
|
backrefs: yes
|
|
path: "{{ nextcloud_config }}"
|
|
insertafter: "array \\("
|
|
regexp: "^(\\s*)0 => '.*',$"
|
|
line: "\\g<1>0 => '{{ domain }}',"
|
|
validate: /usr/bin/php %s
|
|
|
|
- name: Configure Nextcloud default domain for cli
|
|
become_user: "{{ system_user }}"
|
|
lineinfile:
|
|
backrefs: yes
|
|
path: "{{ nextcloud_config }}"
|
|
insertafter: "'version'"
|
|
regexp: "^(\\s*)'overwrite.cli.url' => '.*',$"
|
|
line: "\\1'overwrite.cli.url' => 'https://{{ domain }}',"
|
|
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 }} php -f \"{{ nextcloud_installation_directory }}/cron.php\""
|
|
|
|
- name: Configure auto backup of nextcloud data directory
|
|
cron:
|
|
hour: 1
|
|
minute: 0
|
|
job: "{{ global_helper_directory }}/backup_files.sh {{ nextcloud_data_directory | quote }} {{ domain | quote }}"
|
|
name: "backup nextcloud data of {{ domain }}"
|
|
state: present
|