Skip to content

Commit 10b7519

Browse files
Wayne Gemmellwaynegemmell
authored andcommitted
Added osfamilymap, osmap and other defaults
1 parent 9c69a4e commit 10b7519

File tree

3 files changed

+68
-22
lines changed

3 files changed

+68
-22
lines changed

php/fpm/config.sls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
{%- from tplroot ~ "/map.jinja" import php with context %}
44
{%- from tplroot ~ "/ini.jinja" import php_ini %}
55
6+
{%- do salt.log.debug('[php.fpm.config] php var is set as: ' ~ php) %}
7+
68
{%- set ini_settings = php.ini.defaults %}
79
{%- for key, value in php.fpm.config.ini.settings.items() %}
810
{%- if ini_settings[key] is defined %}
@@ -12,7 +14,7 @@
1214
{%- endif %}
1315
{%- endfor %}
1416
15-
{%- set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
17+
{%- set pillar_php_version = php.pillar_php_version %}
1618
{%- if pillar_php_version is iterable and pillar_php_version is not string %}
1719
{%- for version in pillar_php_version %}
1820
{%- set conf_settings = odict(php.lookup.fpm.defaults) %}

php/fpm/init.sls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ include:
55
- php.fpm.service
66
- php.fpm.pools
77

8-
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
9-
108
extend:
119
{% if pillar_php_version is iterable and pillar_php_version is not string %}
1210
{% for version in pillar_php_version %}

php/map.jinja

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
3+
{%- set tplroot = tpldir.split('/')[0] %}
4+
{#- Start imports as #}
5+
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
6+
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
7+
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
8+
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
9+
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
310

4-
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
5-
{%- if pillar_php_version is iterable and pillar_php_version is not string %}
6-
{%- set php_version = pillar_php_version[0]|string %}
11+
{#- Retrieve the config dict only once #}
12+
{%- set _config = salt['config.get'](tplroot, default={}) %}
13+
14+
{%- set defaults = salt['grains.filter_by'](
15+
default_settings,
16+
default=tplroot,
17+
merge=salt['grains.filter_by'](
18+
osarchmap,
19+
grain='osarch',
20+
merge=salt['grains.filter_by'](
21+
osfamilymap,
22+
grain='os_family',
23+
merge=salt['grains.filter_by'](
24+
osmap,
25+
grain='os',
26+
merge=salt['grains.filter_by'](
27+
osfingermap,
28+
grain='osfinger',
29+
merge=salt['grains.filter_by'](
30+
_config,
31+
default='php'
32+
)
33+
)
34+
)
35+
)
36+
)
37+
)
38+
%}
39+
40+
{%- set config = salt['grains.filter_by'](
41+
{'defaults': defaults},
42+
default='defaults',
43+
merge=_config
44+
)
45+
%}
46+
47+
{% set php = config %}
48+
49+
{%- do salt.log.debug('[map.jinja] php var is set as: ' ~ php) %}
50+
51+
{%- if php['pillar_php_version'] is iterable and php['pillar_php_version'] is not string %}
52+
{%- set php_version = php['pillar_php_version'][0]|string %}
753
{% else %}
8-
{%- set php_version = pillar_php_version|string %}
54+
{%- set php_version = php['pillar_php_version']|string %}
955
{% endif %}
1056
{%- set freebsd_php_version = php_version.replace('.', '') %}
1157

@@ -722,24 +768,24 @@
722768
{%- endif %}
723769
{%- else %}
724770
{%- if salt['grains.get']('osrelease')|string >= '18.04' %}
725-
{%- set php = salt['pillar.get']('php', {
771+
{%- merge = php, salt['pillar.get']('php', {
726772
'lookup': salt['grains.filter_by']({
727773
'Ubuntu': {
728774
'pkgs': {
729775
'adodb': 'libphp-adodb',
730776
'apache2': 'libapache2-mod-php',
731777
'apc': 'php',
732778
'apcu': 'php-apcu',
733-
'bcmath': 'php7.2-bcmath',
734-
'bz2': 'php7.2-bz2',
779+
'bcmath': 'php' + php_version + '-bcmath',
780+
'bz2': 'php' + php_version + '-bz2',
735781
'cache-lite': 'php-cache-lite',
736782
'cgi': 'php-cgi',
737783
'cli': 'php-cli',
738784
'console-table': 'php-console-table',
739785
'composer_bin': 'composer',
740786
'curl': 'php-curl',
741-
'dev': 'php7.2-dev',
742-
'dba': 'php7.2-dba',
787+
'dev': 'php' + php_version + '-dev',
788+
'dba': 'php' + php_version + '-dba',
743789
'fpm': 'php-fpm',
744790
'gd': 'php-gd',
745791
'geoip': 'php-geoip',
@@ -766,7 +812,7 @@
766812
'net6': 'php-net-ipv6',
767813
'oauth': 'php-oauth',
768814
'odbc': 'php-odbc',
769-
'opcache': 'php7.2-opcache',
815+
'opcache': 'php' + php_version + '-opcache',
770816
'pear': 'php-pear',
771817
'pgsql': 'php-pgsql',
772818
'php': 'php',
@@ -782,26 +828,26 @@
782828
'sybase': 'php-sybase',
783829
'tcpdf': 'php-tcpdf',
784830
'temp_dir': '/tmp',
785-
'tidy': 'php7.2-tidy',
831+
'tidy': 'php' + php_version + '-tidy',
786832
'xcache': 'php',
787833
'xdebug': 'php-xdebug',
788834
'xml': ['php-xml', 'php-xmlrpc'],
789-
'xsl': 'php7.2-xsl',
835+
'xsl': 'php' + php_version + '-xsl',
790836
'zip': 'php-zip',
791837
},
792838
'fpm': {
793-
'conf': '/etc/php/7.2/fpm/php-fpm.conf',
794-
'ini': '/etc/php/7.2/fpm/php.ini',
795-
'pools': '/etc/php/7.2/fpm/pool.d',
796-
'service': 'php7.2-fpm',
839+
'conf': '/etc/php/' + php_version + '/fpm/php-fpm.conf',
840+
'ini': '/etc/php/' + php_version + '/fpm/php.ini',
841+
'pools': '/etc/php/' + php_version + '/fpm/pool.d',
842+
'service': 'php' + php_version + '-fpm',
797843
'user': 'root',
798844
'group': 'root',
799845
'defaults': odict([
800846
('global', odict([
801-
('pid', '/var/run/php7.2-fpm.pid'),
802-
('error_log', '/var/log/php7.2-fpm.log'),
847+
('pid', '/var/run/php' + php_version + '-fpm.pid'),
848+
('error_log', '/var/log/php' + php_version + '-fpm.log'),
803849
])),
804-
('include', '/etc/php/7.2/fpm/pool.d/*.conf'),
850+
('include', '/etc/php/' + php_version + '/fpm/pool.d/*.conf'),
805851
]),
806852
},
807853
'hhvm': {

0 commit comments

Comments
 (0)