On this page
win_defrag - Consolidate fragmented files on local volumes.
New in version 2.4.
Synopsis
- Locates and consolidates fragmented files on local volumes to improve system performance.
- More information regarding
win_defrag
is available from: https://technet.microsoft.com/en-us/library/cc731650(v=ws.11.aspx)
Requirements (on host that executes module)
- defrag.exe
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
excluded_volumes |
no |
A list of drive letters or mount point paths to exclude from defragmentation.
|
||
freespace_consolidation |
no |
Perform free space consolidation on the specified volumes.
|
||
included_volumes |
no |
A list of drive letters or mount point paths of the volumes to be defragmented.
If this parameter is omitted, all volumes (not excluded) will be fragmented.
|
||
parallel |
no | no |
|
Run the operation on each volume in parallel in the background.
|
priority |
no | low |
|
Run the operation at low or normal priority.
|
Examples
- name: Defragment all local volumes (in parallel)
win_defrag:
parallel: yes
- name: 'Defragment all local volumes, except C: and D:'
win_defrag:
exclude_volumes: [ C, D ]
- name: 'Defragment volume D: with normal priority'
win_defrag:
include_volumes: D
priority: normal
- name: Consolidate free space (useful when reducing volumes)
win_defrag:
freespace_consolidation: yes
Return Values
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
changed |
Whether or not any changes were made.
|
always | bool | True |
cmd |
The complete command line used by the module
|
always | string | defrag.exe /C /V |
msg |
Possible error message on failure
|
failed | string | Command 'defrag.exe' not found in $env:PATH. |
rc |
The return code for the command
|
always | int | 0 |
stderr |
The error output from the command
|
always | string | None |
stdout |
The standard output from the command
|
always | string | Success. |
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/win_defrag_module.html