From 1710d1aa0cf315d6cdad79b0e2609c5ed61bcc5f Mon Sep 17 00:00:00 2001 From: Adam Keech Date: Wed, 1 Jul 2015 09:53:35 -0400 Subject: [PATCH] Renaming variables in win_regedit module to make more sense with actions that are happening. --- .../modules/extras/windows/win_regedit.ps1 | 49 ++++++++++--------- .../modules/extras/windows/win_regedit.py | 43 ++++++++-------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_regedit.ps1 b/lib/ansible/modules/extras/windows/win_regedit.ps1 index 18cdc99c6ae..3e654202296 100644 --- a/lib/ansible/modules/extras/windows/win_regedit.ps1 +++ b/lib/ansible/modules/extras/windows/win_regedit.ps1 @@ -27,7 +27,7 @@ Set-Attr $result "changed" $false; If ($params.name) { - $registryKeyName = $params.name + $registryValueName = $params.name } Else { @@ -47,39 +47,39 @@ Else $state = "present" } -If ($params.value) +If ($params.data) { - $registryKeyValue = $params.value + $registryValueData = $params.data } ElseIf ($state -eq "present") { - Fail-Json $result "missing required argument: value" + Fail-Json $result "missing required argument: data" } -If ($params.valuetype) +If ($params.type) { - $registryValueType = $params.valuetype.ToString().ToLower() - $validRegistryValueTypes = "binary", "dword", "expandstring", "multistring", "string", "qword" - If ($validRegistryValueTypes -notcontains $registryValueType) + $registryDataType = $params.type.ToString().ToLower() + $validRegistryDataTypes = "binary", "dword", "expandstring", "multistring", "string", "qword" + If ($validRegistryDataTypes -notcontains $registryDataType) { - Fail-Json $result "valuetype is $registryValueType; must be binary, dword, expandstring, multistring, string, or qword" + Fail-Json $result "type is $registryDataType; must be binary, dword, expandstring, multistring, string, or qword" } } Else { - $registryValueType = "string" + $registryDataType = "string" } If ($params.path) { - $registryKeyPath = $params.path + $registryValuePath = $params.path } Else { Fail-Json $result "missing required argument: path" } -Function Test-RegistryValue { +Function Test-RegistryValueData { Param ( [parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()]$Path, @@ -96,16 +96,16 @@ Function Test-RegistryValue { } if($state -eq "present") { - if (Test-Path $registryKeyPath) { - if (Test-RegistryValue -Path $registryKeyPath -Value $registryKeyName) + if (Test-Path $registryValuePath) { + if (Test-RegistryValueData -Path $registryValuePath -Value $registryValueName) { # Changes Type and Value - If ((Get-Item $registryKeyPath).GetValueKind($registryKeyName) -ne $registryValueType) + If ((Get-Item $registryValuePath).GetValueKind($registryValueName) -ne $registryDataType) { Try { - Remove-ItemProperty -Path $registryKeyPath -Name $registryKeyName - New-ItemProperty -Path $registryKeyPath -Name $registryKeyName -Value $registryKeyValue -PropertyType $registryValueType + Remove-ItemProperty -Path $registryValuePath -Name $registryValueName + New-ItemProperty -Path $registryValuePath -Name $registryValueName -Value $registryValueData -PropertyType $registryDataType $result.changed = $true } Catch @@ -114,10 +114,10 @@ if($state -eq "present") { } } # Only Changes Value - ElseIf ((Get-ItemProperty -Path $registryKeyPath | Select-Object -ExpandProperty $registryKeyName) -ne $registryKeyValue) + ElseIf ((Get-ItemProperty -Path $registryValuePath | Select-Object -ExpandProperty $registryValueName) -ne $registryValueData) { Try { - Set-ItemProperty -Path $registryKeyPath -Name $registryKeyName -Value $registryKeyValue + Set-ItemProperty -Path $registryValuePath -Name $registryValueName -Value $registryValueData $result.changed = $true } Catch @@ -130,7 +130,7 @@ if($state -eq "present") { { Try { - New-ItemProperty -Path $registryKeyPath -Name $registryKeyName -Value $registryKeyValue -PropertyType $registryValueType + New-ItemProperty -Path $registryValuePath -Name $registryValueName -Value $registryValueData -PropertyType $registryDataType $result.changed = $true } Catch @@ -143,7 +143,7 @@ if($state -eq "present") { { Try { - New-Item $registryKeyPath -Force | New-ItemProperty -Name $registryKeyName -Value $registryKeyValue -Force -PropertyType $registryValueType + New-Item $registryValuePath -Force | New-ItemProperty -Name $registryValueName -Value $registryValueData -Force -PropertyType $registryDataType $result.changed = $true } Catch @@ -154,12 +154,12 @@ if($state -eq "present") { } else { - if (Test-Path $registryKeyPath) + if (Test-Path $registryValuePath) { - if (Test-RegistryValue -Path $registryKeyPath -Value $registryKeyName) { + if (Test-RegistryValueData -Path $registryValuePath -Value $registryValueName) { Try { - Remove-ItemProperty -Path $registryKeyPath -Name $registryKeyName + Remove-ItemProperty -Path $registryValuePath -Name $registryValueName $result.changed = $true } Catch @@ -171,3 +171,4 @@ else } Exit-Json $result + diff --git a/lib/ansible/modules/extras/windows/win_regedit.py b/lib/ansible/modules/extras/windows/win_regedit.py index 007ddd4e8a9..d8fd3a7c25e 100644 --- a/lib/ansible/modules/extras/windows/win_regedit.py +++ b/lib/ansible/modules/extras/windows/win_regedit.py @@ -25,25 +25,25 @@ DOCUMENTATION = ''' --- module: win_regedit version_added: "2.0" -short_description: Add, Edit, or Remove Registry Key +short_description: Add, Edit, or Remove Registry Value description: - - Add, Edit, or Remove Registry Key using ItemProperties Cmdlets + - Add, Edit, or Remove Registry Value using ItemProperties Cmdlets options: name: description: - - Name of Registry Key + - Name of Registry Value required: true default: null aliases: [] - value: + data: description: - - Value of Registry Key + - Registry Value Data required: false default: null aliases: [] - valuetype: + type: description: - - Type of Registry Key + - Registry Value Data Type required: false choices: - binary @@ -56,13 +56,13 @@ options: aliases: [] path: description: - - Path of Registry Key + - Path of Registry Value required: true default: null aliases: [] state: description: - - State of Registry Key + - State of Registry Value required: false choices: - present @@ -73,29 +73,28 @@ author: "Adam Keech (@smadam813), Josh Ludwig (@joshludwig)" ''' EXAMPLES = ''' - # Add Registry Key (Default is String) + # Add Registry Value (Default is String) win_regedit: - name: testkey - value: 1337 + name: testvalue + data: 1337 path: HKCU:\Software\MyCompany - # Add Registry Key with Type DWord + # Add Registry Value with Type DWord win_regedit: - name: testkey - value: 1337 - valuetype: dword + name: testvalue + data: 1337 + type: dword path: HKCU:\Software\MyCompany - # Edit Registry Key called testkey + # Edit Registry Value called testvalue win_regedit: - name: testkey - value: 8008 + name: testvalue + data: 8008 path: HKCU:\Software\MyCompany - # Remove Registry Key called testkey + # Remove Registry Value called testvalue win_regedit: - name: testkey + name: testvalue path: HKCU:\Software\MyCompany state: absent ''' -