JM: allow choco to install 32 bit version (#42946)

* JM: allow choco to install 32 bit version

* JM: style corrections

* Revert style changes in lists

* JM: changing from boolean to string choice

* JM: updating example
pull/43014/head
Jez McKinley 6 years ago committed by Jordan Borean
parent f89d3721b4
commit 0f6488bb15

@ -33,6 +33,7 @@ $skipscripts = Get-AnsibleParam -obj $params -name "skip_scripts" -type "bool" -
$proxy_url = Get-AnsibleParam -obj $params -name "proxy_url" -type "str"
$proxy_username = Get-AnsibleParam -obj $params -name "proxy_username" -type "str"
$proxy_password = Get-AnsibleParam -obj $params -name "proxy_password" -type "str" -failifempty ($proxy_username -ne $null)
$architecture = Get-AnsibleParam -obj $params -name "architecture" -type "str" -default "default" -validateset "default","x86"
$result = @{
changed = $false
@ -192,7 +193,8 @@ Function Choco-Upgrade
[bool] $allowprerelease,
[string] $proxy_url,
[string] $proxy_username,
[string] $proxy_password
[string] $proxy_password,
[string] $architecture
)
if (-not (Choco-IsInstalled $package))
@ -202,6 +204,10 @@ Function Choco-Upgrade
$options = @( "-y", $package, "--timeout", "$timeout", "--failonunfound" )
switch ($architecture) {
"x86" { $options += "--x86" ; break}
}
if ($check_mode)
{
$options += "--whatif"
@ -306,6 +312,7 @@ Function Choco-Upgrade
$result.failed = $false
}
Function Choco-Install
{
[CmdletBinding()]
@ -327,7 +334,8 @@ Function Choco-Install
[bool] $allowprerelease,
[string] $proxy_url,
[string] $proxy_username,
[string] $proxy_password
[string] $proxy_password,
[string] $architecture
)
if (Choco-IsInstalled $package)
@ -340,7 +348,7 @@ Function Choco-Install
-ignorechecksums $ignorechecksums -ignoredependencies $ignoredependencies `
-allowdowngrade $allowdowngrade -proxy_url $proxy_url `
-proxy_username $proxy_username -proxy_password $proxy_password `
-allowprerelease $allowprerelease
-allowprerelease $allowprerelease -architecture $architecture
return
}
elseif (-not $force)
@ -351,6 +359,10 @@ Function Choco-Install
$options = @( "-y", $package, "--timeout", "$timeout", "--failonunfound" )
switch ($architecture) {
"x86" { $options += "--x86" ; break}
}
if ($check_mode)
{
$options += "--whatif"
@ -529,7 +541,7 @@ if ($state -in ("downgrade", "latest", "present", "reinstalled")) {
-ignorechecksums $ignorechecksums -ignoredependencies $ignoredependencies `
-allowdowngrade ($state -eq "downgrade") -proxy_url $proxy_url `
-proxy_username $proxy_username -proxy_password $proxy_password `
-allowprerelease $allowprerelease
-allowprerelease $allowprerelease -architecture $architecture
}
Exit-Json -obj $result

@ -51,6 +51,15 @@ options:
source:
description:
- Specify source rather than using default chocolatey repository.
architecture:
description:
- Allows installation of alternative architecture packages, for example,
32bit on 64bit windows.
version_added: '2.7'
choices:
- default
- x86
default: default
install_args:
description:
- Arguments to pass to the native installer.
@ -154,6 +163,11 @@ EXAMPLES = r'''
name: notepadplusplus
version: '6.6'
- name: Install notepadplusplus 32 bit version
win_chocolatey:
name: notepadplusplus
architecture: 'x86'
- name: Install git from specified repository
win_chocolatey:
name: git

Loading…
Cancel
Save