Defining states depending on existance of a file/directory

前端 未结 3 693
广开言路
广开言路 2021-01-06 11:33

How is it possible to get something like the following running:

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


        
3条回答
  •  长情又很酷
    2021-01-06 11:55

    You can use unless for this.

    dummy:
      file.touch:
        - name: /tmp/dummy/tmp.txt
        - unless: test -d /tmp/dummy/
    

提交回复
热议问题