1#!/usr/local/bin/python3.8 2# -*- coding: utf-8 -*- 3 4# Copyright: 2017, Dag Wieers (@dagwieers) <dag@wieers.com> 5# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) 6 7DOCUMENTATION = r''' 8--- 9module: win_defrag 10short_description: Consolidate fragmented files on local volumes 11description: 12- Locates and consolidates fragmented files on local volumes to improve system performance. 13- 'More information regarding C(win_defrag) is available from: U(https://technet.microsoft.com/en-us/library/cc731650(v=ws.11).aspx)' 14requirements: 15- defrag.exe 16options: 17 include_volumes: 18 description: 19 - A list of drive letters or mount point paths of the volumes to be defragmented. 20 - If this parameter is omitted, all volumes (not excluded) will be fragmented. 21 type: list 22 elements: str 23 exclude_volumes: 24 description: 25 - A list of drive letters or mount point paths to exclude from defragmentation. 26 type: list 27 elements: str 28 freespace_consolidation: 29 description: 30 - Perform free space consolidation on the specified volumes. 31 type: bool 32 default: no 33 priority: 34 description: 35 - Run the operation at low or normal priority. 36 type: str 37 choices: [ low, normal ] 38 default: low 39 parallel: 40 description: 41 - Run the operation on each volume in parallel in the background. 42 type: bool 43 default: no 44author: 45- Dag Wieers (@dagwieers) 46''' 47 48EXAMPLES = r''' 49- name: Defragment all local volumes (in parallel) 50 community.windows.win_defrag: 51 parallel: yes 52 53- name: 'Defragment all local volumes, except C: and D:' 54 community.windows.win_defrag: 55 exclude_volumes: [ C, D ] 56 57- name: 'Defragment volume D: with normal priority' 58 community.windows.win_defrag: 59 include_volumes: D 60 priority: normal 61 62- name: Consolidate free space (useful when reducing volumes) 63 community.windows.win_defrag: 64 freespace_consolidation: yes 65''' 66 67RETURN = r''' 68cmd: 69 description: The complete command line used by the module. 70 returned: always 71 type: str 72 sample: defrag.exe /C /V 73rc: 74 description: The return code for the command. 75 returned: always 76 type: int 77 sample: 0 78stdout: 79 description: The standard output from the command. 80 returned: always 81 type: str 82 sample: Success. 83stderr: 84 description: The error output from the command. 85 returned: always 86 type: str 87 sample: 88msg: 89 description: Possible error message on failure. 90 returned: failed 91 type: str 92 sample: Command 'defrag.exe' not found in $env:PATH. 93changed: 94 description: Whether or not any changes were made. 95 returned: always 96 type: bool 97 sample: true 98''' 99