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

 

你可能感兴趣的:(ansible)