.. _community.windows.win_defrag_module: **************************** community.windows.win_defrag **************************** **Consolidate fragmented files on local volumes** .. contents:: :local: :depth: 1 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 ------------ The below requirements are needed on the host that executes this module. - defrag.exe Parameters ---------- .. raw:: html
Parameter Choices/Defaults Comments
exclude_volumes
list / elements=string
A list of drive letters or mount point paths to exclude from defragmentation.
freespace_consolidation
boolean
    Choices:
  • no ←
  • yes
Perform free space consolidation on the specified volumes.
include_volumes
list / elements=string
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
boolean
    Choices:
  • no ←
  • yes
Run the operation on each volume in parallel in the background.
priority
string
    Choices:
  • low ←
  • normal
Run the operation at low or normal priority.

Examples -------- .. code-block:: yaml - name: Defragment all local volumes (in parallel) community.windows.win_defrag: parallel: yes - 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: yes Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this module: .. raw:: html
Key Returned Description
changed
boolean
always
Whether or not any changes were made.

Sample:
True
cmd
string
always
The complete command line used by the module.

Sample:
defrag.exe /C /V
msg
string
failed
Possible error message on failure.

Sample:
Command 'defrag.exe' not found in $env:PATH.
rc
integer
always
The return code for the command.

stderr
string
always
The error output from the command.

stdout
string
always
The standard output from the command.

Sample:
Success.


Status ------ Authors ~~~~~~~ - Dag Wieers (@dagwieers)