怎么可能得到类似下面的运行:
{% if not exist('/tmp/dummy/') then %}
dummy:
file.touch:
- name: /tmp/dummy/tmp.txt
...
{% endif %}
我需要它来从 ZIP 文件安装软件。我想在 minions 上解压缩,但我不想留下任何我只需要安装的许可证文件的残余。
怎么可能得到类似下面的运行:
{% if not exist('/tmp/dummy/') then %}
dummy:
file.touch:
- name: /tmp/dummy/tmp.txt
...
{% endif %}
我需要它来从 ZIP 文件安装软件。我想在 minions 上解压缩,但我不想留下任何我只需要安装的许可证文件的残余。
{% if 1 == salt['cmd.retcode']('test -f /tmp/woo.test') %}
ack:
file.touch:
- name: /tmp/woo.test
{% endif %}
您可以为此使用除非。
dummy:
file.touch:
- name: /tmp/dummy/tmp.txt
- unless: test -d /tmp/dummy/
您可以使用纯 python 渲染器来处理盐。这是它的样子。
#!py
import os
def run():
# defines the hash config
config = {}
if (not os.path.isfile("/tmp/dummy")):
config["dummy"] = {
"file.touch": [
{'name': '/tmp/dummy'},
],
}
return config