community.windows.win_defrag 模块 – 合并本地卷上的碎片文件
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.windows
。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.windows.win_defrag
。
概要
查找并合并本地卷上的碎片文件以提高系统性能。
有关
win_defrag
的更多信息,请访问:https://technet.microsoft.com/en-us/library/cc731650%28v%3Dws.11.aspx%29
要求
执行此模块的主机需要以下要求。
defrag.exe
参数
参数 |
注释 |
---|---|
要从碎片整理中排除的驱动器号或挂载点路径列表。 |
|
对指定的卷执行可用空间合并。 选项
|
|
要进行碎片整理的卷的驱动器号或挂载点路径列表。 如果省略此参数,则所有(未排除的)卷都将被碎片整理。 |
|
在后台并行地对每个卷运行操作。 选项
|
|
以低优先级或正常优先级运行操作。 选项
|
示例
- name: Defragment all local volumes (in parallel)
community.windows.win_defrag:
parallel: true
- name: 'Defragment all local volumes, except C: and D:'
community.windows.win_defrag:
exclude_volumes: [C, D]
- name: 'Defragment volume D: with normal priority'
community.windows.win_defrag:
include_volumes: D
priority: normal
- name: Consolidate free space (useful when reducing volumes)
community.windows.win_defrag:
freespace_consolidation: true
返回值
常用的返回值已在 此处 记录,以下是此模块特有的字段
键 |
描述 |
---|---|
是否进行了任何更改。 返回:始终 示例: |
|
模块使用的完整命令行。 返回:始终 示例: |
|
失败时的错误消息。 返回:失败 示例: |
|
命令的返回码。 返回:始终 示例: |
|
命令的错误输出。 返回:始终 |
|
命令的标准输出。 返回:始终 示例: |