win_file - Creates, touches or removes files or directories¶
New in version 1.9.2.
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
path
path required |
Path to the file being managed.
aliases: dest, name |
|
state |
|
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 copy or 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). |
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 flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
Maintenance¶
This module is flagged as core which means that it is maintained by the Ansible Core Team. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Core Team, see here.
Support¶
For more information about Red Hat’s support of this module, please refer to this Knowledge Base article
Author¶
- Jon Hawkesworth (@jhawkesworth)
Hint
If you notice any issues in this documentation you can edit this document to improve it.