=========== | |||||
php-formula | |||||
=========== | |||||
0.2.0 | |||||
----- | |||||
- Added .ng states | |||||
0.1.0 | |||||
----- | |||||
- Initial version |
Installs the php-apc package. | Installs the php-apc package. | ||||
``php.adodb`` | ``php.adodb`` | ||||
------------ | |||||
------------- | |||||
Installs the php-adodb package. | Installs the php-adodb package. | ||||
``php.cgi`` | ``php.cgi`` | ||||
------------ | |||||
----------- | |||||
Installs the php-cgi package. | Installs the php-cgi package. | ||||
``php.cli`` | ``php.cli`` | ||||
------------ | |||||
----------- | |||||
Installs the php-cli package. | Installs the php-cli package. | ||||
``php.imagick`` | ``php.imagick`` | ||||
------------ | |||||
--------------- | |||||
Installs the php-imagick package. | Installs the php-imagick package. | ||||
Installs the php-ldap package. | Installs the php-ldap package. | ||||
``php.mbstring`` | ``php.mbstring`` | ||||
--------------- | |||||
---------------- | |||||
Installs the php-mbstring package. | Installs the php-mbstring package. | ||||
``php.memcache`` | ``php.memcache`` | ||||
------------ | |||||
---------------- | |||||
Installs the php-memcache package. | Installs the php-memcache package. | ||||
``php.memcached`` | ``php.memcached`` | ||||
------------ | |||||
----------------- | |||||
Installs the php-memcached package. | Installs the php-memcached package. | ||||
Installs the php-mysql package. | Installs the php-mysql package. | ||||
``php.mysqlnd`` | ``php.mysqlnd`` | ||||
------------ | |||||
--------------- | |||||
Installs the php-mysqlnd package. | Installs the php-mysqlnd package. | ||||
Installs the php-pear package. | Installs the php-pear package. | ||||
``php.pgsql`` | ``php.pgsql`` | ||||
------------ | |||||
------------- | |||||
Installs the php-pgsql package. | Installs the php-pgsql package. | ||||
Installs the php-soap package. | Installs the php-soap package. | ||||
``php.suhosin`` | ``php.suhosin`` | ||||
------------ | |||||
--------------- | |||||
Installs the php-suhosin package. | Installs the php-suhosin package. | ||||
``php.xml`` | ``php.xml`` | ||||
------------ | |||||
----------- | |||||
Installs the php-xml package. | Installs the php-xml package. | ||||
Next-generation, alternate approach | |||||
=================================== | |||||
The following states provide an alternate approach to managing PHP and FPM | |||||
pools, as well as code organization. Please provide feedback by filing issues, | |||||
discussing in ``#salt`` in Freenode and the mailing list as normal. | |||||
**Note:** php.ng states require the merge parameter of salt.modules.pillar.get(), | |||||
first available in the Helium release. | |||||
.. contents:: | |||||
:local: | |||||
``php.ng`` | |||||
---------- | |||||
Installs the php package. | |||||
``php.ng.adodb`` | |||||
---------------- | |||||
Installs the php-adodb package. | |||||
``php.ng.apc`` | |||||
-------------- | |||||
Installs the php-apc package. | |||||
``php.ng.cgi`` | |||||
-------------- | |||||
Installs the php-cgi package. | |||||
``php.ng.cli`` | |||||
-------------- | |||||
Meta-state that combines `php.ng.cli.install`_ and `php.ng.cli.ini`_. | |||||
``php.ng.cli.install`` | |||||
---------------------- | |||||
Installs the php-cli package. | |||||
``php.ng.cli.ini`` | |||||
------------------ | |||||
Manages the php-cli ini file. | |||||
``php.ng.curl`` | |||||
--------------- | |||||
Installs the php5-curl package on Debian, and ensures that curl itself is | |||||
installed for RedHat systems, this is due to the curl libs being provided by | |||||
php-common, which will get installed with the main php package. | |||||
``php.ng.fpm`` | |||||
-------------- | |||||
Meta-state that combines all php.ng.fpm states. | |||||
``php.ng.fpm.config`` | |||||
--------------------- | |||||
Manages the (non-pool) php-fpm config files. | |||||
``php.ng.fpm.install`` | |||||
---------------------- | |||||
Installs the php-fpm package. | |||||
``php.ng.fpm.pools`` | |||||
-------------------- | |||||
Meta-state that combines `php.ng.fpm.service`_ and `php.ng.fpm.pools_config`_ | |||||
``php.ng.fpm.pools_config`` | |||||
--------------------------- | |||||
Manages php-fpm pool config files. | |||||
``php.ng.fpm.service`` | |||||
---------------------- | |||||
Manages the php-fpm service. | |||||
``php.ng.gd`` | |||||
------------- | |||||
Installs the php-gd package. | |||||
``php.ng.imagick`` | |||||
------------------ | |||||
Installs the php-imagick package. | |||||
``php.ng.imap`` | |||||
--------------- | |||||
Installs the php-imap package. | |||||
``php.ng.json`` | |||||
--------------- | |||||
Installs the php-json package. | |||||
``php.ng.ldap`` | |||||
--------------- | |||||
Installs the php-ldap package. | |||||
``php.ng.mbstring`` | |||||
------------------- | |||||
Installs the php-mbstring package. | |||||
``php.ng.mcrypt`` | |||||
----------------- | |||||
Installs the php-mcrypt package. | |||||
``php.ng.memcache`` | |||||
------------------- | |||||
Installs the php-memcache package. | |||||
``php.ng.memcached`` | |||||
-------------------- | |||||
Installs the php-memcached package. | |||||
``php.ng.mysql`` | |||||
---------------- | |||||
Installs the php-mysql package. | |||||
``php.ng.mysqlnd`` | |||||
------------------ | |||||
Installs the php-mysqlnd package. | |||||
``php.ng.pear`` | |||||
--------------- | |||||
Installs the php-pear package. | |||||
``php.ng.pgsql`` | |||||
---------------- | |||||
Installs the php-pgsql package. | |||||
``php.ng.soap`` | |||||
--------------- | |||||
Installs the php-soap package. | |||||
``php.ng.suhosin`` | |||||
------------------ | |||||
Installs the php-suhosin package. | |||||
``php.ng.xml`` | |||||
-------------- | |||||
Installs the php-xml package. |
0.0.4 |
# Manages the php cli main ini file | |||||
{% from 'php/ng/map.jinja' import php with context %} | |||||
{% from "php/ng/ini.jinja" import php_ini %} | |||||
{% set settings = php.ini.defaults %} | |||||
{% do settings.update(php.cli.ini.settings) %} | |||||
php_cli_ini: | |||||
{{ php_ini(php.lookup.cli.ini, php.cli.ini.opts, settings) }} |
# Installs php-cli and manages the associated php.ini | |||||
include: | |||||
- php.ng.cli.install | |||||
- php.ng.cli.ini | |||||
extend: | |||||
php_cli_ini: | |||||
file: | |||||
- require: | |||||
- sls: php.ng.cli.install |
; | ; | ||||
; **** DO NOT EDIT THIS FILE **** | ; **** DO NOT EDIT THIS FILE **** | ||||
; | ; | ||||
; This file is managed by Salt | |||||
; This file is managed by Salt via {{ source }} | |||||
{{ php_block(config) }} | {{ php_block(config) }} |
# Manages the php-fpm main ini file | # Manages the php-fpm main ini file | ||||
{% from 'php/ng/map.jinja' import php with context %} | {% from 'php/ng/map.jinja' import php with context %} | ||||
{% from "php/ng/macro.jinja" import sls_block, serialize %} | |||||
{% from "php/ng/ini.jinja" import php_ini %} | |||||
{% set ini_settings = php.ini.defaults %} | {% set ini_settings = php.ini.defaults %} | ||||
{% do ini_settings.update(php.fpm.config.ini.settings) %} | {% do ini_settings.update(php.fpm.config.ini.settings) %} | ||||
{% do conf_settings.update(php.fpm.config.conf.settings) %} | {% do conf_settings.update(php.fpm.config.conf.settings) %} | ||||
php_fpm_ini_config: | php_fpm_ini_config: | ||||
file.managed: | |||||
{{ sls_block(php.fpm.config.ini.opts) }} | |||||
- name: {{ php.lookup.fpm.ini }} | |||||
- source: salt://php/ng/files/php.ini | |||||
- template: jinja | |||||
- context: | |||||
config: {{ serialize(ini_settings) }} | |||||
{{ php_ini(php.lookup.fpm.ini, php.fpm.config.ini.opts, ini_settings) }} | |||||
php_fpm_conf_config: | php_fpm_conf_config: | ||||
file.managed: | |||||
{{ sls_block(php.fpm.config.conf.opts) }} | |||||
- name: {{ php.lookup.fpm.conf }} | |||||
- source: salt://php/ng/files/php.ini | |||||
- template: jinja | |||||
- context: | |||||
config: {{ serialize(conf_settings) }} | |||||
{{ php_ini(php.lookup.fpm.conf, php.fpm.config.conf.opts, conf_settings) }} |
# php.ng.fpm | |||||
# | |||||
# Meta-state to fully install php. | |||||
# Meta-state to fully install php.fpm | |||||
include: | include: | ||||
- php.ng.fpm.config | - php.ng.fpm.config | ||||
- file: php_fpm_ini_config | - file: php_fpm_ini_config | ||||
- file: php_fpm_conf_config | - file: php_fpm_conf_config | ||||
- require: | - require: | ||||
- file: php_fpm_ini_config | |||||
- file: php_fpm_conf_config | |||||
- sls: php.ng.fpm.config |
# php.ini management macro. | |||||
{% from "php/ng/macro.jinja" import sls_block, serialize %} | |||||
{% macro php_ini(filename, opts={}, settings={}) %} | |||||
file.managed: | |||||
{{ sls_block(opts) }} | |||||
- name: {{ filename }} | |||||
- source: salt://php/ng/files/php.ini | |||||
- template: jinja | |||||
- context: | |||||
config: {{ serialize(settings) }} | |||||
{%- endmacro -%} |
# php.ng.ini.sls | |||||
# | |||||
# Generic php.ini management state. | |||||
{% from "php/ng/map.jinja" import php with context %} | |||||
{% from "php/ng/macro.jinja" import sls_block, serialize %} | |||||
php_ini: | |||||
file.managed: | |||||
{{ sls_block(php.ini.file_opts) }} | |||||
- source: salt://php/ng/files/php.ini | |||||
- template: jinja | |||||
- context: | |||||
config: {{ serialize(php.ini.settings) }} |
{% from "php/ng/map.jinja" import php with context %} | {% from "php/ng/map.jinja" import php with context %} | ||||
{% from "php/ng/macro.jinja" import sls_block %} | {% from "php/ng/macro.jinja" import sls_block %} | ||||
{% set opts = php.installed.get(state, {}) %} | |||||
php_install_{{ state }}: | |||||
{% pkginfo = php.lookup.pkgs.get(state) %} | |||||
{%- if pkginfo is mapping -%} | |||||
{%- for pkg, opts in pkginfo.items() -%} | |||||
php_install_{{ state }}_{{ pkg }}: | |||||
pkg.installed: | pkg.installed: | ||||
{{ sls_block(opts) }} | {{ sls_block(opts) }} | ||||
- name: {{ php.lookup.pkgs.get(state) }} | |||||
- name: {{ state }} | |||||
{%- endfor -%} | |||||
{%- else -%} | |||||
{%- if pkginfo is not sequence or is string -%} | |||||
{% set pkginfo = [pkginfo] %} | |||||
{%- endif -%} | |||||
php_install_{{ state }}: | |||||
pkg.installed: | |||||
- name: {{ state }} | |||||
- pkgs: {{ php.lookup.pkgs.get(state)|json() }} | |||||
{%- endif -%} |
{% set state = 'json' %} | |||||
{% include "php/ng/installed.jinja" %} |
{{ ret|json() }} | {{ ret|json() }} | ||||
{%- endmacro -%} | {%- endmacro -%} | ||||
{%- macro deserialize(data) -%} | |||||
{%- if data is mapping -%} | |||||
{%- set ret = odict([]) -%} | |||||
{%- for key, value in data.items() -%} | |||||
{%- do ret.update({key: deserialize(value)}) -%} | |||||
{%- endfor -%} | |||||
{%- elif data is iterable and data is not string -%} | |||||
{%- if is_list_skd(data)|int() == 1 -%} | |||||
{%- set ret = odict([]) -%} | |||||
{%- for item in data -%} | |||||
{%- for key, value in item.items() -%} | |||||
{% do ret.update({key: deserialize(value)}) %} | |||||
{%- endfor -%} | |||||
{%- endfor -%} | |||||
{%- else -%} | |||||
{%- set ret = [] -%} | |||||
{%- for item in data -%} | |||||
{%- do ret.append(deserialize(item)) -%} | |||||
{%- endfor -%} | |||||
{%- endif -%} | |||||
{%- else -%} | |||||
{% set ret = data %} | |||||
{%- endif -%} | |||||
{{ ret }} | |||||
{%- endmacro -%} | |||||
# and is not number and is mapping and item|length() == 1 | |||||
{%- macro is_list_skd(list) -%} | |||||
{% set ret = 0 %} | |||||
{%- set skds = {'counter': 0} -%} | |||||
{%- for item in list if item is mapping and item|length() == 1 -%} | |||||
{%- do skds.update({'counter': (skds.counter + 1)}) -%} | |||||
{%- endfor -%} | |||||
{%- if skds.counter == list|length() -%} | |||||
{% set ret = 1 %} | |||||
{%- endif -%} | |||||
{{ ret }} | |||||
{%- endmacro -%} |
'adodb': 'php5-adodb', | 'adodb': 'php5-adodb', | ||||
'pgsql': 'php5-pgsql', | 'pgsql': 'php5-pgsql', | ||||
'ldap': 'php5-ldap', | 'ldap': 'php5-ldap', | ||||
'json': 'php5-json', | |||||
}, | }, | ||||
'fpm': { | 'fpm': { | ||||
'conf': '/etc/php5/fpm/php-fpm.conf', | 'conf': '/etc/php5/fpm/php-fpm.conf', | ||||
])), | ])), | ||||
]), | ]), | ||||
}, | }, | ||||
'apache2_mod_php_ini': '/etc/php5/apache2/php.ini', | |||||
'cli': { | |||||
'ini': '/etc/php5/cli/php.ini', | |||||
}, | |||||
}, | }, | ||||
'RedHat': { | 'RedHat': { | ||||
'pkgs': { | 'pkgs': { | ||||
'apc': 'php-pecl-apc', | 'apc': 'php-pecl-apc', | ||||
'cgi': 'php-cgi', | 'cgi': 'php-cgi', | ||||
'cli': 'php-cli', | 'cli': 'php-cli', | ||||
'curl': 'curl', | |||||
'curl': ['php-common', 'curl'], | |||||
'fpm': 'php-fpm', | 'fpm': 'php-fpm', | ||||
'gd': 'php-gd', | 'gd': 'php-gd', | ||||
'mbstring': 'php-mbstring', | 'mbstring': 'php-mbstring', | ||||
'adodb': 'php-adodb', | 'adodb': 'php-adodb', | ||||
'pgsql': 'php-pgsql', | 'pgsql': 'php-pgsql', | ||||
'ldap': 'php-ldap', | 'ldap': 'php-ldap', | ||||
'json': 'php-common', | |||||
}, | }, | ||||
'fpm': { | 'fpm': { | ||||
'conf': '/etc/php-fpm.conf', | 'conf': '/etc/php-fpm.conf', | ||||
}, | }, | ||||
}, | }, | ||||
}, | }, | ||||
'apache2_mod_php_ini': '/etc/php.ini', | |||||
'cli': { | |||||
'ini': '/etc/php.ini', | |||||
}, | |||||
}, | }, | ||||
}), | }), | ||||
'installed': {}, | |||||
'fpm': { | 'fpm': { | ||||
'service': { | 'service': { | ||||
'enabled': True, | 'enabled': True, | ||||
'managed': {}, | 'managed': {}, | ||||
}, | }, | ||||
}, | }, | ||||
'cli': { | |||||
'ini': | |||||
'opts': {}, | |||||
'settings': {}, | |||||
}, | |||||
'ini': { | 'ini': { | ||||
'defaults': { | 'defaults': { | ||||
'PHP': { | 'PHP': { |
## php.ng pillar examples | |||||
php: | |||||
ng: | |||||
# this section contains mostly grain filtered data, while overrides | |||||
# are possible in the pillar for unique cases, if your OS is not | |||||
# represented, please consider adding it to the map.jinja for | |||||
# upstream inclusion | |||||
lookup: | |||||
# package definitions, these can lists, strings, or dictionaries | |||||
pkgs: | |||||
memcached: php5-memcached | |||||
# ensures both will be installed | |||||
curl: | |||||
- php-common | |||||
- curl | |||||
# a dictionary can be used in more complex cases where you want | |||||
# to pass forward special arguments to the pkg.installed call | |||||
cli: | |||||
php-cli: | |||||
fromrepo: my-specialrepo | |||||
php-common: | |||||
fromrepo: my-specialrepo | |||||
# php-fpm os-specific settings | |||||
fpm: | |||||
# the main php-fpm config file | |||||
conf: /etc/php5/fpm/php-fpm.conf | |||||
# the php-fpm php.ini | |||||
ini: /etc/php5/fpm/php.ini | |||||
# the location where pools are stored | |||||
pools: /etc/php5/fpm/pool.d | |||||
# the name of the php-fpm service | |||||
service: php5-fpm | |||||
# the default content of the php5-fpm main config file | |||||
defaults: | |||||
global: | |||||
pid: /var/run/php5-fpm.pid |