我试图按照https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html上的说明创建一个非常基本的PHP状态 .
/srv/salt/php.sls
:
php_ini:
file.managed:
- name: /etc/php.ini
- source: salt://php.ini.tmpl
- template: jinja
- context:
php_ini_settings: {{ salt.pillar.get('php_ini', {}) | json() }}
/srv/pillar/php.sls
:
php_ini:
PHP:
engine: 'On'
short_open_tag: 'Off'
error_reporting: 'E_ALL & ~E_DEPRECATED & ~E_STRICT'
/srv/salt/php.ini.tmpl
:
{% macro php_ini_serializer(data) %}
{% for section_name, name_val_pairs in data.items() %}
[{{ section_name }}]
{% for name, val in name_val_pairs.items() -%}
{{ name }} = "{{ val }}"
{% endfor %}
{% endfor %}
{% endmacro %}
; File managed by Salt at <{{ source }}>.
; Your changes will be overwritten.
{{ php_ini_serializer(php_ini_settings) }}
输出文件如下所示:
VVV File starts on the next line
; File managed by Salt at <salt://php.ini.tmpl>.
; Your changes will be overwritten.
^^^ File ends on the previous line
我添加了额外的行,以便Stack Overflow正确显示输出文件中的空白行 .
我希望它看起来有点链接:
VVV File starts on the next line
; File managed by Salt at <salt://php.ini.tmpl>.
; Your changes will be overwritten.
[PHP]
engine = "On"
short_open_tag = "Off"
error_reporting = "E_ALL & ~E_DEPRECATED & ~E_STRICT"
^^^ File ends on the previous line
盐似乎根本没有读取支柱文件 . 我做错了什么?
1 回答
看起来
php_ini_settings: {{ salt.pillar.get('php_ini', {}) | json() }}
不会将任何数据添加到您的jinja模板salt://php.ini.tmpl
的上下文中 .要调试检查支柱数据是否可用,请使用pillar module
支柱数据needs to be applied to minions喜欢使用
top.sls
文件的状态 . 我的猜测是你没有将你的支柱数据应用到你的小兵身上 ./srv/pillar/top.sls
包含这样的东西吗?