From 10b7519a399072c4ef49ced2644f2c9933d09e0d Mon Sep 17 00:00:00 2001 From: Wayne Gemmell Date: Mon, 8 Jun 2020 21:46:12 +0200 Subject: [PATCH 1/5] Added osfamilymap, osmap and other defaults --- php/fpm/config.sls | 4 ++- php/fpm/init.sls | 2 -- php/map.jinja | 84 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/php/fpm/config.sls b/php/fpm/config.sls index e7574eaa..bfede2f3 100644 --- a/php/fpm/config.sls +++ b/php/fpm/config.sls @@ -3,6 +3,8 @@ {%- from tplroot ~ "/map.jinja" import php with context %} {%- from tplroot ~ "/ini.jinja" import php_ini %} +{%- do salt.log.debug('[php.fpm.config] php var is set as: ' ~ php) %} + {%- set ini_settings = php.ini.defaults %} {%- for key, value in php.fpm.config.ini.settings.items() %} {%- if ini_settings[key] is defined %} @@ -12,7 +14,7 @@ {%- endif %} {%- endfor %} -{%- set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} +{%- set pillar_php_version = php.pillar_php_version %} {%- if pillar_php_version is iterable and pillar_php_version is not string %} {%- for version in pillar_php_version %} {%- set conf_settings = odict(php.lookup.fpm.defaults) %} diff --git a/php/fpm/init.sls b/php/fpm/init.sls index 85b38fad..2572a8ee 100644 --- a/php/fpm/init.sls +++ b/php/fpm/init.sls @@ -5,8 +5,6 @@ include: - php.fpm.service - php.fpm.pools -{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} - extend: {% if pillar_php_version is iterable and pillar_php_version is not string %} {% for version in pillar_php_version %} diff --git a/php/map.jinja b/php/map.jinja index 6915fce9..e171bffb 100644 --- a/php/map.jinja +++ b/php/map.jinja @@ -1,11 +1,57 @@ # -*- coding: utf-8 -*- # vim: ft=jinja +{%- set tplroot = tpldir.split('/')[0] %} +{#- Start imports as #} +{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} +{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} +{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} +{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %} +{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} -{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} -{%- if pillar_php_version is iterable and pillar_php_version is not string %} - {%- set php_version = pillar_php_version[0]|string %} +{#- Retrieve the config dict only once #} +{%- set _config = salt['config.get'](tplroot, default={}) %} + +{%- set defaults = salt['grains.filter_by']( + default_settings, + default=tplroot, + merge=salt['grains.filter_by']( + osarchmap, + grain='osarch', + merge=salt['grains.filter_by']( + osfamilymap, + grain='os_family', + merge=salt['grains.filter_by']( + osmap, + grain='os', + merge=salt['grains.filter_by']( + osfingermap, + grain='osfinger', + merge=salt['grains.filter_by']( + _config, + default='php' + ) + ) + ) + ) + ) + ) +%} + +{%- set config = salt['grains.filter_by']( + {'defaults': defaults}, + default='defaults', + merge=_config + ) +%} + +{% set php = config %} + +{%- do salt.log.debug('[map.jinja] php var is set as: ' ~ php) %} + +{%- if php['pillar_php_version'] is iterable and php['pillar_php_version'] is not string %} + {%- set php_version = php['pillar_php_version'][0]|string %} {% else %} - {%- set php_version = pillar_php_version|string %} + {%- set php_version = php['pillar_php_version']|string %} {% endif %} {%- set freebsd_php_version = php_version.replace('.', '') %} @@ -722,7 +768,7 @@ {%- endif %} {%- else %} {%- if salt['grains.get']('osrelease')|string >= '18.04' %} - {%- set php = salt['pillar.get']('php', { + {%- merge = php, salt['pillar.get']('php', { 'lookup': salt['grains.filter_by']({ 'Ubuntu': { 'pkgs': { @@ -730,16 +776,16 @@ 'apache2': 'libapache2-mod-php', 'apc': 'php', 'apcu': 'php-apcu', - 'bcmath': 'php7.2-bcmath', - 'bz2': 'php7.2-bz2', + 'bcmath': 'php' + php_version + '-bcmath', + 'bz2': 'php' + php_version + '-bz2', 'cache-lite': 'php-cache-lite', 'cgi': 'php-cgi', 'cli': 'php-cli', 'console-table': 'php-console-table', 'composer_bin': 'composer', 'curl': 'php-curl', - 'dev': 'php7.2-dev', - 'dba': 'php7.2-dba', + 'dev': 'php' + php_version + '-dev', + 'dba': 'php' + php_version + '-dba', 'fpm': 'php-fpm', 'gd': 'php-gd', 'geoip': 'php-geoip', @@ -766,7 +812,7 @@ 'net6': 'php-net-ipv6', 'oauth': 'php-oauth', 'odbc': 'php-odbc', - 'opcache': 'php7.2-opcache', + 'opcache': 'php' + php_version + '-opcache', 'pear': 'php-pear', 'pgsql': 'php-pgsql', 'php': 'php', @@ -782,26 +828,26 @@ 'sybase': 'php-sybase', 'tcpdf': 'php-tcpdf', 'temp_dir': '/tmp', - 'tidy': 'php7.2-tidy', + 'tidy': 'php' + php_version + '-tidy', 'xcache': 'php', 'xdebug': 'php-xdebug', 'xml': ['php-xml', 'php-xmlrpc'], - 'xsl': 'php7.2-xsl', + 'xsl': 'php' + php_version + '-xsl', 'zip': 'php-zip', }, 'fpm': { - 'conf': '/etc/php/7.2/fpm/php-fpm.conf', - 'ini': '/etc/php/7.2/fpm/php.ini', - 'pools': '/etc/php/7.2/fpm/pool.d', - 'service': 'php7.2-fpm', + 'conf': '/etc/php/' + php_version + '/fpm/php-fpm.conf', + 'ini': '/etc/php/' + php_version + '/fpm/php.ini', + 'pools': '/etc/php/' + php_version + '/fpm/pool.d', + 'service': 'php' + php_version + '-fpm', 'user': 'root', 'group': 'root', 'defaults': odict([ ('global', odict([ - ('pid', '/var/run/php7.2-fpm.pid'), - ('error_log', '/var/log/php7.2-fpm.log'), + ('pid', '/var/run/php' + php_version + '-fpm.pid'), + ('error_log', '/var/log/php' + php_version + '-fpm.log'), ])), - ('include', '/etc/php/7.2/fpm/pool.d/*.conf'), + ('include', '/etc/php/' + php_version + '/fpm/pool.d/*.conf'), ]), }, 'hhvm': { From 859e598f682c44532e56ece267511efe192deed9 Mon Sep 17 00:00:00 2001 From: Wayne Gemmell Date: Mon, 8 Jun 2020 21:46:27 +0200 Subject: [PATCH 2/5] Added osfamilymap, osmap and other defaults --- php/defaults.yaml | 5 +++++ php/osarchmap.yaml | 35 ++++++++++++++++++++++++++++++++ php/osfamilymap.yaml | 32 +++++++++++++++++++++++++++++ php/osfingermap.yaml | 48 ++++++++++++++++++++++++++++++++++++++++++++ php/osmap.yaml | 33 ++++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 php/defaults.yaml create mode 100644 php/osarchmap.yaml create mode 100644 php/osfamilymap.yaml create mode 100644 php/osfingermap.yaml create mode 100644 php/osmap.yaml diff --git a/php/defaults.yaml b/php/defaults.yaml new file mode 100644 index 00000000..769fb224 --- /dev/null +++ b/php/defaults.yaml @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +php: + pillar_php_version: "7.0" diff --git a/php/osarchmap.yaml b/php/osarchmap.yaml new file mode 100644 index 00000000..ab3bc1f4 --- /dev/null +++ b/php/osarchmap.yaml @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['osarch'] based logic. +# You just need to add the key:values for an `osarch` that differ +# from `defaults.yaml`. +# Only add an `osarch` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `osarch` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osarch: {} +--- +amd64: + arch: amd64 + +x86_64: + arch: amd64 + +386: + arch: 386 + +arm64: + arch: arm64 + +armv6l: + arch: armv6l + +armv7l: + arch: armv7l + +ppc64le: + arch: ppc64le + +s390x: + arch: s390x diff --git a/php/osfamilymap.yaml b/php/osfamilymap.yaml new file mode 100644 index 00000000..2a721717 --- /dev/null +++ b/php/osfamilymap.yaml @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['os_family'] based logic. +# You just need to add the key:values for an `os_family` that differ +# from `defaults.yaml` + `osarch.yaml`. +# Only add an `os_family` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os_family` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osfamilymap: {} +--- +Debian: {} + +RedHat: {} + +Suse: {} + +Gentoo: {} + +Arch: {} +Alpine: {} + +FreeBSD: {} + +OpenBSD: {} + +Solaris: {} + +Windows: {} + +MacOS: {} diff --git a/php/osfingermap.yaml b/php/osfingermap.yaml new file mode 100644 index 00000000..a3d16385 --- /dev/null +++ b/php/osfingermap.yaml @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['osfinger'] based logic. +# You just need to add the key:values for an `osfinger` that differ +# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`. +# Only add an `osfinger` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os_finger` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osfingermap: {} +--- +# os: Debian +Debian-10: {} +Debian-9: {} +Debian-8: {} + +# os: Ubuntu +Ubuntu-20.04: + pillar_php_version: "7.4" +Ubuntu-19.10: + pillar_php_version: "7.3" +Ubuntu-18.04: + pillar_php_version: "7.2" + +# os: Fedora +Fedora-31: {} +Fedora-30: {} + +# os: CentOS +CentOS Linux-8: {} +CentOS Linux-7: {} + +# os: Amazon +Amazon Linux-2: {} +Amazon Linux AMI-2018: {} + +# os: SUSE +Leap-15: {} + +# os: FreeBSD +FreeBSD-12: {} + +# os: Windows +Windows-8.1: {} + +# os: Gentoo +Gentoo-2: {} diff --git a/php/osmap.yaml b/php/osmap.yaml new file mode 100644 index 00000000..de11a673 --- /dev/null +++ b/php/osmap.yaml @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +# +# Setup variables using grains['os'] based logic. +# You just need to add the key:values for an `os` that differ +# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`. +# Only add an `os` which is/will be supported by the formula. +# +# If you do not need to provide defaults via the `os` grain, +# you will need to provide at least an empty dict in this file, e.g. +# osmap: {} +--- +# os_family: Debian +Ubuntu: {} +Raspbian: {} + +# os_family: RedHat +Fedora: {} +CentOS: {} +Amazon: {} + +# os_family: Suse +SUSE: {} +openSUSE: {} + +# os_family: Gentoo +Funtoo: {} + +# os_family: Arch +Manjaro: {} + +# os_family: Solaris +SmartOS: {} From b22d2232ba00f19d6cb5bd08e56aafe0470abe00 Mon Sep 17 00:00:00 2001 From: Wayne Gemmell Date: Mon, 8 Jun 2020 22:17:08 +0200 Subject: [PATCH 3/5] Installs packages in focal. --- php/fpm/config.sls | 2 +- php/fpm/init.sls | 2 ++ php/map.jinja | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/php/fpm/config.sls b/php/fpm/config.sls index bfede2f3..5ae9c64c 100644 --- a/php/fpm/config.sls +++ b/php/fpm/config.sls @@ -14,7 +14,7 @@ {%- endif %} {%- endfor %} -{%- set pillar_php_version = php.pillar_php_version %} +{%- set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} {%- if pillar_php_version is iterable and pillar_php_version is not string %} {%- for version in pillar_php_version %} {%- set conf_settings = odict(php.lookup.fpm.defaults) %} diff --git a/php/fpm/init.sls b/php/fpm/init.sls index 2572a8ee..94bdefba 100644 --- a/php/fpm/init.sls +++ b/php/fpm/init.sls @@ -6,6 +6,8 @@ include: - php.fpm.pools extend: +{%- set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} + {% if pillar_php_version is iterable and pillar_php_version is not string %} {% for version in pillar_php_version %} diff --git a/php/map.jinja b/php/map.jinja index e171bffb..3f8fecb6 100644 --- a/php/map.jinja +++ b/php/map.jinja @@ -768,7 +768,7 @@ {%- endif %} {%- else %} {%- if salt['grains.get']('osrelease')|string >= '18.04' %} - {%- merge = php, salt['pillar.get']('php', { + {%- set php = salt['pillar.get']('php', { 'lookup': salt['grains.filter_by']({ 'Ubuntu': { 'pkgs': { From c24d65e2a68f83f688c39a46fe4ded4da277d1ec Mon Sep 17 00:00:00 2001 From: Wayne Gemmell Date: Wed, 22 Mar 2023 10:08:52 +0200 Subject: [PATCH 4/5] Jammy default version set to 8.1 --- php/osfingermap.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/php/osfingermap.yaml b/php/osfingermap.yaml index a3d16385..058805de 100644 --- a/php/osfingermap.yaml +++ b/php/osfingermap.yaml @@ -16,6 +16,8 @@ Debian-9: {} Debian-8: {} # os: Ubuntu +Ubuntu-22.04: + pillar_php_version: "8.1" Ubuntu-20.04: pillar_php_version: "7.4" Ubuntu-19.10: From 3372fabfa4d360d4c31aa141605b0063a646c4bb Mon Sep 17 00:00:00 2001 From: Thomas Thorburn Date: Mon, 10 Jun 2024 14:01:51 +0200 Subject: [PATCH 5/5] make map.jinja use the php_version variable everywhere --- php/map.jinja | 74 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/php/map.jinja b/php/map.jinja index 3f8fecb6..4bf16ba5 100644 --- a/php/map.jinja +++ b/php/map.jinja @@ -875,13 +875,13 @@ ]), }, 'cli': { - 'ini': '/etc/php/7.2/cli/php.ini', + 'ini': '/etc/php/' + php_version + '/cli/php.ini', }, 'apache2': { - 'ini': '/etc/php/7.2/apache2/php.ini', + 'ini': '/etc/php/' + php_version + '/apache2/php.ini', }, 'xcache': { - 'ini': '/etc/php/7.2/mods-available/xcache.ini', + 'ini': '/etc/php/' + php_version + '/mods-available/xcache.ini', 'defaults': {}, }, }, @@ -1170,16 +1170,16 @@ 'apache2': 'libapache2-mod-php', 'apc': 'php', 'apcu': 'php-apcu', - 'bcmath': 'php7.1-bcmath', - 'bz2': 'php7.1-bz2', + 'bcmath': 'php' + php_version + '-bcmath', + 'bz2': 'php' + php_version + '-bz2', 'cache-lite': 'php-cache-lite', 'cgi': 'php-cgi', 'cli': 'php-cli', 'console-table': 'php-console-table', 'composer_bin': 'composer', 'curl': 'php-curl', - 'dba': 'php7.1-dba', - 'dev': 'php7.1-dev', + 'dba': 'php' + php_version + '-dba', + 'dev': 'php' + php_version + '-dev', 'fpm': 'php-fpm', 'gd': 'php-gd', 'geoip': 'php-geoip', @@ -1205,7 +1205,7 @@ 'net4': 'php-net-ipv4', 'net6': 'php-net-ipv6', 'oauth': 'php-oauth', - 'opcache': 'php7.1-opcache', + 'opcache': 'php' + php_version + '-opcache', 'pear': 'php-pear', 'pgsql': 'php-pgsql', 'php': 'php', @@ -1221,26 +1221,26 @@ 'sybase': 'php-sybase', 'tcpdf': 'php-tcpdf', 'temp_dir': '/tmp', - 'tidy': 'php7.1-tidy', + 'tidy': 'php' + php_version + '-tidy', 'xcache': 'php', 'xdebug': 'php-xdebug', 'xml': ['php-xml', 'php-xmlrpc'], - 'xsl': 'php7.1-xsl', + 'xsl': 'php' + php_version + '-xsl', 'zip': 'php-zip', }, 'fpm': { - 'conf': '/etc/php/7.1/fpm/php-fpm.conf', - 'ini': '/etc/php/7.1/fpm/php.ini', - 'pools': '/etc/php/7.1/fpm/pool.d', - 'service': 'php7.1-fpm', + 'conf': '/etc/php/' + php_version + '/fpm/php-fpm.conf', + 'ini': '/etc/php/' + php_version + '/fpm/php.ini', + 'pools': '/etc/php/' + php_version + '/fpm/pool.d', + 'service': 'php' + php_version + '-fpm', 'user': 'root', 'group': 'root', 'defaults': odict([ ('global', odict([ - ('pid', '/var/run/php7.1-fpm.pid'), - ('error_log', '/var/log/php7.1-fpm.log'), + ('pid', '/var/run/php' + php_version + '-fpm.pid'), + ('error_log', '/var/log/php' + php_version + '-fpm.log'), ])), - ('include', '/etc/php/7.1/fpm/pool.d/*.conf'), + ('include', '/etc/php/' + php_version + '/fpm/pool.d/*.conf'), ]), }, 'hhvm': { @@ -1268,13 +1268,13 @@ ]), }, 'cli': { - 'ini': '/etc/php/7.1/cli/php.ini', + 'ini': '/etc/php/' + php_version + '/cli/php.ini', }, 'apache2': { - 'ini': '/etc/php/7.1/apache2/php.ini', + 'ini': '/etc/php/' + php_version + '/apache2/php.ini', }, 'xcache': { - 'ini': '/etc/php/7.1/mods-available/xcache.ini', + 'ini': '/etc/php/' + php_version + '/mods-available/xcache.ini', 'defaults': {}, }, }, @@ -1563,16 +1563,16 @@ 'apache2': 'libapache2-mod-php', 'apc': 'php', 'apcu': 'php-apcu', - 'bcmath': 'php7.0-bcmath', - 'bz2': 'php7.0-bz2', + 'bcmath': 'php' + php_version + '-bcmath', + 'bz2': 'php' + php_version + '-bz2', 'cache-lite': 'php-cache-lite', 'cgi': 'php-cgi', 'cli': 'php-cli', 'console-table': 'php-console-table', 'composer_bin': 'composer', 'curl': 'php-curl', - 'dba': 'php7.0-dba', - 'dev': 'php7.0-dev', + 'dba': 'php' + php_version + '-dba', + 'dev': 'php' + php_version + '-dev', 'fpm': 'php-fpm', 'gd': 'php-gd', 'geoip': 'php-geoip', @@ -1598,7 +1598,7 @@ 'net4': 'php-net-ipv4', 'net6': 'php-net-ipv6', 'oauth': 'php-oauth', - 'opcache': 'php7.0-opcache', + 'opcache': 'php' + php_version + '-opcache', 'pear': 'php-pear', 'pgsql': 'php-pgsql', 'php': 'php', @@ -1614,26 +1614,26 @@ 'sybase': 'php-sybase', 'tcpdf': 'php-tcpdf', 'temp_dir': '/tmp', - 'tidy': 'php7.0-tidy', + 'tidy': 'php' + php_version + '-tidy', 'xcache': 'php', 'xdebug': 'php-xdebug', 'xml': ['php-xml', 'php-xmlrpc'], - 'xsl': 'php7.0-xsl', + 'xsl': 'php' + php_version + '-xsl', 'zip': 'php-zip', }, 'fpm': { - 'conf': '/etc/php/7.0/fpm/php-fpm.conf', - 'ini': '/etc/php/7.0/fpm/php.ini', - 'pools': '/etc/php/7.0/fpm/pool.d', - 'service': 'php7.0-fpm', + 'conf': '/etc/php/' + php_version + '/fpm/php-fpm.conf', + 'ini': '/etc/php/' + php_version + '/fpm/php.ini', + 'pools': '/etc/php/' + php_version + '/fpm/pool.d', + 'service': 'php' + php_version + '-fpm', 'user': 'root', 'group': 'root', 'defaults': odict([ ('global', odict([ - ('pid', '/var/run/php7.0-fpm.pid'), - ('error_log', '/var/log/php7.0-fpm.log'), + ('pid', '/var/run/php' + php_version + '-fpm.pid'), + ('error_log', '/var/log/php' + php_version + '-fpm.log'), ])), - ('include', '/etc/php/7.0/fpm/pool.d/*.conf'), + ('include', '/etc/php/' + php_version + '/fpm/pool.d/*.conf'), ]), }, 'hhvm': { @@ -1661,13 +1661,13 @@ ]), }, 'cli': { - 'ini': '/etc/php/7.0/cli/php.ini', + 'ini': '/etc/php/' + php_version + '/cli/php.ini', }, 'apache2': { - 'ini': '/etc/php/7.0/apache2/php.ini', + 'ini': '/etc/php/' + php_version + '/apache2/php.ini', }, 'xcache': { - 'ini': '/etc/php/7.0/mods-available/xcache.ini', + 'ini': '/etc/php/' + php_version + '/mods-available/xcache.ini', 'defaults': {}, }, },