mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
win_chocolatey - fix beta version parsing (#52601)
This commit is contained in:
parent
9f7584e311
commit
1ec376abca
2 changed files with 11 additions and 1 deletions
2
changelogs/fragments/win_chocolatey-beta-versions.yaml
Normal file
2
changelogs/fragments/win_chocolatey-beta-versions.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- win_chocolatey - Fix issue when parsing a beta Chocolatey install - https://github.com/ansible/ansible/issues/52331
|
|
@ -292,7 +292,15 @@ Function Install-Chocolatey {
|
|||
}
|
||||
|
||||
$actual_version = (Get-ChocolateyPackageVersion -choco_path $choco_app.Path -name chocolatey)[0]
|
||||
if ([Version]$actual_version -lt [Version]"0.10.5") {
|
||||
try {
|
||||
# The Chocolatey version may not be in the strict form of major.minor.build and will fail to cast to
|
||||
# System.Version. We want to warn if this is the case saying module behaviour may be incorrect.
|
||||
$actual_version = [Version]$actual_version
|
||||
} catch {
|
||||
$module.Warn("Failed to parse Chocolatey version '$actual_version' for checking module requirements, module may not work correctly: $($_.Exception.Message)")
|
||||
$actual_version = $null
|
||||
}
|
||||
if ($null -ne $actual_version -and $actual_version -lt [Version]"0.10.5") {
|
||||
if ($module.CheckMode) {
|
||||
$module.Result.skipped = $true
|
||||
$module.Result.msg = "Skipped check mode run on win_chocolatey as choco.exe is too old, a real run would have upgraded the executable. Actual: '$actual_version', Minimum Version: '0.10.5'"
|
||||
|
|
Loading…
Reference in a new issue