mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
0d9f9a246f
* Adds win_pagefile module * Fixed win_pagefile doc * Fix win_pagefile doc * Fix win_pagefile doc variable convention * Added check_mode * Changed win_pagefile module&doc to the convention * added win_pagefile integration tests * Changed check_mode blocks to whatif, fixed a bug * Added whatif to set-wmiinstance, changed docs Added whatif in Set-WMIInstance Added dots to end of decription lines * Returns to original state at the end, more tests Added override and no override integration tests Pagefiles now return to same state as before at the end of the integration test * Remove extra line * Added test_path var to win_pagefile * Set test_path as 'no' in integration * Added unit to docs and enclosed exception message * More granular try-catch blocks * Added workaround to avoid value out of range * Deleted wrong line ending * Changed license to one-line * Removed space in line ending * Try to fix python2.6 error * Try 2 to fix python2.6 error * Add separating line again
220 lines
5.2 KiB
YAML
220 lines
5.2 KiB
YAML
---
|
|
# Get current pagefiles status
|
|
- name: Get original pagefile settings
|
|
win_pagefile:
|
|
state: query
|
|
register: original_pagefile_settings
|
|
|
|
# Test 1: Set c pagefile with inital and maximum size
|
|
- name: Set C pagefile as 1024-2048MB
|
|
win_pagefile:
|
|
remove_all: yes
|
|
drive: C
|
|
initial_size: 1024
|
|
maximum_size: 2048
|
|
override: yes
|
|
state: present
|
|
register: c_pagefile
|
|
|
|
- name: Test set c pagefile
|
|
assert:
|
|
that:
|
|
- c_pagefile.changed == true
|
|
|
|
- name: Query all pagefiles
|
|
win_pagefile:
|
|
state: query
|
|
register: pagefiles_query
|
|
|
|
- name: Set fact for pagefile expected result
|
|
set_fact:
|
|
expected:
|
|
pagefiles:
|
|
- caption: "C:\\ 'pagefile.sys'"
|
|
description: "'pagefile.sys' @ C:\\"
|
|
initial_size: 1024
|
|
maximum_size: 2048
|
|
name: "C:\\pagefile.sys"
|
|
|
|
- name: Test query - c pagefile 1024-2048
|
|
assert:
|
|
that:
|
|
- pagefiles_query.changed == false
|
|
- pagefiles_query.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
|
|
# Test 2: Remove c pagefile
|
|
- name: Remove C pagefile
|
|
win_pagefile:
|
|
drive: C
|
|
state: absent
|
|
register: delete_c_pagefile
|
|
|
|
- name: Test removal of c pagefile
|
|
assert:
|
|
that:
|
|
- delete_c_pagefile.changed == true
|
|
|
|
- name: Query all pagefiles
|
|
win_pagefile:
|
|
state: query
|
|
register: pagefiles_query
|
|
|
|
- name: Set fact for pagefile expected result
|
|
set_fact:
|
|
expected:
|
|
pagefiles: []
|
|
|
|
- name: Test query - no c pagefile
|
|
assert:
|
|
that:
|
|
- pagefiles_query.changed == false
|
|
- pagefiles_query.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
|
|
# Test 3: Set automatic managed pagefile as true
|
|
- name: Set automatic managed pagefiles as true
|
|
win_pagefile:
|
|
automatic: yes
|
|
register: set_automatic_true
|
|
|
|
- name: Test removal of c pagefile
|
|
assert:
|
|
that:
|
|
- set_automatic_true.changed == true
|
|
- set_automatic_true.automatic_managed_pagefiles == true
|
|
|
|
|
|
# Test 4: Set c pagefile as system managed pagefile
|
|
- name: Set c pagefile as system managed pagefile
|
|
win_pagefile:
|
|
drive: C
|
|
system_managed: yes
|
|
state: present
|
|
register: c_pagefile_system_managed
|
|
|
|
- name: Test set c pagefile as system managed
|
|
assert:
|
|
that:
|
|
- c_pagefile_system_managed.changed == true
|
|
|
|
- name: Query all pagefiles
|
|
win_pagefile:
|
|
state: query
|
|
register: pagefiles_query
|
|
|
|
- name: Set fact for pagefile expected result
|
|
set_fact:
|
|
expected:
|
|
pagefiles:
|
|
- caption: "C:\\ 'pagefile.sys'"
|
|
description: "'pagefile.sys' @ C:\\"
|
|
initial_size: 0
|
|
maximum_size: 0
|
|
name: "C:\\pagefile.sys"
|
|
|
|
- name: Test query - c pagefile 0-0 (system managed)
|
|
assert:
|
|
that:
|
|
- pagefiles_query.changed == false
|
|
- pagefiles_query.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
# Test 5: Test no override
|
|
- name: Set c pagefile 1024-1024, no override
|
|
win_pagefile:
|
|
drive: C
|
|
initial_size: 1024
|
|
maximum_size: 1024
|
|
override: no
|
|
state: present
|
|
register: c_pagefile_no_override
|
|
|
|
- name: Test set c pagefile no override
|
|
assert:
|
|
that:
|
|
- c_pagefile_no_override.changed == false
|
|
|
|
- name: Query all pagefiles
|
|
win_pagefile:
|
|
state: query
|
|
register: pagefiles_query
|
|
|
|
- name: Test query - c pagefile unchanged
|
|
assert:
|
|
that:
|
|
- pagefiles_query.changed == false
|
|
- pagefiles_query.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
|
|
# Test 6: Test override
|
|
- name: Set c pagefile 1024-1024, override
|
|
win_pagefile:
|
|
drive: C
|
|
initial_size: 1024
|
|
maximum_size: 1024
|
|
state: present
|
|
register: c_pagefile_override
|
|
|
|
- name: Test set c pagefile no override
|
|
assert:
|
|
that:
|
|
- c_pagefile_override.changed == true
|
|
|
|
- name: Query all pagefiles
|
|
win_pagefile:
|
|
state: query
|
|
register: pagefiles_query
|
|
|
|
- name: Set fact for pagefile expected result
|
|
set_fact:
|
|
expected:
|
|
pagefiles:
|
|
- caption: "C:\\ 'pagefile.sys'"
|
|
description: "'pagefile.sys' @ C:\\"
|
|
initial_size: 1024
|
|
maximum_size: 1024
|
|
name: "C:\\pagefile.sys"
|
|
|
|
- name: Test query - c pagefile 1024-1024
|
|
assert:
|
|
that:
|
|
- pagefiles_query.changed == false
|
|
- pagefiles_query.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
# Test 7: Remove all pagefiles
|
|
- name: Remove all pagefiles
|
|
win_pagefile:
|
|
remove_all: true
|
|
register: remove_all_pagefiles
|
|
|
|
- name: Set fact for pagefile expected result
|
|
set_fact:
|
|
expected:
|
|
pagefiles: []
|
|
|
|
- name: Test query - no pagefiles
|
|
assert:
|
|
that:
|
|
- remove_all_pagefiles.changed == true
|
|
- remove_all_pagefiles.pagefiles == expected.pagefiles
|
|
- pagefiles_query.automatic_managed_pagefiles == false
|
|
|
|
# Return all pagefile settings to its original state
|
|
- name: Remove all pagefiles and return automatic to its original state
|
|
win_pagefile:
|
|
remove_all: yes
|
|
automatic: "{{ original_pagefile_settings.automatic_managed_pagefiles }}"
|
|
|
|
- name: Return all previous pagefiles settings
|
|
win_pagefile:
|
|
drive: "{{ item.name[0] }}"
|
|
initial_size: "{{ item.initial_size }}"
|
|
maximum_size: "{{ item.maximum_size }}"
|
|
test_path: no
|
|
state: present
|
|
with_items: "{{ original_pagefile_settings.pagefiles }}"
|