mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-22 00:00:22 -07:00
azure windows: changed pagefile to dynamically get the path (#35376)
This commit is contained in:
parent
b1d14d5b06
commit
ea7d29e262
4 changed files with 80 additions and 13 deletions
|
@ -465,17 +465,34 @@
|
|||
failed_when: "win_stat_no_args.msg != 'Get-AnsibleParam: Missing required argument: path'"
|
||||
|
||||
# https://github.com/ansible/ansible/issues/30258
|
||||
- name: get path of pagefile
|
||||
win_shell: |
|
||||
$pagefile = $null
|
||||
$cs = Get-CimInstance -ClassName Win32_ComputerSystem
|
||||
if ($cs.AutomaticManagedPagefile) {
|
||||
$pagefile = "$($env:SystemRoot.Substring(0, 1)):\pagefile.sys"
|
||||
} else {
|
||||
$pf = Get-CimInstance -ClassName Win32_PageFileSetting
|
||||
if ($pf -ne $null) {
|
||||
$pagefile = $pf[0].Name
|
||||
}
|
||||
}
|
||||
$pagefile
|
||||
register: pagefile_path
|
||||
|
||||
- name: get stat of pagefile
|
||||
win_stat:
|
||||
path: C:\pagefile.sys
|
||||
path: '{{pagefile_path.stdout_lines[0]}}'
|
||||
get_md5: no
|
||||
get_checksum: no
|
||||
register: pagefile_stat
|
||||
when: pagefile_path.stdout_lines|count != 0
|
||||
|
||||
- name: assert get stat of pagefile
|
||||
assert:
|
||||
that:
|
||||
- pagefile_stat.stat.exists == True
|
||||
when: pagefile_path.stdout_lines|count != 0
|
||||
|
||||
# Tests with normal user
|
||||
- set_fact:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue