ansible.windows.win_file module – Creates, touches or removes files or directories
Note
This module is part of the ansible.windows collection (version 1.14.0).
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
.
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 |
Comments |
---|---|
Path to the file being managed. |
|
If If If If Choices:
|
See Also
See also
- ansible.builtin.file
Manage files and file properties.
- ansible.windows.win_acl
Set file/directory/registry permissions for a system user or group.
- ansible.windows.win_acl_inheritance
Change ACL inheritance.
- ansible.windows.win_owner
Set owner.
- ansible.windows.win_stat
Get information about Windows files.
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