From 77d482b2d1c4333cd218ed059e2a33e81f8d4db3 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 4 Jul 2019 14:13:44 -0400 Subject: [PATCH] Check for PHP 7.1+ automatically, for Nextcloud 15/16 --- roles/nextcloud/tasks/main.yml | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 71d8521ee..904fd013e 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -14,6 +14,34 @@ # - debug: # msg: "nextcloud_force_install: {{ nextcloud_force_install }}" + +# 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-L51 + +- name: Try to run 'php -v' to get PHP version + 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 + +- name: Set var 'php_new' to False + set_fact: + php_new: False # Ansible prefers 'false' but IIAB norm is 'False' + #when: php_version_installed.stdout == "" # WORKS TOO, BUT NOT NEC + +- name: Set var 'php_new' indicating if PHP 7.1+ is installed + 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 != "" # IN CASE php NOT INSTALLED + +#- 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 }}" @@ -25,7 +53,8 @@ #poll: 10 tags: - download - when: internet_available and nextcloud_force_install and (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + when: internet_available and nextcloud_force_install 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: @@ -38,7 +67,8 @@ #poll: 10 tags: - download - when: internet_available and nextcloud_force_install and not (is_debian_9 or is_raspbian_9 or is_ubuntu_16) + when: internet_available and nextcloud_force_install 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) @@ -103,14 +133,16 @@ 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 or is_ubuntu_16) + when: nextcloud_force_install and 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+ # 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 or is_ubuntu_16) + when: nextcloud_force_install and php_new + #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: