|
|
|
@ -20,10 +20,6 @@
|
|
|
|
|
# WANT_JSON
|
|
|
|
|
# POWERSHELL_COMMON
|
|
|
|
|
|
|
|
|
|
$result = @{
|
|
|
|
|
changed = $false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$params = Parse-Args $args -supports_check_mode $true
|
|
|
|
|
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
|
|
|
|
|
|
|
|
|
@ -34,14 +30,21 @@ $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
|
|
|
|
|
$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"
|
|
|
|
|
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "absent","latest","present","reinstalled"
|
|
|
|
|
$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
|
|
|
|
|
$skipscripts Get-AnsibleParam -obj $params -name "skip_scripts" -type "bool" -default $false
|
|
|
|
|
|
|
|
|
|
if ($source) {$source = $source.Tolower()}
|
|
|
|
|
$result = @{
|
|
|
|
|
changed = $false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($source) {
|
|
|
|
|
$source = $source.Tolower()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($upgrade)
|
|
|
|
|
{
|
|
|
|
@ -150,6 +153,8 @@ Function Choco-Upgrade
|
|
|
|
|
[bool]$ignoredependencies,
|
|
|
|
|
[Parameter(Mandatory=$false, Position=10)]
|
|
|
|
|
[int]$timeout
|
|
|
|
|
[Parameter(Mandatory=$false, Position=11)]
|
|
|
|
|
[bool]$skipscripts
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (-not (Choco-IsInstalled $package))
|
|
|
|
@ -204,6 +209,11 @@ Function Choco-Upgrade
|
|
|
|
|
$cmd += " -ignoredependencies"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($skipscripts)
|
|
|
|
|
{
|
|
|
|
|
$cmd += " --skip-scripts"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$output = invoke-expression $cmd
|
|
|
|
|
|
|
|
|
|
$result.rc = $LastExitCode
|
|
|
|
@ -250,6 +260,8 @@ Function Choco-Install
|
|
|
|
|
[bool]$ignoredependencies,
|
|
|
|
|
[Parameter(Mandatory=$false, Position=11)]
|
|
|
|
|
[int]$timeout
|
|
|
|
|
[Parameter(Mandatory=$false, Position=12)]
|
|
|
|
|
[bool]$skipscripts
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (Choco-IsInstalled $package)
|
|
|
|
@ -316,6 +328,11 @@ Function Choco-Install
|
|
|
|
|
$cmd += " -ignoredependencies"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($skipscripts)
|
|
|
|
|
{
|
|
|
|
|
$cmd += " --skip-scripts"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$results = invoke-expression $cmd
|
|
|
|
|
|
|
|
|
|
$result.rc = $LastExitCode
|
|
|
|
@ -342,6 +359,8 @@ Function Choco-Uninstall
|
|
|
|
|
[bool]$force,
|
|
|
|
|
[Parameter(Mandatory=$false, Position=4)]
|
|
|
|
|
[int]$timeout
|
|
|
|
|
[Parameter(Mandatory=$false, Position=5)]
|
|
|
|
|
[bool]$skipscripts
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -372,6 +391,11 @@ Function Choco-Uninstall
|
|
|
|
|
$cmd += " -params '$packageparams'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($skipscripts)
|
|
|
|
|
{
|
|
|
|
|
$cmd += " --skip-scripts"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$results = invoke-expression $cmd
|
|
|
|
|
|
|
|
|
|
$result.rc = $LastExitCode
|
|
|
|
@ -394,11 +418,12 @@ Try
|
|
|
|
|
Choco-Install -package $package -version $version -source $source -force $force `
|
|
|
|
|
-installargs $installargs -packageparams $packageparams `
|
|
|
|
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
|
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout
|
|
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout -skipscripts $skipscripts
|
|
|
|
|
}
|
|
|
|
|
elseif ($state -eq "absent")
|
|
|
|
|
{
|
|
|
|
|
Choco-Uninstall -package $package -version $version -force $force -timeout $timeout
|
|
|
|
|
Choco-Uninstall -package $package -version $version -force $force -timeout $timeout `
|
|
|
|
|
-skipscripts $skipscripts
|
|
|
|
|
}
|
|
|
|
|
elseif ($state -eq "reinstalled")
|
|
|
|
|
{
|
|
|
|
@ -407,7 +432,7 @@ Try
|
|
|
|
|
Choco-Install -package $package -version $version -source $source -force $force `
|
|
|
|
|
-installargs $installargs -packageparams $packageparams `
|
|
|
|
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
|
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout
|
|
|
|
|
-ignoredependencies $ignoredependencies -timeout $timeout -skipscripts $skipscripts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Exit-Json $result
|
|
|
|
|