1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Better result handling

This commit is contained in:
Trond Hindenes 2014-07-10 12:00:00 +02:00
parent 3bf16805e1
commit d5a0c18170

View file

@ -92,6 +92,9 @@ Elseif ($state -eq "absent") {
# Loop through results and create a hash containing details about # Loop through results and create a hash containing details about
# each role/feature that is installed/removed # each role/feature that is installed/removed
$installed_features = @() $installed_features = @()
#$featureresult.featureresult is filled if anything was changed
if ($featureresult.FeatureResult)
{
ForEach ($item in $featureresult.FeatureResult) { ForEach ($item in $featureresult.FeatureResult) {
$installed_features += New-Object psobject @{ $installed_features += New-Object psobject @{
id = $item.id.ToString() id = $item.id.ToString()
@ -103,12 +106,17 @@ ForEach ($item in $featureresult.FeatureResult) {
} }
} }
Set-Attr $result "feature_result" $installed_features Set-Attr $result "feature_result" $installed_features
$result.changed = $true
}
Else
{
Set-Attr $result "feature_result" $null
}
Set-Attr $result "feature_success" $featureresult.Success.ToString() Set-Attr $result "feature_success" $featureresult.Success.ToString()
Set-Attr $result "feature_exitcode" $featureresult.ExitCode.ToString() Set-Attr $result "feature_exitcode" $featureresult.ExitCode.ToString()
Set-Attr $result "feature_restart_needed" $featureresult.RestartNeeded.ToString() Set-Attr $result "feature_restart_needed" $featureresult.RestartNeeded.ToString()
If ($result.feature_result.Length -gt 0) {
$result.changed = $true
}
Exit-Json $result; Exit-Json $result;