是否有办法在saltstack中从.sls或.jinja文件中记录自定义调试消息?例如:
{% salt.log_message("Entering...") %}
这是作为2017.7.0的功能添加的:
是的,在Salt中,可以使用日志例如,调用
{%- do salt.log.error('testing jinja logging') -%}
将在仆从日志中插入以下消息:
2017-02-01 01:24:40,728 [salt.module.logmod][ERROR ][3779] testing jinja logging
使用test.nop
添加一个状态,并添加您想要检查的东西作为参数。
salt-call -l debug state.apply yourslsfile test=True
或
salt-call --output=yaml state.show_sls yourslsfile
检查结果。
例如:debug.sls
test:
test.nop:
- user: {{ grains.username }}
- nested:
foo: bar
这是state.show_sls
local:
test:
test:
- user: ian
- nested:
foo: bar
- nop
- order: 10000
__sls__: !!python/unicode dotfiles
__env__: base
最好设置一个独立的环境来测试状态,如下所示