mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Merge pull request #9602 from cchurch/powershell_splatting
Handle PowerShell parameters passed via splatting
This commit is contained in:
commit
07dfbaedc3
5 changed files with 49 additions and 4 deletions
5
test/integration/roles/test_win_script/defaults/main.yml
Normal file
5
test/integration/roles/test_win_script/defaults/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
|
||||
# Parameters to pass to test scripts.
|
||||
test_win_script_value: VaLuE
|
||||
test_win_script_splat: "@{This='THIS'; That='THAT'; Other='OTHER'}"
|
|
@ -0,0 +1,6 @@
|
|||
# Test script to make sure the Ansible script module works when arguments are
|
||||
# passed via splatting (http://technet.microsoft.com/en-us/magazine/gg675931.aspx)
|
||||
|
||||
Write-Host $args.This
|
||||
Write-Host $args.That
|
||||
Write-Host $args.Other
|
|
@ -46,6 +46,38 @@
|
|||
- "not test_script_with_args_result|failed"
|
||||
- "test_script_with_args_result|changed"
|
||||
|
||||
- name: run test script that takes parameters passed via splatting
|
||||
script: test_script_with_splatting.ps1 "@{ This = 'this'; That = '{{ test_win_script_value }}'; Other = 'other'}"
|
||||
register: test_script_with_splatting_result
|
||||
|
||||
- name: check that script ran and received parameters via splatting
|
||||
assert:
|
||||
that:
|
||||
- "test_script_with_splatting_result.rc == 0"
|
||||
- "test_script_with_splatting_result.stdout"
|
||||
- "test_script_with_splatting_result.stdout_lines[0] == 'this'"
|
||||
- "test_script_with_splatting_result.stdout_lines[1] == test_win_script_value"
|
||||
- "test_script_with_splatting_result.stdout_lines[2] == 'other'"
|
||||
- "not test_script_with_splatting_result.stderr"
|
||||
- "not test_script_with_splatting_result|failed"
|
||||
- "test_script_with_splatting_result|changed"
|
||||
|
||||
- name: run test script that takes splatted parameters from a variable
|
||||
script: test_script_with_splatting.ps1 {{ test_win_script_splat|quote }}
|
||||
register: test_script_with_splatting2_result
|
||||
|
||||
- name: check that script ran and received parameters via splatting from a variable
|
||||
assert:
|
||||
that:
|
||||
- "test_script_with_splatting2_result.rc == 0"
|
||||
- "test_script_with_splatting2_result.stdout"
|
||||
- "test_script_with_splatting2_result.stdout_lines[0] == 'THIS'"
|
||||
- "test_script_with_splatting2_result.stdout_lines[1] == 'THAT'"
|
||||
- "test_script_with_splatting2_result.stdout_lines[2] == 'OTHER'"
|
||||
- "not test_script_with_splatting2_result.stderr"
|
||||
- "not test_script_with_splatting2_result|failed"
|
||||
- "test_script_with_splatting2_result|changed"
|
||||
|
||||
- name: run test script that has errors
|
||||
script: test_script_with_errors.ps1
|
||||
register: test_script_with_errors_result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue