win_file – Creates, touches or removes files or directories
win_file – Creates, touches or removes files or directories
New in version 1.9.2.
Synopsis
- Creates (empty) files, updates file modification stamps of existing files, and can create or remove directories.
- Unlike file, does not modify ownership, permissions or manipulate links.
- For non-Windows targets, use the file module instead.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
path path / required |
Path to the file being managed.
| |
state - |
|
If If If |
Notes
Note
- For non-Windows targets, use the file module instead.
- See also win_copy, win_template, copy, template, assemble
Examples
- name: Touch a file (creates if not present, updates modification time if present)
win_file:
path: C:\Temp\foo.conf
state: touch
- name: Remove a file, if present
win_file:
path: C:\Temp\foo.conf
state: absent
- name: Create directory structure
win_file:
path: C:\Temp\folder\subfolder
state: directory
- name: Remove directory structure
win_file:
path: C:\Temp
state: absent
Status
- This module is guaranteed to have no backward incompatible interface changes going forward. [stableinterface]
- This module is maintained by the Ansible Core Team. [core]
Red Hat Support
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors
- Jon Hawkesworth (@jhawkesworth)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/win_file_module.html