Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
0c938562
Commit
0c938562
authored
Jun 17, 2014
by
Chris Church
Committed by
Matt Martz
Jun 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add winrm integration tests for raw, script and ping modules.
parent
fa0943a9
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
241 additions
and
0 deletions
+241
-0
test/integration/Makefile
+3
-0
test/integration/README.md
+20
-0
test/integration/inventory.winrm.template
+7
-0
test/integration/roles/test_win_ping/tasks/main.yml
+66
-0
test/integration/roles/test_win_raw/tasks/main.yml
+56
-0
test/integration/roles/test_win_script/files/test_script.bat
+2
-0
test/integration/roles/test_win_script/files/test_script.ps1
+2
-0
test/integration/roles/test_win_script/files/test_script_with_args.ps1
+7
-0
test/integration/roles/test_win_script/files/test_script_with_errors.ps1
+11
-0
test/integration/roles/test_win_script/tasks/main.yml
+59
-0
test/integration/test_winrm.yml
+8
-0
No files found.
test/integration/Makefile
View file @
0c938562
...
@@ -46,6 +46,9 @@ test_vault:
...
@@ -46,6 +46,9 @@ test_vault:
ansible-playbook test_vault.yml
-i
$(INVENTORY)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
--vault-password-file
$(VAULT_PASSWORD_FILE)
--syntax-check
ansible-playbook test_vault.yml
-i
$(INVENTORY)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
--vault-password-file
$(VAULT_PASSWORD_FILE)
--syntax-check
ansible-playbook test_vault.yml
-i
$(INVENTORY)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
--vault-password-file
$(VAULT_PASSWORD_FILE)
ansible-playbook test_vault.yml
-i
$(INVENTORY)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
--vault-password-file
$(VAULT_PASSWORD_FILE)
test_winrm
:
ansible-playbook test_winrm.yml
-i
inventory.winrm
-e
@
$(VARS_FILE)
$(CREDENTIALS_ARG)
-v
$(TEST_FLAGS)
cloud
:
amazon rackspace
cloud
:
amazon rackspace
cloud_cleanup
:
amazon_cleanup rackspace_cleanup
cloud_cleanup
:
amazon_cleanup rackspace_cleanup
...
...
test/integration/README.md
View file @
0c938562
...
@@ -70,3 +70,23 @@ resources. Running these tests may result in additional fees associated with
...
@@ -70,3 +70,23 @@ resources. Running these tests may result in additional fees associated with
your cloud account. Care is taken to ensure that created resources are
your cloud account. Care is taken to ensure that created resources are
removed. However, it is advisable to inspect your AWS console to ensure no
removed. However, it is advisable to inspect your AWS console to ensure no
unexpected resources are running.
unexpected resources are running.
Windows Tests
=============
These tests exercise the winrm connection plugin and Windows modules. You'll
need to define an inventory with a remote Windows 2008 or 2012 Server to use
for testing, and enable PowerShell Remoting to continue.
Running these tests may result in changes to your Windows host, so don't run
them against a production/critical Windows environment.
Enable PowerShell Remoting (run on the Windows host via Remote Desktop):
Enable-PSRemoting -Force
Define Windows inventory:
cp inventory.winrm.template inventory.winrm
${EDITOR:-vi} inventory.winrm
Run the tests:
make test_winrm
test/integration/inventory.winrm.template
0 → 100644
View file @
0c938562
[windows]
server ansible_ssh_host=10.10.10.10 ansible_ssh_user=Administrator ansible_ssh_pass=ShhhDontTellAnyone
[windows:vars]
ansible_connection=winrm
# HTTPS uses 5986, HTTP uses 5985
ansible_ssh_port=5985
test/integration/roles/test_win_ping/tasks/main.yml
0 → 100644
View file @
0c938562
---
-
name
:
test win_ping
action
:
win_ping
register
:
win_ping_result
-
name
:
check win_ping result
assert
:
that
:
-
"
not
win_ping_result|failed"
-
"
not
win_ping_result|changed"
-
"
win_ping_result.ping
==
'pong'"
-
name
:
test win_ping with data
win_ping
:
data=blah
register
:
win_ping_with_data_result
-
name
:
check win_ping result with data
assert
:
that
:
-
"
not
win_ping_with_data_result|failed"
-
"
not
win_ping_with_data_result|changed"
-
"
win_ping_with_data_result.ping
==
'blah'"
-
name
:
test ping.ps1 with data
ping.ps1
:
data=bleep
register
:
ping_ps1_result
-
name
:
check ping.ps1 result
assert
:
that
:
-
"
not
ping_ps1_result|failed"
-
"
not
ping_ps1_result|changed"
-
"
ping_ps1_result.ping
==
'bleep'"
#- name: test ping.ps1 with invalid args
# ping.ps1: arg=invalid
# register: ping_ps1_invalid_args_result
#- name: check that ping.ps1 with invalid args fails
# assert:
# that:
# - "ping_ps1_invalid_args_result|failed"
# - "ping_ps1_invalid_args_result.msg"
-
name
:
test local ping (should use default ping)
local_action
:
ping
register
:
local_ping_result
-
name
:
check local ping result
assert
:
that
:
-
"
not
local_ping_result|failed"
-
"
not
local_ping_result|changed"
-
"
local_ping_result.ping
==
'pong'"
-
name
:
test ping (should use ping.ps1)
action
:
ping
register
:
ping_result
-
name
:
check ping result
assert
:
that
:
-
"
not
ping_result|failed"
-
"
not
ping_result|changed"
-
"
ping_result.ping
==
'pong'"
test/integration/roles/test_win_raw/tasks/main.yml
0 → 100644
View file @
0c938562
---
-
name
:
run getmac
raw
:
getmac
register
:
getmac_result
-
name
:
assert that getmac ran
assert
:
that
:
-
"
getmac_result.rc
==
0"
-
"
getmac_result.stdout"
-
"
not
getmac_result.stderr"
-
"
not
getmac_result|failed"
-
"
not
getmac_result|changed"
-
name
:
run ipconfig with /all argument
raw
:
ipconfig /all
register
:
ipconfig_result
-
name
:
assert that ipconfig ran with /all argument
assert
:
that
:
-
"
ipconfig_result.rc
==
0"
-
"
ipconfig_result.stdout"
-
"
'Physical
Address'
in
ipconfig_result.stdout"
-
"
not
ipconfig_result.stderr"
-
"
not
ipconfig_result|failed"
-
"
not
ipconfig_result|changed"
-
name
:
run ipconfig with invalid argument
raw
:
ipconfig /badswitch
register
:
ipconfig_invalid_result
ignore_errors
:
true
-
name
:
assert that ipconfig with invalid argument failed
assert
:
that
:
-
"
ipconfig_invalid_result.rc
!=
0"
-
"
ipconfig_invalid_result.stdout"
# ipconfig displays errors on stdout.
-
"
not
ipconfig_invalid_result.stderr"
-
"
ipconfig_invalid_result|failed"
-
"
not
ipconfig_invalid_result|changed"
-
name
:
run an unknown command
raw
:
uname -a
register
:
unknown_result
ignore_errors
:
true
-
name
:
assert that an unknown command failed
assert
:
that
:
-
"
unknown_result.rc
!=
0"
-
"
not
unknown_result.stdout"
-
"
unknown_result.stderr"
# An unknown command displays error on stderr.
-
"
unknown_result|failed"
-
"
not
unknown_result|changed"
test/integration/roles/test_win_script/files/test_script.bat
0 → 100644
View file @
0c938562
@ECHO OFF
ECHO We can even run a batch file!
test/integration/roles/test_win_script/files/test_script.ps1
0 → 100644
View file @
0c938562
# Test script to make sure the Ansible script module works.
Write-Host
"Woohoo! We can run a PowerShell script via Ansible!"
test/integration/roles/test_win_script/files/test_script_with_args.ps1
0 → 100644
View file @
0c938562
# Test script to make sure the Ansible script module works when arguments are
# passed to the script.
foreach
(
$i
in
$args
)
{
Write-Host
$i
;
}
test/integration/roles/test_win_script/files/test_script_with_errors.ps1
0 → 100644
View file @
0c938562
# http://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error
#$ErrorActionPreference = "Stop";
# http://stackoverflow.com/questions/15777492/why-are-my-powershell-exit-codes-always-0
trap
{
Write-Error
-ErrorRecord
$_
exit
1;
}
throw
"Oh noes I has an error"
test/integration/roles/test_win_script/tasks/main.yml
0 → 100644
View file @
0c938562
---
-
name
:
run simple test script
script
:
test_script.ps1
register
:
test_script_result
-
name
:
check that script ran
assert
:
that
:
-
"
test_script_result.rc
==
0"
-
"
test_script_result.stdout"
-
"
'Woohoo'
in
test_script_result.stdout"
-
"
not
test_script_result.stderr"
-
"
not
test_script_result|failed"
-
"
test_script_result|changed"
-
name
:
run test script that takes arguments
script
:
test_script_with_args.ps1 /this /that /other
register
:
test_script_with_args_result
-
name
:
check that script ran and received arguments
assert
:
that
:
-
"
test_script_with_args_result.rc
==
0"
-
"
test_script_with_args_result.stdout"
-
"
test_script_with_args_result.stdout_lines[0]
==
'/this'"
-
"
test_script_with_args_result.stdout_lines[1]
==
'/that'"
-
"
test_script_with_args_result.stdout_lines[2]
==
'/other'"
-
"
not
test_script_with_args_result.stderr"
-
"
not
test_script_with_args_result|failed"
-
"
test_script_with_args_result|changed"
-
name
:
run test script that has errors
script
:
test_script_with_errors.ps1
register
:
test_script_with_errors_result
ignore_errors
:
true
-
name
:
check that script ran but failed with errors
assert
:
that
:
-
"
test_script_with_errors_result.rc
!=
0"
-
"
not
test_script_with_errors_result.stdout"
-
"
test_script_with_errors_result.stderr"
-
"
test_script_with_errors_result|failed"
-
"
test_script_with_errors_result|changed"
-
name
:
run simple batch file
script
:
test_script.bat
register
:
test_batch_result
-
name
:
check that batch file ran
assert
:
that
:
-
"
test_batch_result.rc
==
0"
-
"
test_batch_result.stdout"
-
"
'batch'
in
test_batch_result.stdout"
-
"
not
test_batch_result.stderr"
-
"
not
test_batch_result|failed"
-
"
test_batch_result|changed"
test/integration/test_winrm.yml
0 → 100644
View file @
0c938562
---
-
hosts
:
windows
gather_facts
:
false
roles
:
-
{
role
:
test_win_raw
,
tags
:
test_win_raw
}
-
{
role
:
test_win_script
,
tags
:
test_win_script
}
-
{
role
:
test_win_ping
,
tags
:
test_win_ping
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment