Use shared remote_tmp_dir to simplfy tests (#53721)

pull/53765/head
Jordan Borean 6 years ago committed by GitHub
parent d9795bad98
commit b044bb431e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir

@ -1,31 +1,20 @@
- name: Download PSTools - name: Download PsExec
win_get_url: win_get_url:
url: https://download.sysinternals.com/files/PSTools.zip url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/win_psexec/PsExec.exe
dest: C:\Windows\Temp\PSTools.zip dest: '{{ remote_tmp_dir }}\PsExec.exe'
force: no
- name: Create sysinternals directory - name: Get the existing PATH env var
win_file: win_shell: '$env:PATH'
path: C:\Windows\Temp\sysinternals register: system_path
state: directory changed_when: False
- name: Unzip PSTools
win_unzip:
src: C:\Windows\Temp\PSTools.zip
dest: C:\Windows\Temp\sysinternals
- name: Add sysinternals to PATH
win_path:
name: PATH
elements: C:\Windows\Temp\sysinternals
scope: machine
state: present
- name: Run whoami - name: Run whoami
win_psexec: win_psexec:
command: whoami.exe command: whoami.exe
nobanner: true nobanner: true
register: whoami register: whoami
environment:
PATH: '{{ remote_tmp_dir }};{{ system_path.stdout | trim }}'
- name: Test whoami - name: Test whoami
assert: assert:
@ -40,6 +29,7 @@
command: whoami.exe command: whoami.exe
system: yes system: yes
nobanner: true nobanner: true
executable: '{{ remote_tmp_dir }}\PsExec.exe'
register: whoami_as_system register: whoami_as_system
# Seems to be a bug with PsExec where the stdout can be empty, just retry the task to make this test a bit more stable # Seems to be a bug with PsExec where the stdout can be empty, just retry the task to make this test a bit more stable
until: whoami_as_system.rc == 0 and whoami_as_system.stdout == 'nt authority\system' until: whoami_as_system.rc == 0 and whoami_as_system.stdout == 'nt authority\system'
@ -70,26 +60,11 @@
command: powershell.exe -NonInteractive "exit 1" command: powershell.exe -NonInteractive "exit 1"
ignore_errors: yes ignore_errors: yes
register: whoami_multiple_args register: whoami_multiple_args
environment:
PATH: '{{ remote_tmp_dir }};{{ system_path.stdout | trim }}'
- name: Test command with multiple argumetns - name: Test command with multiple argumetns
assert: assert:
that: that:
- whoami_multiple_args.rc == 1 - whoami_multiple_args.rc == 1
- whoami_multiple_args.psexec_command == "psexec.exe -accepteula powershell.exe -NonInteractive \"exit 1\"" - whoami_multiple_args.psexec_command == "psexec.exe -accepteula powershell.exe -NonInteractive \"exit 1\""
- name: Remove sysinternals from PATH
win_path:
name: PATH
elements: C:\Windows\Temp\sysinternals
scope: machine
state: absent
- name: Remove sysinternals directory
win_file:
path: C:\Windows\Temp\sysinternals
state: absent
- name: Remove sysinternals directory
win_file:
path: C:\Windows\Temp\PSTools.zip
state: absent

Loading…
Cancel
Save