summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimFicarra <JimFicarra@users.noreply.github.com>2017-01-26 19:32:49 -0500
committerMatt Davis <nitzmahone@users.noreply.github.com>2017-01-26 16:32:49 -0800
commit2a27176d7c5e7a9216b569a24579a214aa2a2cee (patch)
tree57472802621d4ea84815351bba67859b0050579a
parent5503b898318bcdb79663f6e34f92f75d89f42287 (diff)
downloadansible-2a27176d7c5e7a9216b569a24579a214aa2a2cee.tar.gz
Add feature - win_package - allow non-zero return codes - Issue #20408 (#20410)
-rw-r--r--lib/ansible/modules/windows/win_package.ps11
-rw-r--r--lib/ansible/modules/windows/win_package.py26
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/ansible/modules/windows/win_package.ps1 b/lib/ansible/modules/windows/win_package.ps1
index fd161dd986..5d4a14ab0d 100644
--- a/lib/ansible/modules/windows/win_package.ps1
+++ b/lib/ansible/modules/windows/win_package.ps1
@@ -850,6 +850,7 @@ function Set-TargetResource
if($process)
{
$exitCode = $process.ExitCode
+ Set-Attr -obj $result -name "exit_code" -value $exitCode
}
}
}
diff --git a/lib/ansible/modules/windows/win_package.py b/lib/ansible/modules/windows/win_package.py
index b20e1c4a47..bea20fe675 100644
--- a/lib/ansible/modules/windows/win_package.py
+++ b/lib/ansible/modules/windows/win_package.py
@@ -74,6 +74,12 @@ options:
- Password of an account with access to the package if it's located on a file share. Only needed if the winrm user doesn't have access to the package. Also specify user_name for this to function properly.
default: null
required: false
+ expected_return_code:
+ description:
+ - One or more return codes from the package installation that indicates success.
+ - If not provided, defaults to 0
+ required: no
+ default: 0
'''
EXAMPLES = r'''
@@ -94,4 +100,24 @@ EXAMPLES = r'''
path: https://download.microsoft.com/download/A/F/0/AF0071F3-B198-4A35-AA90-C68D103BDCCF/rdcman.msi
product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}'
state: absent
+
+# Specify the expected non-zero return code when successful
+# In this case 3010 indicates 'reboot required'
+- name: 'Microsoft .NET Framework 4.5.1'
+ win_package:
+ path: https://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe
+ productid: '{7DEBE4EB-6B40-3766-BB35-5CBBC385DA37}'
+ arguments: '/q /norestart'
+ ensure: present
+ expected_return_code: 3010
+
+# Specify multiple non-zero return codes when successful
+# In this case we can say that both 0 (SUCCESSFUL) and 3010 (REBOOT REQUIRED) codes are acceptable
+ - name: 'Microsoft .NET Framework 4.5.1'
+ win_package:
+ path: https://download.microsoft.com/download/1/6/7/167F0D79-9317-48AE-AEDB-17120579F8E2/NDP451-KB2858728-x86-x64-AllOS-ENU.exe
+ productid: '{7DEBE4EB-6B40-3766-BB35-5CBBC385DA37}'
+ arguments: '/q /norestart'
+ ensure: present
+ expected_return_code: [0,3010]
'''