@@ -0,0 +1,13 @@ | |||
=========== | |||
php-formula | |||
=========== | |||
0.2.0 | |||
----- | |||
- Added .ng states | |||
0.1.0 | |||
----- | |||
- Initial version |
@@ -26,17 +26,17 @@ Installs the php package. | |||
Installs the php-apc package. | |||
``php.adodb`` | |||
------------ | |||
------------- | |||
Installs the php-adodb package. | |||
``php.cgi`` | |||
------------ | |||
----------- | |||
Installs the php-cgi package. | |||
``php.cli`` | |||
------------ | |||
----------- | |||
Installs the php-cli package. | |||
@@ -59,7 +59,7 @@ Installs the php-gd package. | |||
``php.imagick`` | |||
------------ | |||
--------------- | |||
Installs the php-imagick package. | |||
@@ -79,7 +79,7 @@ Installs the php-json package. | |||
Installs the php-ldap package. | |||
``php.mbstring`` | |||
--------------- | |||
---------------- | |||
Installs the php-mbstring package. | |||
@@ -90,12 +90,12 @@ Installs the php-mcrypt package. | |||
``php.memcache`` | |||
------------ | |||
---------------- | |||
Installs the php-memcache package. | |||
``php.memcached`` | |||
------------ | |||
----------------- | |||
Installs the php-memcached package. | |||
@@ -105,7 +105,7 @@ Installs the php-memcached package. | |||
Installs the php-mysql package. | |||
``php.mysqlnd`` | |||
------------ | |||
--------------- | |||
Installs the php-mysqlnd package. | |||
@@ -115,7 +115,7 @@ Installs the php-mysqlnd package. | |||
Installs the php-pear package. | |||
``php.pgsql`` | |||
------------ | |||
------------- | |||
Installs the php-pgsql package. | |||
@@ -125,11 +125,182 @@ Installs the php-pgsql package. | |||
Installs the php-soap package. | |||
``php.suhosin`` | |||
------------ | |||
--------------- | |||
Installs the php-suhosin package. | |||
``php.xml`` | |||
------------ | |||
----------- | |||
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 +1 @@ | |||
0.0.4 |
@@ -0,0 +1,9 @@ | |||
# 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) }} |
@@ -0,0 +1,11 @@ | |||
# 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 |
@@ -27,5 +27,5 @@ | |||
; | |||
; **** DO NOT EDIT THIS FILE **** | |||
; | |||
; This file is managed by Salt | |||
; This file is managed by Salt via {{ source }} | |||
{{ php_block(config) }} |
@@ -1,6 +1,6 @@ | |||
# Manages the php-fpm main ini file | |||
{% 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 %} | |||
{% do ini_settings.update(php.fpm.config.ini.settings) %} | |||
@@ -9,19 +9,7 @@ | |||
{% do conf_settings.update(php.fpm.config.conf.settings) %} | |||
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: | |||
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) }} |
@@ -1,6 +1,4 @@ | |||
# php.ng.fpm | |||
# | |||
# Meta-state to fully install php. | |||
# Meta-state to fully install php.fpm | |||
include: | |||
- php.ng.fpm.config | |||
@@ -14,5 +12,4 @@ extend: | |||
- file: php_fpm_ini_config | |||
- file: php_fpm_conf_config | |||
- require: | |||
- file: php_fpm_ini_config | |||
- file: php_fpm_conf_config | |||
- sls: php.ng.fpm.config |
@@ -0,0 +1,12 @@ | |||
# 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 -%} |
@@ -1,13 +0,0 @@ | |||
# 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) }} |
@@ -2,9 +2,26 @@ | |||
{% from "php/ng/map.jinja" import php with context %} | |||
{% 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: | |||
{{ 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 -%} |
@@ -0,0 +1,2 @@ | |||
{% set state = 'json' %} | |||
{% include "php/ng/installed.jinja" %} |
@@ -25,44 +25,3 @@ | |||
{{ ret|json() }} | |||
{%- 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 -%} |
@@ -24,6 +24,7 @@ | |||
'adodb': 'php5-adodb', | |||
'pgsql': 'php5-pgsql', | |||
'ldap': 'php5-ldap', | |||
'json': 'php5-json', | |||
}, | |||
'fpm': { | |||
'conf': '/etc/php5/fpm/php-fpm.conf', | |||
@@ -38,7 +39,9 @@ | |||
])), | |||
]), | |||
}, | |||
'apache2_mod_php_ini': '/etc/php5/apache2/php.ini', | |||
'cli': { | |||
'ini': '/etc/php5/cli/php.ini', | |||
}, | |||
}, | |||
'RedHat': { | |||
'pkgs': { | |||
@@ -46,7 +49,7 @@ | |||
'apc': 'php-pecl-apc', | |||
'cgi': 'php-cgi', | |||
'cli': 'php-cli', | |||
'curl': 'curl', | |||
'curl': ['php-common', 'curl'], | |||
'fpm': 'php-fpm', | |||
'gd': 'php-gd', | |||
'mbstring': 'php-mbstring', | |||
@@ -64,6 +67,7 @@ | |||
'adodb': 'php-adodb', | |||
'pgsql': 'php-pgsql', | |||
'ldap': 'php-ldap', | |||
'json': 'php-common', | |||
}, | |||
'fpm': { | |||
'conf': '/etc/php-fpm.conf', | |||
@@ -78,10 +82,11 @@ | |||
}, | |||
}, | |||
}, | |||
'apache2_mod_php_ini': '/etc/php.ini', | |||
'cli': { | |||
'ini': '/etc/php.ini', | |||
}, | |||
}, | |||
}), | |||
'installed': {}, | |||
'fpm': { | |||
'service': { | |||
'enabled': True, | |||
@@ -103,6 +108,11 @@ | |||
'managed': {}, | |||
}, | |||
}, | |||
'cli': { | |||
'ini': | |||
'opts': {}, | |||
'settings': {}, | |||
}, | |||
'ini': { | |||
'defaults': { | |||
'PHP': { |
@@ -0,0 +1,39 @@ | |||
## 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 |