Note
This plugin is part of the ansible.windows collection (version 1.7.3).
You might already have this collection installed if you are using the ansible
package. It is not included in ansible-core
. To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_file
.
Parameter | Choices/Defaults | Comments |
---|---|---|
path path / required | Path to the file being managed. aliases: dest, name | |
state string |
| If directory , all immediate subdirectories will be created if they do not exist.If file , the file will NOT be created if it does not exist, see the ansible.windows.win_copy or ansible.windows.win_template module if you want that behavior.If absent , directories will be recursively deleted, and files will be removed.If touch , an empty file will be created if the path does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way touch works from the command line). |
See also
The official documentation on the ansible.builtin.file module.
The official documentation on the ansible.windows.win_acl module.
The official documentation on the ansible.windows.win_acl_inheritance module.
The official documentation on the ansible.windows.win_owner 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
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_file_module.html