community.windows.win_pagefile 模块 – 查询或更改页面文件配置
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用: ansible-galaxy collection install community.windows。
要在剧本中使用它,请指定: community.windows.win_pagefile。
概要
- 查询当前页面文件配置。 
- 启用/禁用 AutomaticManagedPagefile。 
- 创建新的或覆盖页面文件配置。 
参数
| 参数 | 注释 | 
|---|---|
| 为整个系统配置 AutomaticManagedPagefile。 选项 
 | |
| 页面文件的驱动器。 | |
| 页面文件的初始大小(以兆字节为单位)。 | |
| 页面文件最大大小(以兆字节为单位)。 | |
| 覆盖驱动器上的当前页面文件。 选项 
 | |
| 删除系统中的所有页面文件,不包括自动管理的页面文件。 选项 
 | |
| 页面文件的状态。 选项 
 | |
| 将当前页面文件配置为由系统管理。 选项 
 | |
| 在驱动器上使用 Test-Path 以确保驱动器在创建页面文件之前可访问。 选项 
 | 
备注
注意
- 为整个系统配置一次的自动管理页面文件与为每个页面文件配置的系统管理页面文件之间存在差异。 
- InitialSize 为 0 且 MaximumSize 为 0 表示页面文件由系统管理。 
- 超出范围的值异常可能是由几个不同的问题引起的,两个常见的问题是 - 没有这样的驱动器,页面文件大小太小。 
- 当 AutomaticManagedPagefile 启用时设置页面文件将禁用 AutomaticManagedPagefile。 
示例
- 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: false
    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: true
    automatic: true
- name: Remove all pagefiles disable AutomaticManagedPagefile and set C pagefile
  community.windows.win_pagefile:
    drive: C
    initial_size: 2048
    maximum_size: 2048
    remove_all: true
    automatic: false
    state: present
- name: Set D pagefile, override if exists
  community.windows.win_pagefile:
    drive: d
    initial_size: 1024
    maximum_size: 1024
    state: present
返回值
常见的返回值已在此处记录,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 页面文件是否自动管理。 返回:当 state 为 query 时。 示例:  | |
| 包含系统中每个页面文件的标题、描述、initial_size、maximum_size 和名称。 返回:当 state 为 query 时。 示例:  | 
