Browse Source

Cleaned up pools.

tags/v0.34.0
Chad Heuschober 10 years ago
parent
commit
ef19addb98
4 changed files with 107 additions and 33 deletions
  1. +2
    -2
      php/ng/fpm/pools_config.sls
  2. +20
    -13
      php/ng/installed.jinja
  3. +3
    -6
      php/ng/map.jinja
  4. +82
    -12
      pillar.example

+ 2
- 2
php/ng/fpm/pools_config.sls View File



{% set pool_states = [] %} {% set pool_states = [] %}


{% for pool, config in php.fpm.pools.managed.items() %}
{% for pool, config in php.fpm.pools.items() %}
{% set state = 'php_fpm_pool_conf_' ~ loop.index0 %} {% set state = 'php_fpm_pool_conf_' ~ loop.index0 %}
{% set fpath = path_join(pool, php.lookup.fpm.pools) %} {% set fpath = path_join(pool, php.lookup.fpm.pools) %}


{{ state }}: {{ state }}:
{% if config.enabled %} {% if config.enabled %}
file.managed: file.managed:
{{ sls_block(php.fpm.pools.managed_opts) }}
{{ sls_block(config.opts) }}
- name: {{ fpath }} - name: {{ fpath }}
- source: salt://php/ng/files/php.ini - source: salt://php/ng/files/php.ini
- template: jinja - template: jinja

+ 20
- 13
php/ng/installed.jinja View File



{% set pkginfo = php.lookup.pkgs.get(state) %} {% set pkginfo = php.lookup.pkgs.get(state) %}


{%- if pkginfo is mapping -%}
{%- for pkg, opts in pkginfo.items() -%}
{% set pkgs = [] %}
{% set specials = [] %}


php_install_{{ state }}_{{ pkg }}:
{% if pkginfo is iterable and pkginfo is not string %}
{% for pkg in pkginfo %}
{% if pkg is mapping %}
{% do specials.append(pkg) %}
{% else %}
{% do pkgs.append(pkg) %}
{% endif %}
{% endfor %}
{% else %}
{% do pkgs.append(pkginfo) %}
{% endif %}

php_install_{{ state }}:
pkg.installed: pkg.installed:
{{ sls_block(opts) }}
- name: {{ state }} - name: {{ state }}
- pkgs: {{ pkgs|json() }}


{%- endfor -%}
{%- else -%}
{%- if pkginfo is not sequence or pkginfo is string -%}
{% set pkginfo = [pkginfo] %}
{%- endif -%}
{% for pkg in specials %}


php_install_{{ state }}:
php_install_{{ state }}_{{ pkg.get('name') }}:
pkg.installed: pkg.installed:
- name: {{ state }}
- pkgs: {{ php.lookup.pkgs.get(state)|json() }}
{{ sls_block(pkg) }}


{%- endif -%}
{% endfor %}

+ 3
- 6
php/ng/map.jinja View File

'settings': {}, 'settings': {},
}, },
}, },
'pools': {
'managed_opts': {},
'absent_opts': {},
'managed': {},
},
'pools': {},
}, },
'cli': { 'cli': {
'ini':
'ini': {
'opts': {}, 'opts': {},
'settings': {}, 'settings': {},
}
}, },
'ini': { 'ini': {
'defaults': { 'defaults': {

+ 82
- 12
pillar.example View File

# upstream inclusion # upstream inclusion
lookup: lookup:


# package definitions, these can lists, strings, or dictionaries
# package definitions, these can strings, lists of strings, or
# lists of dictionaries
pkgs: pkgs:
memcached: php5-memcached memcached: php5-memcached
# ensures both will be installed # ensures both will be installed
- curl - curl
# a dictionary can be used in more complex cases where you want # a dictionary can be used in more complex cases where you want
# to pass forward special arguments to the pkg.installed call # to pass forward special arguments to the pkg.installed call
# you MUST include the name argument for this to work
cli: cli:
php-cli:
fromrepo: my-specialrepo
php-common:
-
name: php-cli
fromrepo: my-specialrepo fromrepo: my-specialrepo
-
name: php-common
skip_verify: True


# php-fpm os-specific settings # php-fpm os-specific settings
fpm: 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
conf: /location/of/php-fpm/config.conf
ini: /location/of/php-fpm/php.ini
pools: /location/of/php-fpm/pool.d
service: name-of-php5-fpm-service

# the default content of the php5-fpm main config file # the default content of the php5-fpm main config file
defaults: defaults:
global: global:
pid: /var/run/php5-fpm.pid pid: /var/run/php5-fpm.pid

# php-cli os-specific settings
cli:
ini: /location/of/php-cli/php.ini

# php-fpm settings
fpm:

# settings for the php-fpm service
service:
# if True, enables the php-fpm service, if False disables it
enabled: True
# additional arguments passed forward to
# service.enabled/disabled
opts:
reload: True

# settings for the relevant php-fpm configuration files
config:

# options to manage the php.ini file used by php-fpm
ini:
# arguments passed through to file.managed
opts:
recurse: True
# php.ini file contents that will be merged with the
# defaults in php.ng.ini.defaults. See php.ng.ini.defaults for
# syntax guidelines.
settings:
PHP:
engine: 'Off'

# options to manage the php-fpm conf file
conf:
# arguments passed through to file.managed
opts:
recurse: True
# php-fpm conf file contents that will be merged with
# php.ng.lookup.fpm.defaults. See php.ng.ini.defaults for
# ini-style syntax guidelines.
settings:
global:
pid: /var/run/php-fpm/special-pid.file

# settings for fpm-pools
pools:
# name of the pool file to be managed, this will be appended
# to the path specified in php.ng.lookup.fpm.pools
'mypool.conf':
# If true, the pool file will be managed, if False it will be
# absent
enabled: True
# arguments passed forward to file.managed or file.absent
opts:
replace: False

# pool file contents. See php.ng.ini.defaults for ini-style
# syntax guidelines.
settings:
myapp:
user: www-data
group: www-data
listen: /var/run/php5-fpm-myapp.sock
pm: dynamic
pm.max_children: 5
pm.start_servers: 2
pm.min_spare_servers: 1
pm.max_spare_servers: 3
'php_admin_value[memory_limit]': 300M

Loading…
Cancel
Save