community.windows.win_pagefile (2.2.0) — module

Query or change pagefile configuration

Authors: Liran Nisanov (@LiranNis)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Query current pagefile configuration.

Enable/Disable AutomaticManagedPagefile.

Create new or override pagefile configuration.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query pagefiles configuration
  community.windows.win_pagefile:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Query C pagefile
  community.windows.win_pagefile:
    drive: C
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set C pagefile, override if exists
  community.windows.win_pagefile:
    drive: C
    initial_size: 1024
    maximum_size: 1024
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove C pagefile
  community.windows.win_pagefile:
    drive: C
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove all current pagefiles, enable AutomaticManagedPagefile and query at the end
  community.windows.win_pagefile:
    remove_all: yes
    automatic: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set D pagefile, override if exists
  community.windows.win_pagefile:
    drive: d
    initial_size: 1024
    maximum_size: 1024
    state: present

Inputs

    
drive:
    description:
    - The drive of the pagefile.
    type: str

state:
    choices:
    - absent
    - present
    - query
    default: query
    description:
    - State of the pagefile.
    type: str

override:
    default: true
    description:
    - Override the current pagefile on the drive.
    type: bool

automatic:
    description:
    - Configures AutomaticManagedPagefile for the entire system.
    type: bool

test_path:
    default: true
    description:
    - Use Test-Path on the drive to make sure the drive is accessible before creating
      the pagefile.
    type: bool

remove_all:
    default: false
    description:
    - Remove all pagefiles in the system, not including automatic managed.
    type: bool

initial_size:
    description:
    - The initial size of the pagefile in megabytes.
    type: int

maximum_size:
    description:
    - The maximum size of the pagefile in megabytes.
    type: int

system_managed:
    default: false
    description:
    - Configures current pagefile to be managed by the system.
    type: bool

Outputs

automatic_managed_pagefiles:
  description: Whether the pagefiles is automatically managed.
  returned: When state is query.
  sample: true
  type: bool
pagefiles:
  description: Contains caption, description, initial_size, maximum_size and name
    for each pagefile in the system.
  returned: When state is query.
  sample:
  - caption: c:\ 'pagefile.sys'
    description: '''pagefile.sys'' @ c:\'
    initial_size: 2048
    maximum_size: 2048
    name: c:\pagefile.sys
  - caption: d:\ 'pagefile.sys'
    description: '''pagefile.sys'' @ d:\'
    initial_size: 1024
    maximum_size: 1024
    name: d:\pagefile.sys
  type: list