2014-10-01 15:58:45 +02:00
|
|
|
#!powershell
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Copyright 2014, Trond Hindenes <trond@hindenes.com>
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2014-10-01 15:58:45 +02:00
|
|
|
# WANT_JSON
|
|
|
|
# POWERSHELL_COMMON
|
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result = @{
|
|
|
|
changed = $false
|
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2017-03-15 02:57:29 +01:00
|
|
|
$params = Parse-Args $args -supports_check_mode $true
|
|
|
|
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
|
2017-02-24 11:09:11 +01:00
|
|
|
|
|
|
|
$package = Get-AnsibleParam -obj $params -name "name" -type "str" -failifempty $true
|
|
|
|
$force = Get-AnsibleParam -obj $params -name "force" -type "bool" -default $false
|
|
|
|
$upgrade = Get-AnsibleParam -obj $params -name "upgrade" -type "bool" -default $false
|
|
|
|
$version = Get-AnsibleParam -obj $params -name "version" -type "str"
|
|
|
|
$source = Get-AnsibleParam -obj $params -name "source" -type "str"
|
|
|
|
$showlog = Get-AnsibleParam -obj $params -name "showlog" -type "bool" -default $false
|
2017-03-15 02:57:29 +01:00
|
|
|
$timeout = Get-AnsibleParam -obj $params -name "timeout" -type "int" -default 2700 -aliases "execution_timeout"
|
|
|
|
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "present","absent","latest","reinstalled"
|
2017-02-24 11:09:11 +01:00
|
|
|
$installargs = Get-AnsibleParam -obj $params -name "install_args" -type "str"
|
|
|
|
$packageparams = Get-AnsibleParam -obj $params -name "params" -type "str"
|
|
|
|
$allowemptychecksums = Get-AnsibleParam -obj $params -name "allow_empty_checksums" -type "bool" -default $false
|
|
|
|
$ignorechecksums = Get-AnsibleParam -obj $params -name "ignore_checksums" -type "bool" -default $false
|
|
|
|
$ignoredependencies = Get-AnsibleParam -obj $params -name "ignore_dependencies" -type "bool" -default $false
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2015-09-23 20:49:26 +02:00
|
|
|
if ($source) {$source = $source.Tolower()}
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
if ($upgrade)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2017-03-02 07:21:22 +01:00
|
|
|
Add-DeprecationWarning $result "Parameter upgrade=yes is replaced with state=latest"
|
2017-02-24 11:09:11 +01:00
|
|
|
if ($state -eq "present")
|
2017-03-02 07:21:22 +01:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$state = "latest"
|
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
# As of chocolatey 0.9.10, nonzero success exit codes can be returned
|
|
|
|
# See https://github.com/chocolatey/choco/issues/512#issuecomment-214284461
|
|
|
|
$successexitcodes = (0,1605,1614,1641,3010)
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
Function Chocolatey-Install-Upgrade
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
[CmdletBinding()]
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
param()
|
|
|
|
|
|
|
|
$ChocoAlreadyInstalled = get-command choco -ErrorAction 0
|
|
|
|
if ($ChocoAlreadyInstalled -eq $null)
|
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2017-06-27 00:58:52 +02:00
|
|
|
# We need to install chocolatey
|
2016-08-18 00:47:44 +02:00
|
|
|
$install_output = (new-object net.webclient).DownloadString("https://chocolatey.org/install.ps1") | powershell -
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.choco_bootstrap_output = $install_output
|
2016-08-18 00:47:44 +02:00
|
|
|
Fail-Json $result "Chocolatey bootstrap installation failed."
|
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
$result.changed = $true
|
|
|
|
$script:executable = "C:\ProgramData\chocolatey\bin\choco.exe"
|
2017-06-27 00:58:52 +02:00
|
|
|
Add-Warning $result 'Chocolatey was missing from this system, so it was installed during this task run.'
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
|
|
|
else
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
$script:executable = "choco.exe"
|
|
|
|
|
2016-09-23 05:06:45 +02:00
|
|
|
if ([Version](choco --version) -lt [Version]'0.9.9')
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
Choco-Upgrade chocolatey
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
Function Choco-IsInstalled
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
[CmdletBinding()]
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true, Position=1)]
|
|
|
|
[string]$package
|
|
|
|
)
|
|
|
|
|
2017-07-05 00:04:30 +02:00
|
|
|
if ($package -eq "all") {
|
|
|
|
return $true
|
|
|
|
}
|
|
|
|
|
2017-04-04 18:39:27 +02:00
|
|
|
$cmd = "$executable list --local-only --exact $package"
|
2017-02-24 11:09:11 +01:00
|
|
|
$output = invoke-expression $cmd
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.rc = $LastExitCode
|
2015-06-07 20:18:33 +02:00
|
|
|
if ($LastExitCode -ne 0)
|
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.choco_error_cmd = $cmd
|
|
|
|
$result.choco_error_log = $output
|
|
|
|
|
|
|
|
Throw "Error checking installation status for $package"
|
|
|
|
}
|
|
|
|
|
2017-02-27 12:36:52 +01:00
|
|
|
If ("$output" -match "(\d+) packages installed.")
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
|
|
|
return $matches[1] -gt 0
|
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
|
|
|
|
return $false
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
Function Choco-Upgrade
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
[CmdletBinding()]
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true, Position=1)]
|
|
|
|
[string]$package,
|
|
|
|
[Parameter(Mandatory=$false, Position=2)]
|
|
|
|
[string]$version,
|
|
|
|
[Parameter(Mandatory=$false, Position=3)]
|
|
|
|
[string]$source,
|
|
|
|
[Parameter(Mandatory=$false, Position=4)]
|
2015-11-27 15:49:57 +01:00
|
|
|
[bool]$force,
|
|
|
|
[Parameter(Mandatory=$false, Position=5)]
|
|
|
|
[string]$installargs,
|
|
|
|
[Parameter(Mandatory=$false, Position=6)]
|
|
|
|
[string]$packageparams,
|
|
|
|
[Parameter(Mandatory=$false, Position=7)]
|
2016-08-18 18:46:37 +02:00
|
|
|
[bool]$allowemptychecksums,
|
|
|
|
[Parameter(Mandatory=$false, Position=8)]
|
|
|
|
[bool]$ignorechecksums,
|
|
|
|
[Parameter(Mandatory=$false, Position=9)]
|
2017-03-02 08:13:24 +01:00
|
|
|
[bool]$ignoredependencies,
|
|
|
|
[Parameter(Mandatory=$false, Position=10)]
|
2017-03-15 02:57:29 +01:00
|
|
|
[int]$timeout
|
2014-10-01 15:58:45 +02:00
|
|
|
)
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if (-not (Choco-IsInstalled $package))
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
throw "$package is not installed, you cannot upgrade"
|
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2017-07-05 00:20:20 +02:00
|
|
|
$cmd = "$executable upgrade -dv -y $package -timeout $timeout --failonunfound"
|
2017-03-15 02:57:29 +01:00
|
|
|
|
|
|
|
if ($check_mode)
|
|
|
|
{
|
|
|
|
$cmd += " -whatif"
|
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
if ($version)
|
|
|
|
{
|
|
|
|
$cmd += " -version $version"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($source)
|
|
|
|
{
|
|
|
|
$cmd += " -source $source"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($force)
|
|
|
|
{
|
|
|
|
$cmd += " -force"
|
|
|
|
}
|
|
|
|
|
2015-11-27 15:49:57 +01:00
|
|
|
if ($installargs)
|
|
|
|
{
|
|
|
|
$cmd += " -installargs '$installargs'"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($packageparams)
|
|
|
|
{
|
|
|
|
$cmd += " -params '$packageparams'"
|
|
|
|
}
|
|
|
|
|
2016-08-18 18:46:37 +02:00
|
|
|
if ($allowemptychecksums)
|
|
|
|
{
|
|
|
|
$cmd += " --allow-empty-checksums"
|
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2016-08-18 18:46:37 +02:00
|
|
|
if ($ignorechecksums)
|
|
|
|
{
|
|
|
|
$cmd += " --ignore-checksums"
|
|
|
|
}
|
|
|
|
|
2015-11-27 15:49:57 +01:00
|
|
|
if ($ignoredependencies)
|
|
|
|
{
|
|
|
|
$cmd += " -ignoredependencies"
|
|
|
|
}
|
|
|
|
|
2017-03-06 13:55:42 +01:00
|
|
|
$output = invoke-expression $cmd
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.rc = $LastExitCode
|
2016-06-20 21:59:48 +02:00
|
|
|
if ($LastExitCode -notin $successexitcodes)
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.choco_error_cmd = $cmd
|
|
|
|
$result.choco_error_log = $output
|
|
|
|
Throw "Error installing $package"
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
|
|
|
|
2017-03-06 13:55:42 +01:00
|
|
|
if ("$output" -match ' upgraded (\d+)/\d+ package')
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
|
|
|
if ($matches[1] -gt 0)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
|
|
|
$result.changed = $true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
Function Choco-Install
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
[CmdletBinding()]
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true, Position=1)]
|
|
|
|
[string]$package,
|
|
|
|
[Parameter(Mandatory=$false, Position=2)]
|
|
|
|
[string]$version,
|
|
|
|
[Parameter(Mandatory=$false, Position=3)]
|
|
|
|
[string]$source,
|
|
|
|
[Parameter(Mandatory=$false, Position=4)]
|
|
|
|
[bool]$force,
|
|
|
|
[Parameter(Mandatory=$false, Position=5)]
|
2015-11-27 15:49:57 +01:00
|
|
|
[bool]$upgrade,
|
|
|
|
[Parameter(Mandatory=$false, Position=6)]
|
|
|
|
[string]$installargs,
|
|
|
|
[Parameter(Mandatory=$false, Position=7)]
|
|
|
|
[string]$packageparams,
|
|
|
|
[Parameter(Mandatory=$false, Position=8)]
|
2016-08-18 18:46:37 +02:00
|
|
|
[bool]$allowemptychecksums,
|
|
|
|
[Parameter(Mandatory=$false, Position=9)]
|
|
|
|
[bool]$ignorechecksums,
|
|
|
|
[Parameter(Mandatory=$false, Position=10)]
|
2017-03-02 08:13:24 +01:00
|
|
|
[bool]$ignoredependencies,
|
|
|
|
[Parameter(Mandatory=$false, Position=11)]
|
2017-03-15 02:57:29 +01:00
|
|
|
[int]$timeout
|
2015-06-07 20:18:33 +02:00
|
|
|
)
|
|
|
|
|
2017-03-29 02:49:21 +02:00
|
|
|
if (Choco-IsInstalled $package)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2017-04-04 18:39:27 +02:00
|
|
|
if ($state -eq "latest")
|
2017-03-02 08:13:24 +01:00
|
|
|
{
|
|
|
|
Choco-Upgrade -package $package -version $version -source $source -force $force `
|
|
|
|
-installargs $installargs -packageparams $packageparams `
|
|
|
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
2017-03-15 02:57:29 +01:00
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout
|
2017-03-02 08:13:24 +01:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2017-03-29 02:49:21 +02:00
|
|
|
elseif (-not $force)
|
2017-03-02 08:13:24 +01:00
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
|
|
|
|
2017-07-05 00:20:20 +02:00
|
|
|
$cmd = "$executable install -dv -y $package -timeout $timeout --failonunfound"
|
2017-03-15 02:57:29 +01:00
|
|
|
|
|
|
|
if ($check_mode)
|
|
|
|
{
|
|
|
|
$cmd += " -whatif"
|
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if ($version)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
$cmd += " -version $version"
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if ($source)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
$cmd += " -source $source"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($force)
|
|
|
|
{
|
|
|
|
$cmd += " -force"
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2015-11-27 15:49:57 +01:00
|
|
|
if ($installargs)
|
|
|
|
{
|
|
|
|
$cmd += " -installargs '$installargs'"
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($packageparams)
|
|
|
|
{
|
|
|
|
$cmd += " -params '$packageparams'"
|
|
|
|
}
|
|
|
|
|
2016-08-18 18:46:37 +02:00
|
|
|
if ($allowemptychecksums)
|
|
|
|
{
|
|
|
|
$cmd += " --allow-empty-checksums"
|
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2016-08-18 18:46:37 +02:00
|
|
|
if ($ignorechecksums)
|
|
|
|
{
|
|
|
|
$cmd += " --ignore-checksums"
|
|
|
|
}
|
|
|
|
|
2015-11-27 15:49:57 +01:00
|
|
|
if ($ignoredependencies)
|
|
|
|
{
|
|
|
|
$cmd += " -ignoredependencies"
|
|
|
|
}
|
|
|
|
|
2017-03-02 08:13:24 +01:00
|
|
|
$results = invoke-expression $cmd
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.rc = $LastExitCode
|
2016-06-20 21:59:48 +02:00
|
|
|
if ($LastExitCode -notin $successexitcodes)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.choco_error_cmd = $cmd
|
|
|
|
$result.choco_error_log = $output
|
|
|
|
Throw "Error installing $package"
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.changed = $true
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
Function Choco-Uninstall
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
[CmdletBinding()]
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true, Position=1)]
|
|
|
|
[string]$package,
|
|
|
|
[Parameter(Mandatory=$false, Position=2)]
|
|
|
|
[string]$version,
|
|
|
|
[Parameter(Mandatory=$false, Position=3)]
|
2017-03-02 08:13:24 +01:00
|
|
|
[bool]$force,
|
|
|
|
[Parameter(Mandatory=$false, Position=4)]
|
2017-03-15 02:57:29 +01:00
|
|
|
[int]$timeout
|
2017-03-02 08:13:24 +01:00
|
|
|
|
2014-10-01 15:58:45 +02:00
|
|
|
)
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if (-not (Choco-IsInstalled $package))
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
return
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-03-15 02:57:29 +01:00
|
|
|
$cmd = "$executable uninstall -dv -y $package -timeout $timeout"
|
|
|
|
|
|
|
|
if ($check_mode)
|
|
|
|
{
|
|
|
|
$cmd += " -whatif"
|
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if ($version)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
$cmd += " -version $version"
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
|
|
|
if ($force)
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2015-06-07 20:18:33 +02:00
|
|
|
$cmd += " -force"
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2016-06-20 23:30:10 +02:00
|
|
|
if ($packageparams)
|
|
|
|
{
|
|
|
|
$cmd += " -params '$packageparams'"
|
|
|
|
}
|
|
|
|
|
2017-03-02 08:13:24 +01:00
|
|
|
$results = invoke-expression $cmd
|
2015-06-07 20:18:33 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.rc = $LastExitCode
|
2016-06-20 21:59:48 +02:00
|
|
|
if ($LastExitCode -notin $successexitcodes)
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.choco_error_cmd = $cmd
|
|
|
|
$result.choco_error_log = $output
|
|
|
|
Throw "Error uninstalling $package"
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
$result.changed = $true
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
|
2015-06-07 20:18:33 +02:00
|
|
|
Try
|
|
|
|
{
|
|
|
|
Chocolatey-Install-Upgrade
|
|
|
|
|
2017-03-29 02:49:21 +02:00
|
|
|
if ($state -eq "present" -or $state -eq "latest")
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
Choco-Install -package $package -version $version -source $source -force $force `
|
|
|
|
-installargs $installargs -packageparams $packageparams `
|
|
|
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
2017-03-15 02:57:29 +01:00
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
2017-02-24 11:09:11 +01:00
|
|
|
elseif ($state -eq "absent")
|
2015-06-07 20:18:33 +02:00
|
|
|
{
|
2017-03-15 02:57:29 +01:00
|
|
|
Choco-Uninstall -package $package -version $version -force $force -timeout $timeout
|
|
|
|
}
|
|
|
|
elseif ($state -eq "reinstalled")
|
|
|
|
{
|
|
|
|
Choco-Uninstall -package $package -version $version -force $force -timeout $timeout
|
|
|
|
|
|
|
|
Choco-Install -package $package -version $version -source $source -force $force `
|
|
|
|
-installargs $installargs -packageparams $packageparams `
|
|
|
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
2014-10-01 15:58:45 +02:00
|
|
|
|
2017-02-24 11:09:11 +01:00
|
|
|
Exit-Json $result
|
2015-06-07 20:18:33 +02:00
|
|
|
}
|
|
|
|
Catch
|
2014-10-01 15:58:45 +02:00
|
|
|
{
|
2017-02-24 11:09:11 +01:00
|
|
|
Fail-Json $result $_.Exception.Message
|
2014-10-01 15:58:45 +02:00
|
|
|
}
|