Creates, touches or removes files or directories
- Creates (empty) files, updates file modification stamps of existing files, and can create or remove directories.
- Unlike :ref:`ansible.builtin.file <ansible.builtin.file_module>`, does not modify ownership, permissions or manipulate links.
- For non-Windows targets, use the :ref:`ansible.builtin.file <ansible.builtin.file_module>` module instead.
.. seealso:: :ref:`ansible.builtin.file_module` The official documentation on the **ansible.builtin.file** module. :ref:`ansible.windows.win_acl_module` The official documentation on the **ansible.windows.win_acl** module. :ref:`ansible.windows.win_acl_inheritance_module` The official documentation on the **ansible.windows.win_acl_inheritance** module. :ref:`ansible.windows.win_owner_module` The official documentation on the **ansible.windows.win_owner** module. :ref:`ansible.windows.win_stat_module` The official documentation on the **ansible.windows.win_stat** module.
- name: Touch a file (creates if not present, updates modification time if present)
ansible.windows.win_file:
path: C:\Temp\foo.conf
state: touch
- name: Remove a file, if present
ansible.windows.win_file:
path: C:\Temp\foo.conf
state: absent
- name: Create directory structure
ansible.windows.win_file:
path: C:\Temp\folder\subfolder
state: directory
- name: Remove directory structure
ansible.windows.win_file:
path: C:\Temp
state: absent
- Jon Hawkesworth (@jhawkesworth)