From 07154308292e11696dfb77dbc551b932e90458b8 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 4 Apr 2017 18:39:27 +0200 Subject: [PATCH] win_chocolatey: Perform exact presence check (#23098) The current implementation matches libreoffice-oldstable when testing for libreoffice. So uninstalling libreoffice fails when libreoffice-oldstable is installed. ``` PS C:\WINDOWS\system32> choco list --local-only libreoffice Chocolatey v0.10.3 libreoffice-oldstable 5.2.6 1 packages installed. PS C:\WINDOWS\system32> choco list --local-only --exact libreoffice Chocolatey v0.10.3 0 packages installed. ``` The solution is easy, just add `--exact`. --- lib/ansible/modules/windows/win_chocolatey.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/windows/win_chocolatey.ps1 b/lib/ansible/modules/windows/win_chocolatey.ps1 index 562beab2df2..a04fe49f4ed 100644 --- a/lib/ansible/modules/windows/win_chocolatey.ps1 +++ b/lib/ansible/modules/windows/win_chocolatey.ps1 @@ -100,7 +100,7 @@ Function Choco-IsInstalled [string]$package ) - $cmd = "$executable list --local-only $package" + $cmd = "$executable list --local-only --exact $package" $output = invoke-expression $cmd $result.rc = $LastExitCode @@ -249,7 +249,7 @@ Function Choco-Install if (Choco-IsInstalled $package) { - if ($upgrade) + if ($state -eq "latest") { Choco-Upgrade -package $package -version $version -source $source -force $force ` -installargs $installargs -packageparams $packageparams `