runas + async - get working on older hosts (#41772)

* runas + async - get working on older hosts

* fixed up sanity issues

* Moved first task to end of test for CI race issues

* Minor change to async test to be more stable, change to runas become to not touch the disk

* moved async test back to normal spot
This commit is contained in:
Jordan Borean 2018-06-26 14:40:49 +10:00 committed by GitHub
commit 2af36412f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 186 additions and 640 deletions

View file

@ -22,7 +22,7 @@
- name: async poll immediate success
async_test:
sleep_delay_sec: 0
async: 10
async: 20
poll: 1
register: asyncresult
@ -59,7 +59,7 @@
- name: async poll retry
async_test:
sleep_delay_sec: 5
async: 10
async: 20
poll: 1
register: asyncresult
@ -94,8 +94,8 @@
- name: async poll timeout
async_test:
sleep_delay_sec: 5
async: 3
sleep_delay_sec: 25
async: 20
poll: 1
register: asyncresult
ignore_errors: true
@ -146,7 +146,7 @@
- name: echo some non ascii characters
win_command: cmd.exe /c echo über den Fußgängerübergang gehen
async: 10
async: 20
poll: 1
register: nonascii_output

View file

@ -189,37 +189,16 @@
- whoami_out.label.sid == 'S-1-16-16384'
- whoami_out.logon_type == 'Service'
# Test out Async on Windows Server 2012+
- name: get OS version
win_shell: |
$version = [System.Environment]::OSVersion.Version
if ($version -ge [Version]"6.2") {
"async"
} elseif ($version -lt [Version]"6.1") {
"old-gramps"
} else {
""
}
register: os_version
- name: test become + async on older hosts
- name: test become + async
vars: *become_vars
win_command: whoami
async: 10
register: whoami_out
ignore_errors: yes
- name: verify older hosts failed with become + async
assert:
that:
- whoami_out is failed
when: os_version.stdout_lines[0] != "async"
- name: verify newer hosts worked with become + async
- name: verify become + async worked
assert:
that:
- whoami_out is successful
when: os_version.stdout_lines[0] == "async"
- name: test failure with string become invalid key
vars: *become_vars
@ -244,12 +223,24 @@
failed_when: "failed_flags_invalid_flag.msg != \"Failed to parse become_flags 'logon_flags=with_profile,invalid': become_flags logon_flags value 'invalid' is not valid, valid values are: with_profile, netcredentials_only\""
# Server 2008 doesn't work with network and network_cleartext, there isn't really a reason why you would want this anyway
- name: check if we are running on a dinosaur, neanderthal or an OS of the modern age
win_shell: |
$version = [System.Environment]::OSVersion.Version
if ($version -lt [Version]"6.1") {
"dinosaur"
} elseif ($version -lt [Version]"6.2") {
"neanderthal"
} else {
"False"
}
register: os_version
- name: become different types
vars: *become_vars
win_whoami:
become_flags: logon_type={{item.type}}
register: become_logon_type
when: not ((item.type == 'network' or item.type == 'network_cleartext') and os_version.stdout_lines[0] == "old-gramps")
when: not ((item.type == 'network' or item.type == 'network_cleartext') and os_version.stdout_lines[0] == "dinosaur")
failed_when: become_logon_type.logon_type != item.actual and become_logon_type.sid != user_limited_result.sid
with_items:
- type: interactive
@ -298,6 +289,7 @@
become_flags: logon_flags={{item.flags}}
register: become_logon_flags
failed_when: become_logon_flags.stdout_lines[0]|bool != item.actual
when: os_version.stdout_lines[0] not in ["dinosaur", "neanderthal"] # usual suspect 2008 doesn't support the no profile flags
with_items:
- flags:
actual: False