From a2f9e0d2fe3d3a55bfb278335c03387bbc2486a1 Mon Sep 17 00:00:00 2001 From: nitzmahone Date: Wed, 17 Aug 2016 15:47:44 -0700 Subject: [PATCH] isolate chocolatey bootstrapper execution fixes #2742 added output capture/return, exit code check to bootstrapper exec --- lib/ansible/modules/extras/windows/win_chocolatey.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/windows/win_chocolatey.ps1 b/lib/ansible/modules/extras/windows/win_chocolatey.ps1 index e725519b99..bf5418abbe 100644 --- a/lib/ansible/modules/extras/windows/win_chocolatey.ps1 +++ b/lib/ansible/modules/extras/windows/win_chocolatey.ps1 @@ -59,7 +59,12 @@ Function Chocolatey-Install-Upgrade if ($ChocoAlreadyInstalled -eq $null) { #We need to install chocolatey - iex ((new-object net.webclient).DownloadString("https://chocolatey.org/install.ps1")) + $install_output = (new-object net.webclient).DownloadString("https://chocolatey.org/install.ps1") | powershell - + if ($LASTEXITCODE -ne 0) + { + Set-Attr $result "choco_bootstrap_output" $install_output + Fail-Json $result "Chocolatey bootstrap installation failed." + } $result.changed = $true $script:executable = "C:\ProgramData\chocolatey\bin\choco.exe" }