2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2020-02-16 16:29:12 +00:00
# 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"
2022-12-21 19:18:27 +00:00
# shell: php -v | head -1 | sed 's/^[^0-9.]*//; s/[^0-9.].*//'
2020-02-16 16:29:12 +00:00
# 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-28 03:37:02 +00:00
2021-06-27 22:25:49 +00:00
# February 2020: See @m-anish's PR #2119 and follow-up PR #2258.
2023-06-15 13:01:38 +00:00
# 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
2023-03-21 14:57:19 +00:00
# https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html
2021-07-06 18:44:54 +00:00
# https://docs.nextcloud.com/server/latest/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
2023-06-15 13:01:38 +00:00
# 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 :
2020-03-19 16:12:17 +00:00
#- 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?
2021-06-29 23:34:48 +00:00
- 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
2021-06-30 03:04:50 +00:00
- 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
2021-06-29 23:34:48 +00:00
- php{{ php_version }}-curl # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
2021-07-06 18:44:54 +00:00
#- 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'
2021-06-29 23:34:48 +00:00
- php{{ php_version }}-gd # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml
2021-06-30 03:04:50 +00:00
- 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
2021-06-29 23:34:48 +00:00
- 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
2022-10-19 13:51:24 +00:00
#- php{{ php_version }}-json # Included with PHP >= 8.0 -- see stanza just below
2020-03-19 16:12:17 +00:00
#- php{{ php_version }}-libxml # NOT INSTALLABLE: ENABLED BY DEFAULT (https://www.php.net/manual/en/libxml.installation.php)
2021-06-29 23:34:48 +00:00
- 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
2022-10-19 13:51:24 +00:00
#- php{{ php_version }}-openssl # Included with PHP >= 8.0 -- NOT INSTALLABLE
2021-06-27 21:58:44 +00:00
#- php{{ php_version }}-pdo_mysql # NOT INSTALLABLE: php{{ php_version }}-mysql handles this on all OS's?
2020-03-19 16:12:17 +00:00
#- 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)
2021-06-29 23:34:48 +00:00
- 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}
2021-06-27 23:43:22 +00:00
#- php{{ php_version }}-xmlrpc # 2021-06-27: Experimentally remove, as explained in moodle/tasks/install.yml
2021-06-29 23:34:48 +00:00
- php{{ php_version }}-zip # Likewise installed in moodle/tasks/install.yml, pbx/tasks/freepbx_dependencies.yml, wordpress/tasks/install.yml
2020-03-19 16:12:17 +00:00
#- 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.
2021-06-28 04:01:09 +00:00
# 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', '<')
2021-06-25 18:21:03 +00:00
2022-12-30 09:09:46 +00:00
- 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
2022-12-29 16:48:17 +00:00
2020-02-16 16:29:12 +00:00
2021-07-06 19:11:55 +00:00
- name : Create dir {{ nextcloud_root_dir }} (by default 755 dirs & 644 files)
2019-07-05 00:43:15 +00:00
file :
state : directory
2020-02-17 01:52:01 +00:00
path : "{{ nextcloud_root_dir }}" # /library/www/nextcloud
2019-07-05 00:43:15 +00:00
2023-04-30 18:25:30 +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"
2023-03-24 23:49:54 +00:00
set_fact :
nextcloud_dl_url : https://download.nextcloud.com/server/releases/latest-25.tar.bz2
2023-04-30 18:25:30 +00:00
when : php_version is version('8.0', '<')
2023-03-24 23:49:54 +00:00
2022-11-11 02:04:26 +00:00
- 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 }}"
2020-02-17 01:52:01 +00:00
#dest: "{{ nextcloud_base_dir }}" # /library/www
dest : "{{ nextcloud_root_dir }}" # /library/www/nextcloud
2021-02-19 19:39:39 +00:00
owner : "{{ apache_user }}" # www-data on debuntu
2019-07-05 00:43:15 +00:00
group : "{{ apache_user }}"
2020-02-17 01:52:01 +00:00
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
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'nextcloud_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : nextcloud
option : nextcloud_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2020-01-30 09:00:00 +00:00
- name : "Set 'nextcloud_installed: True'"
set_fact :
nextcloud_installed : True
2020-01-12 23:15:33 +00:00
- name : "Add 'nextcloud_installed: True' to {{ iiab_state_file }}"
2019-09-09 17:14:13 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
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 '