Skip to content

Commit 38098bc

Browse files
committed
[php/ng] support the use of a list of php versions
Related to #138
1 parent 4dc3e14 commit 38098bc

File tree

6 files changed

+83
-4
lines changed

6 files changed

+83
-4
lines changed

php/ng/fpm/config.sls

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@
1111
{% endif %}
1212
{% endfor %}
1313
14+
15+
{% if salt['pillar.get']('php:ng:version') is iterable %}
16+
{% for version in salt['pillar.get']('php:ng:version') %}
17+
{% set conf_settings = odict(php.lookup.fpm.defaults) %}
18+
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
19+
{% set ini = php.lookup.fpm.ini|replace(first_version, version) %}
20+
{% set conf = php.lookup.fpm.conf|replace(first_version, version) %}
21+
{% set pools = php.lookup.fpm.pools|replace(first_version, version) %}
22+
23+
{% for key, value in conf_settings.items() %}
24+
{% if value is string %}
25+
{% do conf_settings.update({key: value.replace(first_version, version)}) %}
26+
{% endif %}
27+
{% endfor %}
28+
{% do conf_settings.global.update({'pid': '/var/run/php' + version + '-fpm.pid' }) %}
29+
{% do conf_settings.global.update({'error_log': '/var/log/php' + version + '-fpm.log' }) %}
30+
31+
php_fpm_ini_config_{{ version }}:
32+
{{ php_ini(ini, php.fpm.config.ini.opts, ini_settings) }}
33+
34+
php_fpm_conf_config_{{ version }}:
35+
{{ php_ini(conf, php.fpm.config.conf.opts, odict(conf_settings)) }}
36+
37+
{{ pools }}:
38+
file.directory:
39+
- name: {{ pools }}
40+
- user: {{ php.lookup.fpm.user }}
41+
- group: {{ php.lookup.fpm.group }}
42+
- file_mode: 755
43+
- make_dirs: True
44+
{% endfor %}
45+
{% else %}
46+
1447
{% set conf_settings = php.lookup.fpm.defaults %}
1548
{% do conf_settings.update(php.fpm.config.conf.settings) %}
1649
@@ -27,3 +60,4 @@ php_fpm_conf_config:
2760
- group: {{ php.lookup.fpm.group }}
2861
- file_mode: 755
2962
- make_dirs: True
63+
{% endif %}

php/ng/fpm/init.sls

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,29 @@ extend:
99
php_fpm_service:
1010
service:
1111
- watch:
12+
{% if salt['pillar.get']('php:ng:version') is iterable %}
13+
{% for version in salt['pillar.get']('php:ng:version') %}
14+
- file: php_fpm_ini_config_{{ version }}
15+
- file: php_fpm_conf_config_{{ version }}
16+
{% endfor %}
17+
{% else %}
1218
- file: php_fpm_ini_config
1319
- file: php_fpm_conf_config
20+
{% endif %}
1421
- require:
1522
- sls: php.ng.fpm.config
23+
{% if salt['pillar.get']('php:ng:version') is iterable %}
24+
{% for version in salt['pillar.get']('php:ng:version') %}
25+
php_fpm_ini_config_{{ version }}:
26+
file:
27+
- require:
28+
- pkg: php_install_fpm
29+
php_fpm_conf_config_{{ version }}:
30+
file:
31+
- require:
32+
- pkg: php_install_fpm
33+
{% endfor %}
34+
{% else %}
1635
php_fpm_ini_config:
1736
file:
1837
- require:
@@ -21,3 +40,4 @@ extend:
2140
file:
2241
- require:
2342
- pkg: php_install_fpm
43+
{% endif %}

php/ng/fpm/pools_config.sls

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
{% do pvalues.update(pool_defaults) %}
1818
{% endfor %}
1919
{% set state = 'php_fpm_pool_conf_' ~ loop.index0 %}
20-
{% set fpath = path_join(config.get('filename', pool), php.lookup.fpm.pools) %}
20+
21+
{% if salt['pillar.get']('php:ng:version') is iterable %}
22+
{% set first_fpath = path_join(config.get('filename', pool), php.lookup.fpm.pools) %}
23+
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
24+
{% set fpath = first_fpath.replace(first_version, config.get('phpversion', '7.0')) %}
25+
{% else %}
26+
{% set fpath = path_join(config.get('filename', pool), php.lookup.fpm.pools) %}
27+
{% endif %}
2128
2229
{{ state }}:
2330
{% if config.enabled %}

php/ng/ini.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
- source: salt://php/ng/files/php.ini
1111
- template: jinja
1212
- context:
13-
config: {{ serialize(settings) }}
13+
config: {{ serialize(odict(settings)) }}
1414
{%- endmacro -%}

php/ng/installed.jinja

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,24 @@
1616
{% do specials.append(pkg) %}
1717
{% else %}
1818
{% do pkgs.append(pkg) %}
19+
{% if salt['pillar.get']('php:ng:version') is iterable %}
20+
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
21+
{% for other_version in salt['pillar.get']('php:ng:version') %}
22+
{% set other_version_str = other_version|string %}
23+
{% do pkgs.append(pkg.replace(first_version, other_version_str)) %}
24+
{% endfor %}
25+
{% endif %}
1926
{% endif %}
2027
{% endfor %}
2128
{% else %}
2229
{% do pkgs.append(pkginfo) %}
30+
{% if salt['pillar.get']('php:ng:version') is iterable %}
31+
{% set first_version = salt['pillar.get']('php:ng:version')[0]|string %}
32+
{% for other_version in salt['pillar.get']('php:ng:version') %}
33+
{% set other_version_str = other_version|string %}
34+
{% do pkgs.append(pkginfo.replace(first_version, other_version_str)) %}
35+
{% endfor %}
36+
{% endif %}
2337
{% endif %}
2438

2539
{% if grains['os_family'] == "Debian" and (state == 'cli' or state == 'fpm' or state == 'php') %}
@@ -60,7 +74,7 @@ php_ppa_{{ state }}:
6074
- __env__:
6175
- LC_ALL: C.UTF-8
6276
- onlyif:
63-
- test ! -e /etc/apt/sources.list.d/ondrej-php.list
77+
- test ! -e /etc/apt/sources.list.d/ondrej-php.list
6478
- require_in:
6579
- pkg: php_install_{{ state }}
6680
pkg.latest:

php/ng/map.jinja

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %}
4+
{%- if salt['pillar.get']('php:ng:version') is iterable %}
5+
{%- set phpng_version = salt['pillar.get']('php:ng:version')[0]|string %}
6+
{% else %}
7+
{%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %}
8+
{% endif %}
59
{%- set freebsd_phpng_version = phpng_version.replace('.', '') %}
610

711
{%- if salt['grains.get']('os') == "Ubuntu" %}

0 commit comments

Comments
 (0)