community.windows.win_pagefile – Query or change pagefile configuration
Note
This plugin is part of the community.windows collection (version 1.8.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_pagefile
.
Synopsis
Query current pagefile configuration.
Enable/Disable AutomaticManagedPagefile.
Create new or override pagefile configuration.
Parameters
Parameter |
Comments |
---|---|
Configures AutomaticManagedPagefile for the entire system. Choices:
|
|
The drive of the pagefile. |
|
The initial size of the pagefile in megabytes. |
|
The maximum size of the pagefile in megabytes. |
|
Override the current pagefile on the drive. Choices:
|
|
Remove all pagefiles in the system, not including automatic managed. Choices:
|
|
State of the pagefile. Choices:
|
|
Configures current pagefile to be managed by the system. Choices:
|
|
Use Test-Path on the drive to make sure the drive is accessible before creating the pagefile. Choices:
|
Notes
Note
There is difference between automatic managed pagefiles that configured once for the entire system and system managed pagefile that configured per pagefile.
InitialSize 0 and MaximumSize 0 means the pagefile is managed by the system.
Value out of range exception may be caused by several different issues, two common problems - No such drive, Pagefile size is too small.
Setting a pagefile when AutomaticManagedPagefile is on will disable the AutomaticManagedPagefile.
Examples
- name: Query pagefiles configuration
community.windows.win_pagefile:
- name: Query C pagefile
community.windows.win_pagefile:
drive: C
- name: Set C pagefile, don't override if exists
community.windows.win_pagefile:
drive: C
initial_size: 1024
maximum_size: 1024
override: no
state: present
- name: Set C pagefile, override if exists
community.windows.win_pagefile:
drive: C
initial_size: 1024
maximum_size: 1024
state: present
- name: Remove C pagefile
community.windows.win_pagefile:
drive: C
state: absent
- name: Remove all current pagefiles, enable AutomaticManagedPagefile and query at the end
community.windows.win_pagefile:
remove_all: yes
automatic: yes
- name: Remove all pagefiles disable AutomaticManagedPagefile and set C pagefile
community.windows.win_pagefile:
drive: C
initial_size: 2048
maximum_size: 2048
remove_all: yes
automatic: no
state: present
- name: Set D pagefile, override if exists
community.windows.win_pagefile:
drive: d
initial_size: 1024
maximum_size: 1024
state: present
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Whether the pagefiles is automatically managed. Returned: When state is query. Sample: true |
|
Contains caption, description, initial_size, maximum_size and name for each pagefile in the system. Returned: When state is query. Sample: [{“caption”: “c:\\ \u0027pagefile.sys\u0027”, “description”: “\u0027pagefile.sys\u0027 @ c:\\”, “initial_size”: 2048, “maximum_size”: 2048, “name”: “c:\\pagefile.sys”}, {“caption”: “d:\\ \u0027pagefile.sys\u0027”, “description”: “\u0027pagefile.sys\u0027 @ d:\\”, “initial_size”: 1024, “maximum_size”: 1024, “name”: “d:\\pagefile.sys”}] |
Authors
Liran Nisanov (@LiranNis)