Check file exists and create a symlink

你。 提交于 2019-12-03 03:23:11

We can use file.directory_exists

{% if not salt['file.directory_exists' ]('/symlink/path/A') %}
symlink:
  file.symlink:
    - name: /path/to/A
    - target: /symlink/path/A
{% endif %}
Jason Zhu

You should use Dan Garthwaite's excellent answer here as a basis for how to check for the existence of a file. I have modified his solution to answer your question.

{% if 1 == salt['cmd.retcode']('test -f /path/to/A') %}
/path/to/A:
  file.symlink:
    - target: /symlink/path/A
{% endif %}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!