ansible.windows.win_file – Creates, touches or removes files or directories
ansible.windows.win_file – Creates, touches or removes files or directories
Note
This plugin is part of the ansible.windows collection (version 1.3.0).
To install it use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_file
.
Synopsis
- Creates (empty) files, updates file modification stamps of existing files, and can create or remove directories.
- Unlike ansible.builtin.file, does not modify ownership, permissions or manipulate links.
- For non-Windows targets, use the ansible.builtin.file module instead.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
path path / required |
Path to the file being managed.
| |
state string |
|
If If If If |
See Also
See also
- ansible.builtin.file
- The official documentation on the ansible.builtin.file module.
- ansible.windows.win_acl
- The official documentation on the ansible.windows.win_acl module.
- ansible.windows.win_acl_inheritance
- The official documentation on the ansible.windows.win_acl_inheritance module.
- ansible.windows.win_owner
- The official documentation on the ansible.windows.win_owner module.
- ansible.windows.win_stat
- The official documentation on the ansible.windows.win_stat module.
Examples
- 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
Authors
- Jon Hawkesworth (@jhawkesworth)
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/ansible/windows/win_file_module.html