4

怎么可能得到类似下面的运行:

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

...
{% endif %}

我需要它来从 ZIP 文件安装软件。我想在 minions 上解压缩,但我不想留下任何我只需要安装的许可证文件的残余。

4

3 回答 3

6
{% if 1 == salt['cmd.retcode']('test -f /tmp/woo.test') %}
ack:
  file.touch:
    - name: /tmp/woo.test
{% endif %}
于 2014-02-19T15:16:15.200 回答
6

您可以为此使用除非。

dummy:
  file.touch:
    - name: /tmp/dummy/tmp.txt
    - unless: test -d /tmp/dummy/
于 2017-05-18T19:34:06.320 回答
2

您可以使用纯 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
于 2014-02-18T16:14:39.957 回答