fix conflicts in win_chocolatey execution_timeout (#22182)
parent
299e964dbf
commit
4901763d72
|
@ -32,6 +32,7 @@ $upgrade = Get-AnsibleParam -obj $params -name "upgrade" -type "bool" -default $
|
||||||
$version = Get-AnsibleParam -obj $params -name "version" -type "str"
|
$version = Get-AnsibleParam -obj $params -name "version" -type "str"
|
||||||
$source = Get-AnsibleParam -obj $params -name "source" -type "str"
|
$source = Get-AnsibleParam -obj $params -name "source" -type "str"
|
||||||
$showlog = Get-AnsibleParam -obj $params -name "showlog" -type "bool" -default $false
|
$showlog = Get-AnsibleParam -obj $params -name "showlog" -type "bool" -default $false
|
||||||
|
$executiontimeout = Get-Attr -obj $params -name execution_timeout -default $null
|
||||||
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "present","absent","latest"
|
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "present","absent","latest"
|
||||||
$installargs = Get-AnsibleParam -obj $params -name "install_args" -type "str"
|
$installargs = Get-AnsibleParam -obj $params -name "install_args" -type "str"
|
||||||
$packageparams = Get-AnsibleParam -obj $params -name "params" -type "str"
|
$packageparams = Get-AnsibleParam -obj $params -name "params" -type "str"
|
||||||
|
@ -140,7 +141,9 @@ Function Choco-Upgrade
|
||||||
[Parameter(Mandatory=$false, Position=8)]
|
[Parameter(Mandatory=$false, Position=8)]
|
||||||
[bool]$ignorechecksums,
|
[bool]$ignorechecksums,
|
||||||
[Parameter(Mandatory=$false, Position=9)]
|
[Parameter(Mandatory=$false, Position=9)]
|
||||||
[bool]$ignoredependencies
|
[bool]$ignoredependencies,
|
||||||
|
[Parameter(Mandatory=$false, Position=10)]
|
||||||
|
[string]$executiontimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not (Choco-IsInstalled $package))
|
if (-not (Choco-IsInstalled $package))
|
||||||
|
@ -190,7 +193,12 @@ Function Choco-Upgrade
|
||||||
$cmd += " -ignoredependencies"
|
$cmd += " -ignoredependencies"
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = invoke-expression $cmd
|
if ($executiontimeout)
|
||||||
|
{
|
||||||
|
$cmd += " --execution-timeout=$executiontimeout"
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = invoke-expression $cmd
|
||||||
|
|
||||||
$result.rc = $LastExitCode
|
$result.rc = $LastExitCode
|
||||||
if ($LastExitCode -notin $successexitcodes)
|
if ($LastExitCode -notin $successexitcodes)
|
||||||
|
@ -233,14 +241,29 @@ Function Choco-Install
|
||||||
[Parameter(Mandatory=$false, Position=9)]
|
[Parameter(Mandatory=$false, Position=9)]
|
||||||
[bool]$ignorechecksums,
|
[bool]$ignorechecksums,
|
||||||
[Parameter(Mandatory=$false, Position=10)]
|
[Parameter(Mandatory=$false, Position=10)]
|
||||||
[bool]$ignoredependencies
|
[bool]$ignoredependencies,
|
||||||
|
[Parameter(Mandatory=$false, Position=11)]
|
||||||
|
[string]$executiontimeout
|
||||||
)
|
)
|
||||||
|
|
||||||
if ((Choco-IsInstalled $package) -and -not $force)
|
if ((Choco-IsInstalled $package) -and -not $force)
|
||||||
{
|
{
|
||||||
|
if ($upgrade)
|
||||||
|
{
|
||||||
|
Choco-Upgrade -package $package -version $version -source $source -force $force `
|
||||||
|
-installargs $installargs -packageparams $packageparams `
|
||||||
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
||||||
|
-ignoredependencies $ignoredependencies -executiontimeout $executiontimeout
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (-not $force)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$cmd = "$executable install -dv -y $package"
|
$cmd = "$executable install -dv -y $package"
|
||||||
|
|
||||||
if ($version)
|
if ($version)
|
||||||
|
@ -283,7 +306,12 @@ Function Choco-Install
|
||||||
$cmd += " -ignoredependencies"
|
$cmd += " -ignoredependencies"
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = invoke-expression $cmd
|
if ($executiontimeout)
|
||||||
|
{
|
||||||
|
$cmd += " --execution-timeout=$executiontimeout"
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = invoke-expression $cmd
|
||||||
|
|
||||||
$result.rc = $LastExitCode
|
$result.rc = $LastExitCode
|
||||||
if ($LastExitCode -notin $successexitcodes)
|
if ($LastExitCode -notin $successexitcodes)
|
||||||
|
@ -306,7 +334,10 @@ Function Choco-Uninstall
|
||||||
[Parameter(Mandatory=$false, Position=2)]
|
[Parameter(Mandatory=$false, Position=2)]
|
||||||
[string]$version,
|
[string]$version,
|
||||||
[Parameter(Mandatory=$false, Position=3)]
|
[Parameter(Mandatory=$false, Position=3)]
|
||||||
[bool]$force
|
[bool]$force,
|
||||||
|
[Parameter(Mandatory=$false, Position=4)]
|
||||||
|
[string]$executiontimeout
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not (Choco-IsInstalled $package))
|
if (-not (Choco-IsInstalled $package))
|
||||||
|
@ -331,7 +362,12 @@ Function Choco-Uninstall
|
||||||
$cmd += " -params '$packageparams'"
|
$cmd += " -params '$packageparams'"
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = invoke-expression $cmd
|
if ($executiontimeout)
|
||||||
|
{
|
||||||
|
$cmd += " --execution-timeout=$executiontimeout"
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = invoke-expression $cmd
|
||||||
|
|
||||||
$result.rc = $LastExitCode
|
$result.rc = $LastExitCode
|
||||||
if ($LastExitCode -notin $successexitcodes)
|
if ($LastExitCode -notin $successexitcodes)
|
||||||
|
@ -353,7 +389,7 @@ Try
|
||||||
Choco-Install -package $package -version $version -source $source -force $force `
|
Choco-Install -package $package -version $version -source $source -force $force `
|
||||||
-installargs $installargs -packageparams $packageparams `
|
-installargs $installargs -packageparams $packageparams `
|
||||||
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
-allowemptychecksums $allowemptychecksums -ignorechecksums $ignorechecksums `
|
||||||
-ignoredependencies $ignoredependencies
|
-ignoredependencies $ignoredependencies -executiontimeout $executiontimeout
|
||||||
}
|
}
|
||||||
elseif ($state -eq "latest")
|
elseif ($state -eq "latest")
|
||||||
{
|
{
|
||||||
|
@ -364,7 +400,8 @@ Try
|
||||||
}
|
}
|
||||||
elseif ($state -eq "absent")
|
elseif ($state -eq "absent")
|
||||||
{
|
{
|
||||||
Choco-Uninstall -package $package -version $version -force $force
|
Choco-Uninstall -package $package -version $version -force $force `
|
||||||
|
-executiontimeout $executiontimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit-Json $result
|
Exit-Json $result
|
||||||
|
|
|
@ -94,6 +94,11 @@ options:
|
||||||
- Ignore dependencies, only install/upgrade the package itself
|
- Ignore dependencies, only install/upgrade the package itself
|
||||||
default: false
|
default: false
|
||||||
version_added: '2.1'
|
version_added: '2.1'
|
||||||
|
execution_timeout:
|
||||||
|
description:
|
||||||
|
- Timeout to pass to the native installer
|
||||||
|
require: false
|
||||||
|
version_added: '2.3'
|
||||||
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…
Reference in New Issue