From 7ee89d4ac6284b044a696c08d338303810cbc264 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Fri, 15 Mar 2019 16:48:18 +1000 Subject: [PATCH] win_chocolatey Fix incompatibilities with latest Chocolcatey release --- changelogs/fragments/win_chocolatey-update.yaml | 2 ++ lib/ansible/modules/windows/win_chocolatey.ps1 | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/win_chocolatey-update.yaml diff --git a/changelogs/fragments/win_chocolatey-update.yaml b/changelogs/fragments/win_chocolatey-update.yaml new file mode 100644 index 00000000000..ed0f6c0a0ce --- /dev/null +++ b/changelogs/fragments/win_chocolatey-update.yaml @@ -0,0 +1,2 @@ +bugfixes: +- win_chocolatey - Fix incompatibilities with the latest release of Chocolatey ``v0.10.12+`` diff --git a/lib/ansible/modules/windows/win_chocolatey.ps1 b/lib/ansible/modules/windows/win_chocolatey.ps1 index df590b7ba82..d185f91ab5a 100644 --- a/lib/ansible/modules/windows/win_chocolatey.ps1 +++ b/lib/ansible/modules/windows/win_chocolatey.ps1 @@ -155,7 +155,8 @@ Function Choco-IsInstalled Fail-Json -obj $result -message "Error checking installation status for package 'package': $($_.Exception.Message)" } - if ($LastExitCode -ne 0) { + # Chocolatey v0.10.12 introduced enhanced exit codes, 2 means no results, e.g. no package + if ($LastExitCode -notin @(0, 2)) { $result.rc = $LastExitCode $result.command = "$script:executable list $options" $result.stdout = $output | Out-String