saltstack-formulas / php-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
57 stars 231 forks source link

php.ng.fpm formula won't work without pillar data #47

Closed aboe76 closed 8 years ago

aboe76 commented 9 years ago

If you run the php.ng.fpm state on a minion without pillar data gives the following error:

Passed invalid arguments: 'NoneType' object is not iterable

On a debug level I found the following issue:

[DEBUG   ] Results of YAML rendering: 
OrderedDict([('include', ['php.ng.fpm.service', 'php.ng.fpm.pools_config']), ('extend', OrderedDict([('php_fpm_service', OrderedDict([('service', [OrderedDict([('watch', None)]), OrderedDict([('require', None)])])]))]))])
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://php/ng/fpm/pools_config.sls'
[DEBUG   ] Jinja search path: ['/var/cache/salt/minion/files/base']
[DEBUG   ] Re-using SAuth for ('/etc/salt/pki/minion', 'example.home.lan', 'tcp://xxx.xxx.xxx.xxx:4506')
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://php/ng/map.jinja'
[INFO    ] Fetching file from saltenv 'base', ** skipped ** latest already in cache 'salt://php/ng/macro.jinja'
[DEBUG   ] Rendered data from file: /var/cache/salt/minion/files/base/php/ng/fpm/pools_config.sls:
# Manages the php-fpm pools config files

# Simple path concatenation.

[DEBUG   ] Results of YAML rendering: 
{}
Passed invalid arguments: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 138, in call
    ret['return'] = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/modules/state.py", line 671, in sls
    ret = st_.state.call_high(high_)
  File "/usr/lib/python2.7/site-packages/salt/state.py", line 2027, in call_high
    high, ext_errors = self.reconcile_extend(high)
  File "/usr/lib/python2.7/site-packages/salt/state.py", line 1208, in reconcile_extend
    .extend(arg[argfirst]))
TypeError: 'NoneType' object is not iterable

So it looks like it trying to create a fpm pool without data.

I would think the state php.ng.fpm would just do nothing with pools if they aren't provided in pillar.

aboe76 commented 9 years ago

@cheuschober could you check this? I thought it would work without any additional pillar data,

aboe76 commented 9 years ago

I think a quick fix is to remove the php.ng.fpm.pools from the include in init.sls that way you can still install and configure php fpm and use the default pools provided by the package. and include php.ng.fpm.pools if you want to overwrite and or extend the php fpm pools.

cheuschober commented 9 years ago

@aboe76 alternately you could still set the key but just pass it an empty value, eg empty dict/list etc

aboe76 commented 9 years ago

That's what the defaults in map.jinja does

johnkeates commented 8 years ago

This happened to me too, took a while to figure out what was happening as we did have some FPM pillar data, but just no pools. (due to our pillar merging strategy with common snippets being included even if there are no pools yet)

genuss commented 8 years ago

If someone would need a minimal config, here it is:

php:
  ng:
    fpm:
      pools:
        default.conf:
          enabled: False
hackel commented 8 years ago

Just got bit by this myself. This is really frustrating to debug, basically by trial-and-error (wish I would have seen this first!). If you would still like to make sure your pools are managed by salt, here is the default pool configuration that comes with php:

php:
  ng:
    fpm:
      pools:
        'www.conf':
          enabled: True
          settings:
            www:
              user: www-data
              group: www-data
              listen: /run/php/php7.0-fpm.sock
              listen.owner: www-data
              listen.group: www-data
              pm: dynamic
              pm.max_children: 5
              pm.start_servers: 2
              pm.min_spare_servers: 1
              pm.max_spare_servers: 3