| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright: (c) 2017, Liran Nisanov <[email protected]> |
| 5 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r''' |
| 8 |
--- |
| 9 |
module: win_pagefile |
| 10 |
short_description: Query or change pagefile configuration |
| 11 |
description: |
| 12 |
- Query current pagefile configuration. |
| 13 |
- Enable/Disable AutomaticManagedPagefile. |
| 14 |
- Create new or override pagefile configuration. |
| 15 |
options: |
| 16 |
drive: |
| 17 |
description: |
| 18 |
- The drive of the pagefile. |
| 19 |
type: str |
| 20 |
initial_size: |
| 21 |
description: |
| 22 |
- The initial size of the pagefile in megabytes. |
| 23 |
type: int |
| 24 |
maximum_size: |
| 25 |
description: |
| 26 |
- The maximum size of the pagefile in megabytes. |
| 27 |
type: int |
| 28 |
override: |
| 29 |
description: |
| 30 |
- Override the current pagefile on the drive. |
| 31 |
type: bool |
| 32 |
default: yes |
| 33 |
system_managed: |
| 34 |
description: |
| 35 |
- Configures current pagefile to be managed by the system. |
| 36 |
type: bool |
| 37 |
default: no |
| 38 |
automatic: |
| 39 |
description: |
| 40 |
- Configures AutomaticManagedPagefile for the entire system. |
| 41 |
type: bool |
| 42 |
remove_all: |
| 43 |
description: |
| 44 |
- Remove all pagefiles in the system, not including automatic managed. |
| 45 |
type: bool |
| 46 |
default: no |
| 47 |
test_path: |
| 48 |
description: |
| 49 |
- Use Test-Path on the drive to make sure the drive is accessible before creating the pagefile. |
| 50 |
type: bool |
| 51 |
default: yes |
| 52 |
state: |
| 53 |
description: |
| 54 |
- State of the pagefile. |
| 55 |
type: str |
| 56 |
choices: [ absent, present, query ] |
| 57 |
default: query |
| 58 |
notes: |
| 59 |
- There is difference between automatic managed pagefiles that configured once for the entire system and system managed pagefile that configured per pagefile. |
| 60 |
- InitialSize 0 and MaximumSize 0 means the pagefile is managed by the system. |
| 61 |
- Value out of range exception may be caused by several different issues, two common problems - No such drive, Pagefile size is too small. |
| 62 |
- Setting a pagefile when AutomaticManagedPagefile is on will disable the AutomaticManagedPagefile. |
| 63 |
author: |
| 64 |
- Liran Nisanov (@LiranNis) |
| 65 |
''' |
| 66 |
|
| 67 |
EXAMPLES = r''' |
| 68 |
- name: Query pagefiles configuration |
| 69 |
community.windows.win_pagefile: |
| 70 |
|
| 71 |
- name: Query C pagefile |
| 72 |
community.windows.win_pagefile: |
| 73 |
drive: C |
| 74 |
|
| 75 |
- name: Set C pagefile, don't override if exists |
| 76 |
community.windows.win_pagefile: |
| 77 |
drive: C |
| 78 |
initial_size: 1024 |
| 79 |
maximum_size: 1024 |
| 80 |
override: false |
| 81 |
state: present |
| 82 |
|
| 83 |
- name: Set C pagefile, override if exists |
| 84 |
community.windows.win_pagefile: |
| 85 |
drive: C |
| 86 |
initial_size: 1024 |
| 87 |
maximum_size: 1024 |
| 88 |
state: present |
| 89 |
|
| 90 |
- name: Remove C pagefile |
| 91 |
community.windows.win_pagefile: |
| 92 |
drive: C |
| 93 |
state: absent |
| 94 |
|
| 95 |
- name: Remove all current pagefiles, enable AutomaticManagedPagefile and query at the end |
| 96 |
community.windows.win_pagefile: |
| 97 |
remove_all: true |
| 98 |
automatic: true |
| 99 |
|
| 100 |
- name: Remove all pagefiles disable AutomaticManagedPagefile and set C pagefile |
| 101 |
community.windows.win_pagefile: |
| 102 |
drive: C |
| 103 |
initial_size: 2048 |
| 104 |
maximum_size: 2048 |
| 105 |
remove_all: true |
| 106 |
automatic: false |
| 107 |
state: present |
| 108 |
|
| 109 |
- name: Set D pagefile, override if exists |
| 110 |
community.windows.win_pagefile: |
| 111 |
drive: d |
| 112 |
initial_size: 1024 |
| 113 |
maximum_size: 1024 |
| 114 |
state: present |
| 115 |
''' |
| 116 |
|
| 117 |
RETURN = r''' |
| 118 |
automatic_managed_pagefiles: |
| 119 |
description: Whether the pagefiles is automatically managed. |
| 120 |
returned: When state is query. |
| 121 |
type: bool |
| 122 |
sample: true |
| 123 |
pagefiles: |
| 124 |
description: Contains caption, description, initial_size, maximum_size and name for each pagefile in the system. |
| 125 |
returned: When state is query. |
| 126 |
type: list |
| 127 |
sample: |
| 128 |
[{"caption": "c:\\ 'pagefile.sys'", "description": "'pagefile.sys' @ c:\\", "initial_size": 2048, "maximum_size": 2048, "name": "c:\\pagefile.sys"}, |
| 129 |
{"caption": "d:\\ 'pagefile.sys'", "description": "'pagefile.sys' @ d:\\", "initial_size": 1024, "maximum_size": 1024, "name": "d:\\pagefile.sys"}] |
| 130 |
|
| 131 |
''' |