根据文件/目录的存在来定义状态

ber*_*sel 4 salt-stack

怎么可能得到以下运行:

{% if not exist('/tmp/dummy/') then %}
dummy:
  file.touch:
    - name: /tmp/dummy/tmp.txt

...
{% endif %}
Run Code Online (Sandbox Code Playgroud)

我需要它来从ZI​​P文件安装软件.我想解开minions,但在那里我不想要任何许可证文件的遗留物,我只需要安装,左边.

Dan*_*ite 6

{% if 1 == salt['cmd.retcode']('test -f /tmp/woo.test') %}
ack:
  file.touch:
    - name: /tmp/woo.test
{% endif %}
Run Code Online (Sandbox Code Playgroud)


gtm*_*red 5

你可以使用除非这个.

dummy:
  file.touch:
    - name: /tmp/dummy/tmp.txt
    - unless: test -d /tmp/dummy/
Run Code Online (Sandbox Code Playgroud)