From d4772f92fa7629235672f36508fea748fffb914e Mon Sep 17 00:00:00 2001 From: Nicolas Rodriguez Date: Wed, 4 Sep 2019 01:08:56 +0200 Subject: [PATCH] fix(fpm): be sure to restart all Php instances in case of multi-versions --- php/fpm/init.sls | 36 +++++++++++++++++++++++------------- php/fpm/pools.sls | 19 +++++++++++++++++++ php/fpm/service.sls | 20 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/php/fpm/init.sls b/php/fpm/init.sls index e7b56ce..85b38fa 100644 --- a/php/fpm/init.sls +++ b/php/fpm/init.sls @@ -6,39 +6,49 @@ include: - php.fpm.pools {% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} + extend: - php_fpm_service: +{% if pillar_php_version is iterable and pillar_php_version is not string %} + {% for version in pillar_php_version %} + + php_fpm_service_{{ version }}: service: - watch: - {% if pillar_php_version is iterable and pillar_php_version is not string %} - {% for version in pillar_php_version %} - file: php_fpm_ini_config_{{ version }} - file: php_fpm_conf_config_{{ version }} - {% endfor %} - {% else %} - - file: php_fpm_ini_config - - file: php_fpm_conf_config - {% endif %} - require: - sls: php.fpm.config - {% if pillar_php_version is iterable and pillar_php_version is not string %} - {% for version in pillar_php_version %} + php_fpm_ini_config_{{ version }}: file: - require: - pkg: php_install_fpm + php_fpm_conf_config_{{ version }}: file: - require: - pkg: php_install_fpm - {% endfor %} - {% else %} + + {% endfor %} + +{% else %} + + php_fpm_service: + service: + - watch: + - file: php_fpm_ini_config + - file: php_fpm_conf_config + - require: + - sls: php.fpm.config + php_fpm_ini_config: file: - require: - pkg: php_install_fpm + php_fpm_conf_config: file: - require: - pkg: php_install_fpm - {% endif %} + +{% endif %} diff --git a/php/fpm/pools.sls b/php/fpm/pools.sls index ff03e88..01e8202 100644 --- a/php/fpm/pools.sls +++ b/php/fpm/pools.sls @@ -8,12 +8,31 @@ include: - php.fpm.service - php.fpm.pools_config +{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} + {% if pool_states %} extend: + +{% if pillar_php_version is iterable and pillar_php_version is not string %} + {% for version in pillar_php_version %} + php_fpm_service_{{ version }}: + service: + - watch: +{{ file_requisites(pool_states) }} + - require: +{{ file_requisites(pool_states) }} + + {% endfor %} + +{% else %} + php_fpm_service: service: - watch: {{ file_requisites(pool_states) }} - require: {{ file_requisites(pool_states) }} + +{% endif %} + {% endif %} diff --git a/php/fpm/service.sls b/php/fpm/service.sls index bed2ff2..1eb2f66 100644 --- a/php/fpm/service.sls +++ b/php/fpm/service.sls @@ -3,10 +3,28 @@ {% from "php/macro.jinja" import sls_block %} {% set service_function = {True:'running', False:'dead'}.get(php.fpm.service.enabled) %} +{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} include: - php.fpm.install +{% if pillar_php_version is iterable and pillar_php_version is not string %} + {% for version in pillar_php_version %} + +php_fpm_service_{{ version }}: + service.{{ service_function }}: + {{ sls_block(php.fpm.service.opts) }} + - name: {{ 'php' ~ version ~ '-fpm' }} + - enable: {{ php.fpm.service.enabled }} + - require: + - sls: php.fpm.install + - watch: + - pkg: php_install_fpm + + {% endfor %} + +{% else %} + php_fpm_service: service.{{ service_function }}: {{ sls_block(php.fpm.service.opts) }} @@ -16,3 +34,5 @@ php_fpm_service: - sls: php.fpm.install - watch: - pkg: php_install_fpm + +{% endif %}