community.windows.win_file_compression 模块 – 更改 NTFS 分区上文件和目录的压缩属性。
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible 软件包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.windows。
要在剧本中使用它,请指定:community.windows.win_file_compression。
概要
- 此模块设置支持压缩的文件系统(如 NTFS)上文件和目录的压缩属性。 
- NTFS 压缩可用于节省磁盘空间。 
参数
| 参数 | 注释 | 
|---|---|
| 此选项仅在 recurse 为  如果为  如果为  如果文件夹结构复杂或包含大量文件,建议将此选项设置为  选项 
 | |
| 要修改的文件或目录的完整路径。 路径必须存在于支持压缩的文件系统(如 NTFS)上。 | |
| 是否将更改递归应用于所有子目录和文件。 此选项仅在 path 是目录时有效。 设置为  设置为  选项 
 | |
| 设置为  设置为  选项 
 | 
备注
注意
- community.windows.win_file_compression 设置文件系统的压缩状态,它不会创建 zip 压缩文件。 
- 有关 NTFS 压缩的更多信息,请参阅 http://www.ntfs.com/ntfs-compressed.htm 
示例
- name: Compress log files directory
  community.windows.win_file_compression:
    path: C:\Logs
    state: present
- name: Decompress log files directory
  community.windows.win_file_compression:
    path: C:\Logs
    state: absent
- name: Compress reports directory and all subdirectories
  community.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)
  community.windows.win_file_compression:
    path: C:\business\reports
    compressed: true
    recurse: true
    force: false
返回值
常用返回值已在 此处 记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 压缩/解压缩操作的返回代码。 如果没有进行更改或操作成功,则 rc 为 0。 返回:始终 示例: | 
