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.

196 lines
5.0 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"
- 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)
with_items:
- accessibility
- activity
- admin_audit
- apporder
- bruteforcesettings
- calendar
- checksum
- cloud_federation_api
- comments
- contacts
- dav
- deck
- dicomviewer
- external
- federatedfilesharing
- federation
- files
- files_automatedtagging
- files_external
- files_pdfviewer
- files_rightclick
- files_sharing
- files_texteditor
- files_trashbin
- files_versions
- files_videoplayer
- firstrunwizard
- gallery
- logreader
- lookup_server_connector
- mail
- metadata
- nextcloud_announcements
- notes
- notifications
- oauth2
- password_policy
- polls
- previewgenerator
- provisioning_api
- quota_warning
- serverinfo
- sharebymail
- sharerenamer
- social
- sociallogin
- socialsharing_email
- spreed
- support
- survey_client
- suspicious_login
- systemtags
- tasks
- theming
- twofactor_admin
- twofactor_backupcodes
- twofactor_gateway
- twofactor_nextcloud_notification
- twofactor_totp
- twofactor_u2f
- updatenotification
- workflowengine
- name: Set background job mode to cron
become_user: "{{ system_user }}"
command: /usr/bin/php occ background:cron
args:
chdir: "{{ nextcloud_installation_directory }}"
- 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: Add background cron job for preview generation
cron:
name: "nextcloud preview cron for {{ domain }}"
hour: 3
minute: 0
job: "sudo -u {{ system_user | quote }} php -f {{ nextcloud_installation_directory | quote }}/occ preview:pre-generate"
- 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
#- name: Upgrade Nextcloud
# become_user: "{{ system_user }}"
# command: /usr/bin/php occ upgrade
# args:
# chdir: "{{ nextcloud_installation_directory }}"
# register: nextcloud_upgrade_result
# changed_when: "'already latest version' not in nextcloud_upgrade_result.rc"