From 4bae0256660000fc471f47c746ffd555ae792652 Mon Sep 17 00:00:00 2001 From: Greyeye Date: Fri, 19 Aug 2016 02:46:37 +1000 Subject: [PATCH] pass flag to choco, allowemptychecksums and ignorechecksums (#2722) --- .../modules/extras/windows/win_chocolatey.ps1 | 35 ++++++++++++++++++- .../modules/extras/windows/win_chocolatey.py | 12 +++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/windows/win_chocolatey.ps1 b/lib/ansible/modules/extras/windows/win_chocolatey.ps1 index 546fc7621a4..7a3f14aabc3 100644 --- a/lib/ansible/modules/extras/windows/win_chocolatey.ps1 +++ b/lib/ansible/modules/extras/windows/win_chocolatey.ps1 @@ -37,6 +37,8 @@ $state = Get-Attr -obj $params -name state -default "present" $installargs = Get-Attr -obj $params -name install_args -default $null $packageparams = Get-Attr -obj $params -name params -default $null +$allowemptychecksums = Get-Attr -obj $params -name allow_empty_checksums -default "false" | ConvertTo-Bool +$ignorechecksums = Get-Attr -obj $params -name ignore_checksums -default "false" | ConvertTo-Bool $ignoredependencies = Get-Attr -obj $params -name ignore_dependencies -default "false" | ConvertTo-Bool # as of chocolatey 0.9.10, nonzero success exit codes can be returned @@ -126,6 +128,10 @@ Function Choco-Upgrade [Parameter(Mandatory=$false, Position=6)] [string]$packageparams, [Parameter(Mandatory=$false, Position=7)] + [bool]$allowemptychecksums, + [Parameter(Mandatory=$false, Position=8)] + [bool]$ignorechecksums, + [Parameter(Mandatory=$false, Position=9)] [bool]$ignoredependencies ) @@ -161,6 +167,16 @@ Function Choco-Upgrade $cmd += " -params '$packageparams'" } + if ($allowemptychecksums) + { + $cmd += " --allow-empty-checksums" + } + + if ($ignorechecksums) + { + $cmd += " --ignore-checksums" + } + if ($ignoredependencies) { $cmd += " -ignoredependencies" @@ -204,6 +220,10 @@ Function Choco-Install [Parameter(Mandatory=$false, Position=7)] [string]$packageparams, [Parameter(Mandatory=$false, Position=8)] + [bool]$allowemptychecksums, + [Parameter(Mandatory=$false, Position=9)] + [bool]$ignorechecksums, + [Parameter(Mandatory=$false, Position=10)] [bool]$ignoredependencies ) @@ -213,6 +233,7 @@ Function Choco-Install { Choco-Upgrade -package $package -version $version -source $source -force $force ` -installargs $installargs -packageparams $packageparams ` + -allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums ` -ignoredependencies $ignoredependencies return @@ -251,6 +272,16 @@ Function Choco-Install $cmd += " -params '$packageparams'" } + if ($allowemptychecksums) + { + $cmd += " --allow-empty-checksums" + } + + if ($ignorechecksums) + { + $cmd += " --ignore-checksums" + } + if ($ignoredependencies) { $cmd += " -ignoredependencies" @@ -322,7 +353,8 @@ Try { Choco-Install -package $package -version $version -source $source ` -force $force -upgrade $upgrade -installargs $installargs ` - -packageparams $packageparams -ignoredependencies $ignoredependencies + -packageparams $packageparams -allowemptychecksums $allowemptychecksums ` + -ignorechecksums $ignorechecksums -ignoredependencies $ignoredependencies } else { @@ -336,3 +368,4 @@ Catch Fail-Json $result $_.Exception.Message } + diff --git a/lib/ansible/modules/extras/windows/win_chocolatey.py b/lib/ansible/modules/extras/windows/win_chocolatey.py index a54e5504e2b..4160de2ebe1 100644 --- a/lib/ansible/modules/extras/windows/win_chocolatey.py +++ b/lib/ansible/modules/extras/windows/win_chocolatey.py @@ -80,6 +80,18 @@ options: require: false default: null version_added: '2.1' + allow_empty_checksums: + description: + - Allow empty Checksums to be used + require: false + default: false + version_added: '2.2' + ignore_checksums: + description: + - Ignore Checksums + require: false + default: false + version_added: '2.2' ignore_dependencies: description: - Ignore dependencies, only install/upgrade the package itself