summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2017-02-16 13:41:59 +0100
committerJohn R Barker <john@johnrbarker.com>2017-02-16 12:41:59 +0000
commitedf2b006147ae722b036c437a119477d6b93db7c (patch)
tree24f6af4f9bdc4cb8b2f87e9e17ed2e6cb876365e
parentdbb452100ab686b4dd0bc8835425a512a785212f (diff)
downloadansible-edf2b006147ae722b036c437a119477d6b93db7c.tar.gz
win_regmerge: Clean up parameter handling (#21388)
Changes include: - Use Get-AnsibleParam with -type support - Replace $result PSObject with normal hash
-rw-r--r--lib/ansible/modules/windows/win_regmerge.ps127
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/ansible/modules/windows/win_regmerge.ps1 b/lib/ansible/modules/windows/win_regmerge.ps1
index 87e73a6977..1c2380a4f4 100644
--- a/lib/ansible/modules/windows/win_regmerge.ps1
+++ b/lib/ansible/modules/windows/win_regmerge.ps1
@@ -31,12 +31,13 @@ Function Convert-RegistryPath {
Return $output
}
+$result = @{
+ changed = $false
+}
$params = Parse-Args $args
-$result = New-Object PSObject
-Set-Attr $result "changed" $False
-$path = Get-Attr -obj $params -name path -failifempty $True -resultobj $result
-$compare_to = Get-Attr -obj $params -name compare_to -failifempty $False -resultobj $result
+$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true -resultobj $result
+$compare_to = Get-AnsibleParam -obj $params -name "compare_to" -type "str" -resultobj $result
# check it looks like a reg key, warn if key not present - will happen first time
# only accepting PS-Drive style key names (starting with HKLM etc, not HKEY_LOCAL_MACHINE etc)
@@ -48,7 +49,7 @@ If ($compare_to) {
If (Test-Path $compare_to_key -pathType container ) {
$do_comparison = $True
} Else {
- Set-Attr $result "compare_to_key_found" $False
+ $result.compare_to_key_found = $false
}
}
@@ -71,28 +72,28 @@ If ( $do_comparison -eq $True ) {
$reg_import_args = @("IMPORT", "$path")
$ret = & reg.exe $reg_import_args 2>&1
If ($LASTEXITCODE -eq 0) {
- Set-Attr $result "changed" $True
- Set-Attr $result "difference_count" $comparison_result.count
+ $result.changed = $true
+ $result.difference_count = $comparison_result.count
} Else {
- Set-Attr $result "rc" $LASTEXITCODE
+ $result.rc = $LASTEXITCODE
Fail-Json $result "$ret"
}
} Else {
- Set-Attr $result "difference_count" 0
+ $result.difference_count = 0
}
Remove-Item $exported_path
- Set-Attr $result "compared" $True
+ $result.compared = $true
} Else {
# not comparing, merge and report changed
$reg_import_args = @("IMPORT", "$path")
$ret = & reg.exe $reg_import_args 2>&1
If ( $LASTEXITCODE -eq 0 ) {
- Set-Attr $result "changed" $True
- Set-Attr $result "compared" $False
+ $result.changed = $true
+ $result.compared = $false
} Else {
- Set-Attr $result "rc" $LASTEXITCODE
+ $result.rc = $LASTEXITCODE
Fail-Json $result "$ret"
}
}