1、这种情况是可以的,只有一个 deploy.sls 时,appname 可以传递给 /data/apps/{{ appname }}
// deploy.sls
{% set appname = 'foo-service' %}
app-config-dir:
file.directory:
- name: /data/apps/{{ appname }} # --> 得到值为 foo-service
- mode: 755
- user: root
- group: root
2、下面这种情况就不行,appname 不能传递给 include 后的 config.sls 文件,报错提示 Jinja variable 'appname' is undefined
// deploy.sls
{% set appname = 'foo-service' %}
include:
- config
// config.sls
app-config-dir:
file.directory:
- name: /data/apps/{{ appname }}
- mode: 755
- user: root
- group: root
如何要实现 appname 能传递给 include 后的 config.sls 文件,要怎么做?