From 9ce8e65b5adc25ec7bf34f8e995543adfd5fc969 Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Wed, 1 Apr 2020 20:27:21 +0100 Subject: [PATCH] fixes for when php isn't installed --- tasks/a2mod.yml | 4 ++-- tasks/checks.yml | 8 ++++++-- templates/localhost.conf.j2 | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tasks/a2mod.yml b/tasks/a2mod.yml index a297037..4193908 100644 --- a/tasks/a2mod.yml +++ b/tasks/a2mod.yml @@ -32,7 +32,7 @@ - "libapache2-mod-php{{ apache_php_version }}" state: absent update_cache: false - when: '"apache_phpfpm_mod" in apache_mods_disabled' + when: ( apache_php ) and ( "apache_phpfpm_mod" in apache_mods_disabled ) - name: Disable modules apache2_module: @@ -83,7 +83,7 @@ - "libapache2-mod-php{{ apache_php_version }}" state: present update_cache: false - when: '"apache_phpfpm_mod" in apache_mods_enabled' + when: ( apache_php ) and ( "apache_phpfpm_mod" in apache_mods_enabled ) - name: Apache modules enabled apache2_module: diff --git a/tasks/checks.yml b/tasks/checks.yml index f69736a..e84675c 100644 --- a/tasks/checks.yml +++ b/tasks/checks.yml @@ -180,11 +180,15 @@ when: apache_version is version('2.4.41', '>=') - name: Check if phpquery is installed - shell: which phpquery || echo absent + shell: which phpquery || echo ABSENT check_mode: false register: apache_phpquery_path changed_when: '"phpquery" not in apache_phpquery_path.stdout' + - name: Set the apache_php variable to true or false + set_fact: + apache_php: "{% if apache_phpquery_path.stdout == 'ABSENT' %}false{% else %}true{% endif %}" + - name: Check PHP version block: @@ -210,7 +214,7 @@ - "apache_phpfpm_conf: {{ apache_phpfpm_conf }}" verbosity: 2 - when: ( apache_phpquery_path is defined ) and ( apache_phpquery_path.stdout == "/usr/sbin/phpquery" ) + when: ( apache_php is defined ) and ( apache_php ) - name: Check loaded modules block: diff --git a/templates/localhost.conf.j2 b/templates/localhost.conf.j2 index 00a32cb..08484b2 100644 --- a/templates/localhost.conf.j2 +++ b/templates/localhost.conf.j2 @@ -21,7 +21,7 @@ </Location> </IfModule> {% endif %} -{% if "proxy_fcgi" in apache_mods_enabled %} +{% if apache_php and if "proxy_fcgi" in apache_mods_enabled %} <Location /status> SetHandler "proxy:unix:/run/php/php{{ apache_php_version }}-fpm.sock|fcgi://localhost/" Require host localhost 127.0.0.1 ::1 @@ -35,7 +35,7 @@ AllowOverride AuthConfig Indexes FileInfo Limit Require host localhost 127.0.0.1 ::1 {% if apache_mods_enabled is defined %} -{% if apache_phpfpm_mod is defined and apache_phpfpm_mod in apache_mods_enabled %} +{% if apache_php and if apache_phpfpm_mod is defined and apache_phpfpm_mod in apache_mods_enabled %} <IfModule php7_module> php_admin_value doc_root /var/www/localhost php_admin_value open_basedir /var/www/localhost/:/tmp/:/usr/share/php/ @@ -44,7 +44,7 @@ </FilesMatch> </IfModule> {% endif %} -{% if "proxy_fcgi" in apache_mods_enabled %} +{% if apache_php and if "proxy_fcgi" in apache_mods_enabled %} # https://wiki.apache.org/httpd/PHP-FPM#Proxy_via_handler <IfModule proxy_fcgi_module> <IfModule setenvif_module> -- GitLab