Saltstack Official PHP Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.2KB

  1. {#- Manages the php-fpm main ini file #}
  2. {%- set tplroot = tpldir.split('/')[0] %}
  3. {%- from tplroot ~ "/map.jinja" import php with context %}
  4. {%- from tplroot ~ "/ini.jinja" import php_ini %}
  5. {%- set ini_settings = php.ini.defaults %}
  6. {%- for key, value in php.fpm.config.ini.settings.items() %}
  7. {%- if ini_settings[key] is defined %}
  8. {%- do ini_settings[key].update(value) %}
  9. {%- else %}
  10. {%- do ini_settings.update({key: value}) %}
  11. {%- endif %}
  12. {%- endfor %}
  13. {%- set pillar_php_version = salt['pillar.get']('php:version', '7.0') %}
  14. {%- if pillar_php_version is iterable and pillar_php_version is not string %}
  15. {%- for version in pillar_php_version %}
  16. {%- set conf_settings = odict(php.lookup.fpm.defaults) %}
  17. {%- set first_version = pillar_php_version[0]|string %}
  18. {%- set ini = php.lookup.fpm.ini|replace(first_version, version) %}
  19. {%- set conf = php.lookup.fpm.conf|replace(first_version, version) %}
  20. {%- set pools = php.lookup.fpm.pools|replace(first_version, version) %}
  21. {%- if version in php.fpm.config.ini %}
  22. {%- set ini_settings_versioned = {} %}
  23. {%- for key, value in ini_settings.items() %}
  24. {%- do ini_settings_versioned.update({key: value.copy()}) %}
  25. {%- endfor %}
  26. {%- for key, value in php.fpm.config.ini[version].items() %}
  27. {%- if ini_settings_versioned[key] is defined %}
  28. {%- do ini_settings_versioned[key].update(value) %}
  29. {%- else %}
  30. {%- do ini_settings_versioned.update({key: value}) %}
  31. {%- endif %}
  32. {%- endfor %}
  33. {%- endif %}
  34. {%- for key, value in conf_settings.items() %}
  35. {%- if value is string %}
  36. {%- do conf_settings.update({key: value.replace(first_version, version)}) %}
  37. {%- endif %}
  38. {%- endfor %}
  39. {%- do conf_settings.global.update({'pid': '/run/php/php' + version + '-fpm.pid' }) %}
  40. {%- do conf_settings.global.update({'error_log': '/var/log/php' + version + '-fpm.log' }) %}
  41. php_fpm_ini_config_{{ version }}:
  42. {{ php_ini(ini,
  43. 'php_fpm_ini_config_' ~ version,
  44. php.fpm.config.ini.opts,
  45. ini_settings_versioned | default(ini_settings)
  46. ) }}
  47. php_fpm_conf_config_{{ version }}:
  48. {{ php_ini(conf,
  49. 'php_fpm_conf_config_' ~ version,
  50. php.fpm.config.conf.opts,
  51. odict(conf_settings)
  52. ) }}
  53. {{ pools }}:
  54. file.directory:
  55. - name: {{ pools }}
  56. - user: {{ php.lookup.fpm.user }}
  57. - group: {{ php.lookup.fpm.group }}
  58. - file_mode: 755
  59. - make_dirs: True
  60. {%- endfor %}
  61. {%- else %}
  62. {%- set conf_settings = php.lookup.fpm.defaults %}
  63. {%- do conf_settings.update(php.fpm.config.conf.settings) %}
  64. php_fpm_ini_config:
  65. {{ php_ini(php.lookup.fpm.ini,
  66. 'php_fpm_ini_config',
  67. php.fpm.config.ini.opts,
  68. ini_settings
  69. ) }}
  70. php_fpm_conf_config:
  71. {{ php_ini(php.lookup.fpm.conf,
  72. 'php_fpm_conf_config',
  73. php.fpm.config.conf.opts,
  74. conf_settings
  75. ) }}
  76. {{ php.lookup.fpm.pools }}:
  77. file.directory:
  78. - name: {{ php.lookup.fpm.pools }}
  79. - user: {{ php.lookup.fpm.user }}
  80. - group: {{ php.lookup.fpm.group }}
  81. - file_mode: 755
  82. - make_dirs: True
  83. {%- endif %}