azure windows: changed pagefile to dynamically get the path (#35376)

This commit is contained in:
Jordan Borean 2018-01-26 10:58:49 +10:00 committed by Matt Clay
parent b1d14d5b06
commit ea7d29e262
4 changed files with 80 additions and 13 deletions

View file

@ -77,17 +77,34 @@
- cmdout is skipped
- cmdout.msg is search('exists')
- 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: test creates with hidden system file, should skip
win_command: echo no
args:
creates: C:\pagefile.sys
creates: '{{pagefile_path.stdout_lines[0]}}'
register: cmdout
when: pagefile_path.stdout_lines|count != 0
- name: validate result
assert:
that:
- cmdout is skipped
- cmdout.msg is search('exists')
when: pagefile_path.stdout_lines|count != 0
- name: ensure testfile is still present
win_stat: