From a60c051952c11721df5d85e4d9e150f9d570efef Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 27 Jan 2017 16:30:51 +0100 Subject: [PATCH] win_ping: Make full-functional Small cleanup and backport `ping` functionality. --- lib/ansible/modules/windows/win_ping.ps1 | 16 +++++++++++----- lib/ansible/modules/windows/win_ping.py | 8 +++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/windows/win_ping.ps1 b/lib/ansible/modules/windows/win_ping.ps1 index a4dd60ef19..8a1c453980 100644 --- a/lib/ansible/modules/windows/win_ping.ps1 +++ b/lib/ansible/modules/windows/win_ping.ps1 @@ -17,13 +17,19 @@ # WANT_JSON # POWERSHELL_COMMON -$params = Parse-Args $args $true; +$ErrorActionPreference = "Stop" -$data = Get-Attr $params "data" "pong"; +$params = Parse-Args $args -supports_check_mode $true -$result = New-Object psobject @{ +$data = Get-AnsibleParam -obj $params -name "data" -type "str" -default "pong" + +if ($data -eq "crash") { + throw "boom" +} + +$result = @{ changed = $false ping = $data -}; +} -Exit-Json $result; +Exit-Json $result diff --git a/lib/ansible/modules/windows/win_ping.py b/lib/ansible/modules/windows/win_ping.py index e2e0fd98e3..744553b56c 100644 --- a/lib/ansible/modules/windows/win_ping.py +++ b/lib/ansible/modules/windows/win_ping.py @@ -36,9 +36,7 @@ options: data: description: - Alternate data to return instead of 'pong' - required: false default: 'pong' - aliases: [] author: "Chris Church (@cchurch)" ''' @@ -47,6 +45,10 @@ EXAMPLES = r''' ansible winserver -m win_ping # Example from an Ansible Playbook -- action: win_ping +- win_ping: + +# Induce a crash to see what happens +- win_ping: + data: crash '''