diff --git a/roles/internetarchive/tasks/main.yml b/roles/internetarchive/tasks/main.yml index 9f364e92a..fd0f196d5 100644 --- a/roles/internetarchive/tasks/main.yml +++ b/roles/internetarchive/tasks/main.yml @@ -2,7 +2,7 @@ - name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x fail: - msg: "Internet Archive install cannot proceeed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml" + msg: "Internet Archive install cannot proceed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml" when: internetarchive_install and (nodejs_version != "10.x") - name: Install packages needed by Distributed Web diff --git a/roles/nextcloud/defaults/main.yml b/roles/nextcloud/defaults/main.yml index 38392bbb5..11fd0371c 100644 --- a/roles/nextcloud/defaults/main.yml +++ b/roles/nextcloud/defaults/main.yml @@ -5,20 +5,20 @@ # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! # REMOVE /opt/nextcloud/version.php TO FORCE AN INSTALL OR REINSTALL OR UPGRADE -nextcloud_force_install: False nextcloud_url: /nextcloud nextcloud_prefix: /opt -nextcloud_data_dir: "{{ content_base }}/nextcloud/data" +nextcloud_data_dir: "{{ content_base }}/nextcloud/data" # /library/nextcloud/data nextcloud_dl_url: https://download.nextcloud.com/server/releases -# 2019-05-11: latest-16.tar.bz2 finally published to https://download.nextcloud.com/server/releases/ (nextcloud/server#15502) e.g. for Ubuntu 18.04 & Debian 10 -nextcloud_orig_src_file_old: latest-15.tar.bz2 # 2019-05-16: for legacy OS's Debian 9 & Raspbian 9 where PHP 7.1+ isn't available +# For OLD OS's where PHP 7.1+ isn't detected -- e.g. Raspbian 9, Debian 9, Ubuntu 16.04 +nextcloud_orig_src_file_old: latest-15.tar.bz2 nextcloud_src_file_old: nextcloud_{{ nextcloud_orig_src_file_old }} -nextcloud_orig_src_file: latest-16.tar.bz2 # 2019-05-16: for all other OS's e.g. Debian 10 & Ubuntu 18.04 where PHP 7.1+ is hopefully available! +# For NEW OS's where PHP 7.1+ is auto-detected -- e.g. Raspbian 10, Debian 10 & Ubuntu 18.04 +nextcloud_orig_src_file: latest-16.tar.bz2 nextcloud_src_file: nextcloud_{{ nextcloud_orig_src_file }} -# we install on mysql with these setting or those from default_vars, etc. +# We install on MySQL with these settings: nextcloud_dbname: nextcloud nextcloud_dbhost: localhost nextcloud_dbuser: nextcloud diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/enable_or_disable.yml similarity index 100% rename from roles/nextcloud/tasks/nextcloud_enabled.yml rename to roles/nextcloud/tasks/enable_or_disable.yml diff --git a/roles/nextcloud/tasks/install.yml b/roles/nextcloud/tasks/install.yml new file mode 100644 index 000000000..697210feb --- /dev/null +++ b/roles/nextcloud/tasks/install.yml @@ -0,0 +1,225 @@ +# CHECK FOR PHP VERSION AUTOMATICALLY, TO DETERMINE WHICH NEXTCLOUD TO INSTALL. +# INSPIRED BY: github.com/iiab/iiab/blob/master/roles/nodejs/tasks/main.yml#L10-L54 + +- 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.]*//' | sed '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 + + +- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file_old }} to {{ downloads_dir }}/{{ nextcloud_src_file_old }} on older OS's lacking PHP 7.1+ + get_url: + url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file_old }}" + dest: "{{ downloads_dir }}/{{ nextcloud_src_file_old }}" + timeout: "{{ download_timeout }}" + force: yes + #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 + #async: 1800 + #poll: 10 + tags: + - download + when: internet_available and not php_new + #when: internet_available and nextcloud_force_install and (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + +- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }} on newer OS's that have PHP 7.1+ + get_url: + url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}" + dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}" + timeout: "{{ download_timeout }}" + force: yes + #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 + #async: 1800 + #poll: 10 + tags: + - download + when: internet_available and php_new + #when: internet_available and nextcloud_force_install and not (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + +# Ubuntu and Debian treat names differently +- name: Install 3 php packages (debian) + package: + name: + - "libapache2-mod-php{{ php_version }}" + - "php{{ php_version }}-mbstring" + - "php{{ php_version }}-zip" + state: present + when: is_debian | bool + +# Ubuntu and Debian treat names differently +- name: Install 4 php packages (ubuntu) + package: + name: + - libapache2-mod-php + - php-imagick + - php-zip + - php-mbstring + state: present + when: is_ubuntu | bool + +- name: Install 5 more php packages (debuntu) + package: + name: + - "php{{ php_version }}-gd" + - "php{{ php_version }}-json" + - "php{{ php_version }}-mysql" + - "php{{ php_version }}-curl" + - "php{{ php_version }}-intl" + state: present + when: is_debuntu | bool + +- name: 'Install php{{ php_version }}-mcrypt IF this is a "pre-2018" distro in the debuntu family. NOTE: PHP 7.1 deprecated mcrypt 1-Dec-2016 and PHP 7.2 dropped it completely 30-Nov-2017, as it should no longer be nec.' + package: + name: "php{{ php_version }}-mcrypt" + state: present + when: is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 + # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml + # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) + +# we need to install the rpm in order to get the dependencies +# but we only need to do this the first time + +- name: Install 7 php packages (redhat) + package: + name: + - php + - php-gd + - php-json + - php-mysql + - php-curl + - php-intl + - php-mcrypt + # CentOS does not have a package for php-imagick + #- php-imagick + state: present + when: is_redhat | bool + +- name: Unarchive {{ nextcloud_src_file_old }} to permanent location {{ nextcloud_prefix }}/nextcloud on older OS's lacking PHP 7.1+ # i.e. unpack nextcloud_latest-15.tar.bz2 to /opt/nextcloud + unarchive: + src: "{{ downloads_dir }}/{{ nextcloud_src_file_old }}" + dest: "{{ nextcloud_prefix }}" + #creates: "{{ nextcloud_prefix }}/nextcloud/version.php" + when: not php_new + #when: nextcloud_force_install and (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + +- name: Unarchive {{ nextcloud_src_file }} to permanent location {{ nextcloud_prefix }}/nextcloud on newer OS's that have PHP 7.1+ # i.e. unpack nextcloud_latest-16.tar.bz2 to /opt/nextcloud + unarchive: + src: "{{ downloads_dir }}/{{ nextcloud_src_file }}" + dest: "{{ nextcloud_prefix }}" + #creates: "{{ nextcloud_prefix }}/nextcloud/version.php" + when: php_new | bool + #when: nextcloud_force_install and not (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + +- name: Create dir /etc/nextcloud (centos) for a subsequent config dir that's symlinked to /etc/nextcloud ? + file: + path: /etc/nextcloud + state: directory + when: is_centos | bool + +- name: Install {{ nextcloud_prefix }}/nextcloud/config/autoconfig.php from template (centos) + template: + src: autoconfig.php.j2 + dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php" + owner: "{{ apache_user }}" + group: "{{ apache_user }}" + mode: 0640 + when: is_centos | bool + +- name: chown -R {{ apache_user }}:{{ apache_user }} {{ nextcloud_prefix }}/nextcloud + file: + path: "{{ nextcloud_prefix }}/nextcloud" + owner: "{{ apache_user }}" + group: "{{ apache_user }}" + recurse: yes + state: directory + +- name: Create data directory {{ nextcloud_data_dir }} # /opt/nextcloud/data + file: + path: "{{ nextcloud_data_dir }}" + owner: "{{ apache_user }}" + group: "{{ apache_user }}" + mode: 0750 + state: directory + +- name: 'Create MySQL database with name: {{ nextcloud_dbname }}' + mysql_db: + name: "{{ nextcloud_dbname }}" + when: mysql_enabled and nextcloud_enabled + +- name: Add username/password to the MySQL database (associated with trusted IP's like localhost) + mysql_user: + name: "{{ nextcloud_dbuser }}" + host: "{{ item }}" + password: "{{ nextcloud_dbpassword }}" + priv: "{{ nextcloud_dbname }}.*:ALL,GRANT" + with_items: + - "{{ nextcloud_dbhost }}" + - 127.0.0.1 + - ::1 + - localhost + when: mysql_enabled and nextcloud_enabled + +# Appears unnec as nextcloud_enabled.yml (just below) does the same +#- name: Restart Apache +# service: +# name: "{{ apache_service }}" +# state: restarted +## when: nextcloud_enabled | bool # taken care of by nextcloud_enabled.yml below +# when: not nextcloud_enabled + +# Enables or disable Nextcloud! +- include_tasks: enable_or_disable.yml + +- name: Add 'nextcloud' variable values to {{ iiab_ini_file }} + ini_file: + path: "{{ iiab_ini_file }}" + section: Nextcloud + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: Nextcloud + - option: description + value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."' + - option: path + value: "{{ nextcloud_prefix }}/nextcloud" + #- option: nextcloud_force_install + # value: "{{ nextcloud_force_install }}" + - option: nextcloud_orig_src_file + value: "{{ nextcloud_orig_src_file }}" + - option: nextcloud_src_file + value: "{{ nextcloud_src_file }}" + - option: nextcloud_enabled + value: "{{ nextcloud_enabled }}" diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 2487b1e91..13bd12b01 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -4,192 +4,13 @@ register: nextcloud_page - name: FORCE INSTALL OR REINSTALL OR UPGRADE IF {{ nextcloud_prefix }}/nextcloud/version.php DOESN'T EXIST - set_fact: - nextcloud_force_install: True - when: not nextcloud_page.stat.exists + #set_fact: + # nextcloud_force_install: True + include_tasks: install.yml + when: nextcloud_install and not nextcloud_page.stat.exists # - debug: # var: nextcloud_force_install # - debug: # msg: "nextcloud_force_install: {{ nextcloud_force_install }}" - -- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file_old }} to {{ downloads_dir }}/{{ nextcloud_src_file_old }} on older OS's lacking PHP 7.1+ - get_url: - url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file_old }}" - dest: "{{ downloads_dir }}/{{ nextcloud_src_file_old }}" - timeout: "{{ download_timeout }}" - force: yes - #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 - #async: 1800 - #poll: 10 - tags: - - download - when: internet_available and nextcloud_force_install and (is_debian_9 or is_raspbian_9) - -- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }} on newer OS's that have PHP 7.1+ - get_url: - url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}" - dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}" - timeout: "{{ download_timeout }}" - force: yes - #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 - #async: 1800 - #poll: 10 - tags: - - download - when: internet_available and nextcloud_force_install and not (is_debian_9 or is_raspbian_9) - -# Ubuntu and Debian treat names differently -- name: Install 3 php packages (debian) - package: - name: - - "libapache2-mod-php{{ php_version }}" - - "php{{ php_version }}-mbstring" - - "php{{ php_version }}-zip" - state: present - when: is_debian | bool - -# Ubuntu and Debian treat names differently -- name: Install 4 php packages (ubuntu) - package: - name: - - libapache2-mod-php - - php-imagick - - php-zip - - php-mbstring - state: present - when: is_ubuntu | bool - -- name: Install 5 more php packages (debuntu) - package: - name: - - "php{{ php_version }}-gd" - - "php{{ php_version }}-json" - - "php{{ php_version }}-mysql" - - "php{{ php_version }}-curl" - - "php{{ php_version }}-intl" - state: present - when: is_debuntu | bool - -- name: 'Install php{{ php_version }}-mcrypt IF this is a "pre-2018" distro in the debuntu family. NOTE: PHP 7.1 deprecated mcrypt 1-Dec-2016 and PHP 7.2 dropped it completely 30-Nov-2017, as it should no longer be nec.' - package: - name: "php{{ php_version }}-mcrypt" - state: present - when: is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 - # NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/.yml - # DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!) - -# we need to install the rpm in order to get the dependencies -# but we only need to do this the first time - -- name: Install 7 php packages (redhat) - package: - name: - - php - - php-gd - - php-json - - php-mysql - - php-curl - - php-intl - - php-mcrypt - # CentOS does not have a package for php-imagick - #- php-imagick - state: present - when: is_redhat | bool - -- name: Unarchive {{ nextcloud_src_file_old }} to permanent location {{ nextcloud_prefix }}/nextcloud on older OS's lacking PHP 7.1+ # e.g. unpack nextcloud_latest-15.tar.bz2 to /opt/nextcloud - unarchive: - src: "{{ downloads_dir }}/{{ nextcloud_src_file_old }}" - dest: "{{ nextcloud_prefix }}" - #creates: "{{ nextcloud_prefix }}/nextcloud/version.php" - when: nextcloud_force_install and (is_debian_9 or is_raspbian_9) - -- name: Unarchive {{ nextcloud_src_file }} to permanent location {{ nextcloud_prefix }}/nextcloud on newer OS's that have PHP 7.1+ # e.g. unpack nextcloud_latest-16.tar.bz2 to /opt/nextcloud - unarchive: - src: "{{ downloads_dir }}/{{ nextcloud_src_file }}" - dest: "{{ nextcloud_prefix }}" - #creates: "{{ nextcloud_prefix }}/nextcloud/version.php" - when: nextcloud_force_install and not (is_debian_9 or is_raspbian_9) - -- name: Create dir /etc/nextcloud (centos) for a subsequent config dir that's symlinked to /etc/nextcloud ? - file: - path: /etc/nextcloud - state: directory - when: is_centos | bool - -- name: Install {{ nextcloud_prefix }}/nextcloud/config/autoconfig.php from template (centos) - template: - src: autoconfig.php.j2 - dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php" - owner: "{{ apache_user }}" - group: "{{ apache_user }}" - mode: 0640 - when: is_centos | bool - -- name: chown -R {{ apache_user }}:{{ apache_user }} {{ nextcloud_prefix }}/nextcloud - file: - path: "{{ nextcloud_prefix }}/nextcloud" - owner: "{{ apache_user }}" - group: "{{ apache_user }}" - recurse: yes - state: directory - -- name: Create data directory {{ nextcloud_data_dir }} # /opt/nextcloud/data - file: - path: "{{ nextcloud_data_dir }}" - owner: "{{ apache_user }}" - group: "{{ apache_user }}" - mode: 0750 - state: directory - -- name: 'Create MySQL database with name: {{ nextcloud_dbname }}' - mysql_db: - name: "{{ nextcloud_dbname }}" - when: mysql_enabled and nextcloud_enabled - -- name: Add username/password to the MySQL database (associated with trusted IP's like localhost) - mysql_user: - name: "{{ nextcloud_dbuser }}" - host: "{{ item }}" - password: "{{ nextcloud_dbpassword }}" - priv: "{{ nextcloud_dbname }}.*:ALL,GRANT" - with_items: - - "{{ nextcloud_dbhost }}" - - 127.0.0.1 - - ::1 - - localhost - when: mysql_enabled and nextcloud_enabled - -# Appears unnec as nextcloud_enabled.yml (just below) does the same -#- name: Restart Apache -# service: -# name: "{{ apache_service }}" -# state: restarted -## when: nextcloud_enabled | bool # taken care of by nextcloud_enabled.yml below -# when: not nextcloud_enabled - -# Enables or disable Nextcloud! -- include_tasks: nextcloud_enabled.yml - -- name: Add 'nextcloud' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: Nextcloud - option: "{{ item.option }}" - value: "{{ item.value }}" - with_items: - - option: name - value: Nextcloud - - option: description - value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."' - - option: path - value: "{{ nextcloud_prefix }}/nextcloud" - - option: nextcloud_force_install - value: "{{ nextcloud_force_install }}" - - option: nextcloud_orig_src_file - value: "{{ nextcloud_orig_src_file }}" - - option: nextcloud_src_file - value: "{{ nextcloud_src_file }}" - - option: nextcloud_enabled - value: "{{ nextcloud_enabled }}" diff --git a/roles/nodejs/tasks/main.yml b/roles/nodejs/tasks/main.yml index f2de51b3a..3e504b09c 100644 --- a/roles/nodejs/tasks/main.yml +++ b/roles/nodejs/tasks/main.yml @@ -13,6 +13,9 @@ # IF SO & THIS DOESN'T MATCH nodejs_version AS SET IN defaults_vars.yml # AND/OR local_vars.yml, INSTALL HALTS WITH AN EXPLANATION (PR #1447) +# 2019-07-04: FOR A SOMEWHAT MORE MODERN "VERSION DETECTOR" SEE: +# github.com/iiab/iiab/blob/master/roles/nextcloud/tasks/install.yml#L1-L40 + - name: Try to run 'nodejs -v' to get Node.js version # 'node -v' doesn't work with older versions e.g. Ubuntu 16.04's nodejs 4.2.6 # Both below convert v10.15.1 to 10.x, but this is safer: (removes non-digits) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index 138dedf03..339f4b0eb 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -1,6 +1,6 @@ - name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x fail: - msg: "Sugarizer install cannot proceeed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml" + msg: "Sugarizer install cannot proceed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml" when: sugarizer_install and (nodejs_version != "10.x")