Support lists of packages in win_winget module

This commit is contained in:
Kenneth Benzie 2024-12-10 23:19:12 +00:00
parent a9aa1bdaaf
commit 1995bf3bc2
2 changed files with 37 additions and 34 deletions

View File

@ -6,8 +6,9 @@
$module = [Ansible.Basic.AnsibleModule]::Create($args, @{
options = @{
name = @{
type = "str"
default = $null
type = "list"
elements = "str"
required = $true
}
state = @{
type = "str"
@ -18,7 +19,7 @@ $module = [Ansible.Basic.AnsibleModule]::Create($args, @{
supports_check_mode = $false
})
$name = $module.Params.name
$names = $module.Params.name
$state = $module.Params.state
$winget = Get-ExecutablePath "winget"
$noPackageString = "No installed package found matching input criteria."
@ -48,6 +49,7 @@ function Test-UpgradeAvailable {
return $true
}
foreach ($name in $names) {
switch ($state) {
"absent" {
if (Test-Installed) {
@ -91,6 +93,7 @@ switch ($state) {
}
}
}
}
$module.Result.rc = 0
$module.ExitJson()

View File

@ -11,7 +11,7 @@ options:
name:
description:
- Name of the package to manage.
type: str
type: list[str]
state:
description:
- Indicates the desired package state. V(latest) ensures that the latest