ansible.windows.win_file_compression module – Alters the compression of files and directories on NTFS partitions.
Note
This module is part of the ansible.windows collection (version 3.2.0).
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_compression.
New in ansible.windows 2.7.0
Synopsis
- This module sets the compressed attribute for files and directories on a filesystem that supports it like NTFS. 
- NTFS compression can be used to save disk space. 
Parameters
| Parameter | Comments | 
|---|---|
| This option only has an effect when recurse is  If  If  If the folder structure is complex or contains a lot of files, it is recommended to set this option to  Choices: 
 | |
| The full path of the file or directory to modify. The path must exist on file system that supports compression like NTFS. | |
| Whether to recursively apply changes to all subdirectories and files. This option only has an effect when path is a directory. When set to  When set to  Choices: 
 | |
| Set to  Set to  Choices: 
 | 
Notes
Note
- ansible.windows.win_file_compression sets the file system’s compression state, it does not create a zip archive file. 
- For more about NTFS Compression, see http://www.ntfs.com/ntfs-compressed.htm 
Examples
- name: Compress log files directory
  ansible.windows.win_file_compression:
    path: C:\Logs
    state: present
- name: Decompress log files directory
  ansible.windows.win_file_compression:
    path: C:\Logs
    state: absent
- name: Compress reports directory and all subdirectories
  ansible.windows.win_file_compression:
    path: C:\business\reports
    state: present
    recurse: true
# This will only check C:\business\reports for the compressed state
# If C:\business\reports is compressed, it will not make a change
# even if one of the child items is uncompressed
- name: Compress reports directory and all subdirectories (quick)
  ansible.windows.win_file_compression:
    path: C:\business\reports
    compressed: true
    recurse: true
    force: false
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| The return code of the compress/uncompress operation. If no changes are made or the operation is successful, rc is 0. Returned: always Sample:  | 
