From 39b36c2522706944a71ca1634048248b4c2fc78b Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Fri, 5 May 2023 10:35:21 +0100 Subject: [PATCH] Fix PHP checks --- tasks/checks.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tasks/checks.yml b/tasks/checks.yml index 3a29e2c..8e4a90d 100644 --- a/tasks/checks.yml +++ b/tasks/checks.yml @@ -225,13 +225,32 @@ - name: Set a fact for the default version of PHP ansible.builtin.set_fact: apache_php_update_alt_q: "{{ apache_update_alternatives_query_php.stdout | string | community.general.jc('update_alt_q') }}" - apache_php_version: "{{ apache_update_alternatives_query_php.stdout | string | community.general.jc('update_alt_q') | community.general.json_query('value') | regex_replace('^/usr/bin/php') }}" - - name: Debug PHP update-alternatives --query php | jc -- update-alt-q + - name: Debug PHP update-alternatives --query php | jc --update-alt-q | jp value ansible.builtin.debug: - var: apache_php_update_alt_q + var: apache_php_update_alt_q.value verbosity: 3 + - name: Check if the default version of PHP is a symlink + ansible.builtin.stat: + path: "{{ apache_php_update_alt_q.value }}" + register: apache_php_update_alt_q_value_path + + - name: Debug PHP default version path + ansible.builtin.debug: + var: apache_php_update_alt_q_value_path.stat + verbosity: 3 + + - name: Set a fact for the default version of PHP when it is a symlink + ansible.builtin.set_fact: + apache_php_version: "{{ apache_php_update_alt_q_value_path.stat.lnk_target | regex_replace('^php') }}" + when: apache_php_update_alt_q_value_path.stat.islnk | bool + + - name: Set a fact for the default version of PHP when it is a not symlink + ansible.builtin.set_fact: + apache_php_version: "{{ apache_php_update_alt_q.value | regex_replace('^/usr/bin/php') }}" + when: not apache_php_update_alt_q_value_path.stat.islnk | bool + - name: A default PHP version is required ansible.builtin.assert: that: -- GitLab