How to create an empty file with Ansible?

后端 未结 10 945
傲寒
傲寒 2021-01-31 12:53

What is the easiest way to create an empty file using Ansible? I know I can save an empty file into the files directory and then copy it to the remote host, but I f

10条回答
  •  感动是毒
    2021-01-31 13:41

    Another option, using the command module:

    - name: Create file
      command: touch /path/to/file
      args:
        creates: /path/to/file
    

    The 'creates' argument ensures that this action is not performed if the file exists.

提交回复
热议问题