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