Merge pull request #1295 from superquadratic/win_choco_params
win_chocolatey: Add install_args, params and ignoredependencies
This commit is contained in:
commit
22f20ebeed
2 changed files with 69 additions and 11 deletions
|
@ -34,6 +34,11 @@ if ($source) {$source = $source.Tolower()}
|
||||||
|
|
||||||
$showlog = Get-Attr -obj $params -name showlog -default "false" | ConvertTo-Bool
|
$showlog = Get-Attr -obj $params -name showlog -default "false" | ConvertTo-Bool
|
||||||
$state = Get-Attr -obj $params -name state -default "present"
|
$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
|
||||||
|
$ignoredependencies = Get-Attr -obj $params -name ignore_dependencies -default "false" | ConvertTo-Bool
|
||||||
|
|
||||||
if ("present","absent" -notcontains $state)
|
if ("present","absent" -notcontains $state)
|
||||||
{
|
{
|
||||||
Fail-Json $result "state is $state; must be present or absent"
|
Fail-Json $result "state is $state; must be present or absent"
|
||||||
|
@ -106,7 +111,13 @@ Function Choco-Upgrade
|
||||||
[Parameter(Mandatory=$false, Position=3)]
|
[Parameter(Mandatory=$false, Position=3)]
|
||||||
[string]$source,
|
[string]$source,
|
||||||
[Parameter(Mandatory=$false, Position=4)]
|
[Parameter(Mandatory=$false, Position=4)]
|
||||||
[bool]$force
|
[bool]$force,
|
||||||
|
[Parameter(Mandatory=$false, Position=5)]
|
||||||
|
[string]$installargs,
|
||||||
|
[Parameter(Mandatory=$false, Position=6)]
|
||||||
|
[string]$packageparams,
|
||||||
|
[Parameter(Mandatory=$false, Position=7)]
|
||||||
|
[bool]$ignoredependencies
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not (Choco-IsInstalled $package))
|
if (-not (Choco-IsInstalled $package))
|
||||||
|
@ -131,6 +142,21 @@ Function Choco-Upgrade
|
||||||
$cmd += " -force"
|
$cmd += " -force"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($installargs)
|
||||||
|
{
|
||||||
|
$cmd += " -installargs '$installargs'"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($packageparams)
|
||||||
|
{
|
||||||
|
$cmd += " -params '$packageparams'"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ignoredependencies)
|
||||||
|
{
|
||||||
|
$cmd += " -ignoredependencies"
|
||||||
|
}
|
||||||
|
|
||||||
$results = invoke-expression $cmd
|
$results = invoke-expression $cmd
|
||||||
|
|
||||||
if ($LastExitCode -ne 0)
|
if ($LastExitCode -ne 0)
|
||||||
|
@ -163,14 +189,22 @@ Function Choco-Install
|
||||||
[Parameter(Mandatory=$false, Position=4)]
|
[Parameter(Mandatory=$false, Position=4)]
|
||||||
[bool]$force,
|
[bool]$force,
|
||||||
[Parameter(Mandatory=$false, Position=5)]
|
[Parameter(Mandatory=$false, Position=5)]
|
||||||
[bool]$upgrade
|
[bool]$upgrade,
|
||||||
|
[Parameter(Mandatory=$false, Position=6)]
|
||||||
|
[string]$installargs,
|
||||||
|
[Parameter(Mandatory=$false, Position=7)]
|
||||||
|
[string]$packageparams,
|
||||||
|
[Parameter(Mandatory=$false, Position=8)]
|
||||||
|
[bool]$ignoredependencies
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Choco-IsInstalled $package)
|
if (Choco-IsInstalled $package)
|
||||||
{
|
{
|
||||||
if ($upgrade)
|
if ($upgrade)
|
||||||
{
|
{
|
||||||
Choco-Upgrade -package $package -version $version -source $source -force $force
|
Choco-Upgrade -package $package -version $version -source $source -force $force `
|
||||||
|
-installargs $installargs -packageparams $packageparams `
|
||||||
|
-ignoredependencies $ignoredependencies
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -193,6 +227,21 @@ Function Choco-Install
|
||||||
$cmd += " -force"
|
$cmd += " -force"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($installargs)
|
||||||
|
{
|
||||||
|
$cmd += " -installargs '$installargs'"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($packageparams)
|
||||||
|
{
|
||||||
|
$cmd += " -params '$packageparams'"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ignoredependencies)
|
||||||
|
{
|
||||||
|
$cmd += " -ignoredependencies"
|
||||||
|
}
|
||||||
|
|
||||||
$results = invoke-expression $cmd
|
$results = invoke-expression $cmd
|
||||||
|
|
||||||
if ($LastExitCode -ne 0)
|
if ($LastExitCode -ne 0)
|
||||||
|
@ -253,7 +302,8 @@ Try
|
||||||
if ($state -eq "present")
|
if ($state -eq "present")
|
||||||
{
|
{
|
||||||
Choco-Install -package $package -version $version -source $source `
|
Choco-Install -package $package -version $version -source $source `
|
||||||
-force $force -upgrade $upgrade
|
-force $force -upgrade $upgrade -installargs $installargs `
|
||||||
|
-packageparams $packageparams -ignoredependencies $ignoredependencies
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,8 +33,6 @@ options:
|
||||||
description:
|
description:
|
||||||
- Name of the package to be installed
|
- Name of the package to be installed
|
||||||
required: true
|
required: true
|
||||||
default: null
|
|
||||||
aliases: []
|
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the package on the system
|
- State of the package on the system
|
||||||
|
@ -43,7 +41,6 @@ options:
|
||||||
- present
|
- present
|
||||||
- absent
|
- absent
|
||||||
default: present
|
default: present
|
||||||
aliases: []
|
|
||||||
force:
|
force:
|
||||||
description:
|
description:
|
||||||
- Forces install of the package (even if it already exists). Using Force will cause ansible to always report that a change was made
|
- Forces install of the package (even if it already exists). Using Force will cause ansible to always report that a change was made
|
||||||
|
@ -52,7 +49,6 @@ options:
|
||||||
- yes
|
- yes
|
||||||
- no
|
- no
|
||||||
default: no
|
default: no
|
||||||
aliases: []
|
|
||||||
upgrade:
|
upgrade:
|
||||||
description:
|
description:
|
||||||
- If package is already installed it, try to upgrade to the latest version or to the specified version
|
- If package is already installed it, try to upgrade to the latest version or to the specified version
|
||||||
|
@ -61,20 +57,32 @@ options:
|
||||||
- yes
|
- yes
|
||||||
- no
|
- no
|
||||||
default: no
|
default: no
|
||||||
aliases: []
|
|
||||||
version:
|
version:
|
||||||
description:
|
description:
|
||||||
- Specific version of the package to be installed
|
- Specific version of the package to be installed
|
||||||
- Ignored when state == 'absent'
|
- Ignored when state == 'absent'
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
|
||||||
source:
|
source:
|
||||||
description:
|
description:
|
||||||
- Specify source rather than using default chocolatey repository
|
- Specify source rather than using default chocolatey repository
|
||||||
require: false
|
require: false
|
||||||
default: null
|
default: null
|
||||||
aliases: []
|
install_args:
|
||||||
|
description:
|
||||||
|
- Arguments to pass to the native installer
|
||||||
|
require: false
|
||||||
|
default: null
|
||||||
|
params:
|
||||||
|
description:
|
||||||
|
- Parameters to pass to the package
|
||||||
|
require: false
|
||||||
|
default: null
|
||||||
|
ignore_dependencies:
|
||||||
|
description:
|
||||||
|
- Ignore dependencies, only install/upgrade the package itself
|
||||||
|
require: false
|
||||||
|
default: false
|
||||||
author: "Trond Hindenes (@trondhindenes), Peter Mounce (@petemounce), Pepe Barbe (@elventear), Adam Keech (@smadam813)"
|
author: "Trond Hindenes (@trondhindenes), Peter Mounce (@petemounce), Pepe Barbe (@elventear), Adam Keech (@smadam813)"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue