ansible 怎么检查文件是否存在

详细的具体方案见  https://stackoverflow.com/questions/35654286/how-to-check-if-a-file-exists-in-ansible

这里举出其中最具代表性的例子

- name: Register file
      stat:
        path: "/tmp/test_file"
      register: file_path

- name: Create file if it doesn't exists
      file: 
        path: "/tmp/test_file"
        state: touch
      when: file_path.stat.exists == False

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章