1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/nextcloud/tasks/install.yml

147 lines
9.1 KiB
YAML
Raw Normal View History

- name: Record (initial) disk space used
shell: df -B1 --output=used / | tail -1
register: df1
# CHECK FOR PHP VERSION AUTOMATICALLY, TO DETERMINE WHICH NEXTCLOUD TO INSTALL.
# INSPIRED BY: github.com/iiab/iiab/blob/master/roles/nodejs/tasks/main.yml
# - name: Try to run 'php -v' to get PHP version
# # e.g. converts multi-line "PHP 7.0.33-0ubuntu0.16.04.5 (cli) ( NTS ) ..." to "7.0.33"
# shell: php -v | head -1 | sed 's/^[^0-9.]*//; s/[^0-9.].*//'
# register: php_version_installed
# #ignore_errors: yes # NOT NEC: if php is not installed, php_version_installed.stdout will get set to ""
# - debug:
# var: php_version_installed
# # NOTE: this could easily be made to work even if PHP was not installed, e.g.
# # by pre-initializing variable 'php_new' to False here. But trapping the
# # absence of PHP (below) is a useful software safety precondition!
# #
# #- name: Initialize var 'php_new' to False
# # set_fact:
# # php_new: False
# - name: INTENTIONALLY FAIL, IF PHP (Nextcloud prerequisite) ISN'T INSTALLED
# fail:
# msg: >
# Nextcloud install cannot proceed, as it requires PHP be installed first.
# Note that as of 2019-07-04, IIAB takes care of this by forcing vars
# mysql_install and mysql_enabled to True in
# /opt/iiab/iiab/roles/0-init/tasks/main.yml, which in turn forces the
# installation of PHP in /opt/iiab/iiab/roles/mysql/tasks/main.yml, as
# invoked by /opt/iiab/iiab/roles/3-base-server/tasks/main.yml
# when: php_version_installed.stdout == ""
# - name: Set var 'php_new' indicating if installed version of PHP ({{ php_version_installed.stdout }}) >= 7.1, as required by Nextcloud 16
# set_fact:
# php_new: "{{ php_version_installed.stdout is version('7.1', '>=') }}"
# # Ansible's Version Comparison routine:
# # https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#version-comparison
# when: php_version_installed.stdout != "" # i.e. IF ABOVE 'php -v' WORKED
# - debug:
# var: php_new
2021-06-27 22:25:49 +00:00
# February 2020: See @m-anish's PR #2119 and follow-up PR #2258.
# 2023-03-21 & 2023-06-15: Check latest required AND recommended prereqs below.
# e.g. Nextcloud 26 now works with PHP 8.2; Nextcloud 27 deprecates PHP 8.0
# https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html
# https://docs.nextcloud.com/server/latest/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
# https://docs.nextcloud.com/server/27/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
# https://docs.nextcloud.com/server/26/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
2021-06-27 20:01:53 +00:00
- name: Install ffmpeg + libxml2 + 11 PHP packages (run 'php -m' or 'php -i' to verify)
2019-07-05 00:43:15 +00:00
package:
name:
#- dnsutils # NOT REQUESTED by Nextcloud
- ffmpeg # Optional (for preview generation)
- libxml2 # php-libxml requires libxml2 >= 2.7.0
2020-02-16 03:49:27 +00:00
#- libapache2-mod-php # 2020-02-15: NO LONGER NEEDED?
- php{{ php_version }}-bcmath # Highly recommended by Nextcloud 21 for "improved performance and better compatibility" -- Likewise installed in pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
- php{{ php_version }}-bz2 # OPTIONAL (for extraction of apps)
2021-06-27 22:25:49 +00:00
#- php{{ php_version }}-common # Auto-installed as an apt dependency. REGARDLESS: php{{ php_version }}-common superset php{{ php_version }}-cli is auto-installed by php{{ php_version }}-fpm in nginx/tasks/install.yml
- php{{ php_version }}-curl # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
#- php{{ php_version }}-exif # OPTIONAL (for image rotation in pictures app) but somehow already installed with PHP's core, as confirmed by 'php -m'
#- php{{ php_version }}-fileinfo # OPTIONAL (enhances file analysis performance) but somehow already installed with PHP's core, as confirmed by 'php -m'
- php{{ php_version }}-gd # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml
- php{{ php_version }}-gmp # OPTIONAL (for SFTP storage)
- php-imagick # OPTIONAL (for preview generation). BUT drags in Apache's libapache2-mod-phpX.Y etc, as confirmed by 'apt depends php-imagick' -- while php{{ php_version }}-imagick installs (despite not being shown within 'apt list "php*imagick"') it's no better -- and 'apt depends phpX.Y-imagick' mysteriously does NOT show its deps. Likewise installed in wordpress/tasks/install.yml
- php{{ php_version }}-intl # OPTIONAL (increases language translation performance and fixes sorting of non-ASCII characters): Likewise installed in mediawiki/tasks/install.yml, moodle/tasks/install.yml, wordpress/tasks/install.yml
#- php{{ php_version }}-json # Included with PHP >= 8.0 -- see stanza just below
#- php{{ php_version }}-libxml # NOT INSTALLABLE: ENABLED BY DEFAULT (https://www.php.net/manual/en/libxml.installation.php)
- php{{ php_version }}-mbstring # Likewise installed in mediawiki/tasks/install.yml, moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
- php{{ php_version }}-mysql # Likewise installed in mysql/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
#- php{{ php_version }}-openssl # Included with PHP >= 8.0 -- NOT INSTALLABLE
#- php{{ php_version }}-pdo_mysql # NOT INSTALLABLE: php{{ php_version }}-mysql handles this on all OS's?
#- php{{ php_version }}-redis # @m-anish future work?
#- php{{ php_version }}-session # NOT INSTALLABLE: ENABLED BY DEFAULT?
#- php{{ php_version }}-smbclient # Optional (SMB/CIFS integration)
- php{{ php_version }}-xml # Likewise installed in mediawiki/tasks/install.yml, moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml -- AND REGARDLESS dragged in later by Admin Console's use of php-pear for roles/cmdsrv/tasks/main.yml -- Nextcloud's official requirements include {SimpleXML, XMLReader, XMLWriter} as confirmed by 'php -m | grep -i xml' which in the end shows {libxml, SimpleXML, xml, xmlreader, xmlwriter}
#- php{{ php_version }}-xmlrpc # 2021-06-27: Experimentally remove, as explained in moodle/tasks/install.yml
- php{{ php_version }}-zip # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
#- php{{ php_version }}-zlib # NOT INSTALLABLE: ENABLED BY DEFAULT?
2019-07-05 00:43:15 +00:00
state: present
2021-06-27 20:01:53 +00:00
# For PHP >= 8.0: phpX.Y-json is baked into PHP itself.
# For PHP < 8.0: phpX.Y-json auto-installed by phpX.Y-fpm AND phpX.Y-cli in 3-base-server's nginx/tasks/install.yml, as confirmed by: apt rdepends phpX.Y-json
2021-06-27 20:01:53 +00:00
#
#- name: Install php{{ php_version }}-json if PHP < 8.0
# package:
# name: php{{ php_version }}-json
# state: present
# when: php_version is version('8.0', '<')
- name: "Run roles/www_options/tasks/php-settings.yml with 'nginx_high_php_limits: False' by default"
include_tasks: roles/www_options/tasks/php-settings.yml
when: php_settings_done is undefined
- name: Create dir {{ nextcloud_root_dir }} (by default 755 dirs & 644 files)
2019-07-05 00:43:15 +00:00
file:
state: directory
path: "{{ nextcloud_root_dir }}" # /library/www/nextcloud
2019-07-05 00:43:15 +00:00
- name: "2023-03-24: NEXTCLOUD 26 REQUIRES PHP 8 -- SO THIS TEMPORARY PATCH INSTALLS THE OLDER NEXTCLOUD 25 ON OS's WITH PHP 7.x -- WHOSE END-OF-LIFE WAS NOVEMBER 2022"
set_fact:
nextcloud_dl_url: https://download.nextcloud.com/server/releases/latest-25.tar.bz2
when: php_version is version('8.0', '<')
- name: Unarchive {{ nextcloud_dl_url }} (~140 MB) to {{ nextcloud_root_dir }} (~519 MB initially, sometimes ~543 MB later, {{ apache_user }}:{{ apache_user }})
2020-02-16 03:49:27 +00:00
unarchive:
2021-02-24 14:02:46 +00:00
remote_src: yes # Overwrite even if "already exists on the target"
2020-02-16 03:49:27 +00:00
src: "{{ nextcloud_dl_url }}"
#dest: "{{ nextcloud_base_dir }}" # /library/www
dest: "{{ nextcloud_root_dir }}" # /library/www/nextcloud
owner: "{{ apache_user }}" # www-data on debuntu
2019-07-05 00:43:15 +00:00
group: "{{ apache_user }}"
extra_opts: --strip-components=1 # Or use 'dest: /library/www' above
2020-02-16 03:49:27 +00:00
- name: Provision Nextcloud's MySQL DB, run Nextcloud's install wizard, etc
include_tasks: setup.yml
2019-07-05 00:43:15 +00:00
2020-01-29 14:21:00 +00:00
2020-01-30 09:00:00 +00:00
# RECORD Nextcloud AS INSTALLED
- name: Record (final) disk space used
shell: df -B1 --output=used / | tail -1
register: df2
- name: Add 'nextcloud_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: nextcloud
option: nextcloud_disk_usage
value: "{{ df2.stdout|int - df1.stdout|int }}"
2020-01-30 09:00:00 +00:00
- name: "Set 'nextcloud_installed: True'"
set_fact:
nextcloud_installed: True
- name: "Add 'nextcloud_installed: True' to {{ iiab_state_file }}"
2019-09-09 17:14:13 +00:00
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
2019-09-09 17:14:13 +00:00
regexp: '^nextcloud_installed'
2019-10-07 17:11:21 +00:00
line: 'nextcloud_installed: True'