summaryrefslogtreecommitdiff
path: root/lib/chef/resource/registry_key.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource/registry_key.rb')
-rw-r--r--lib/chef/resource/registry_key.rb154
1 files changed, 77 insertions, 77 deletions
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index a643ad3344..b78a0c92d2 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -29,94 +29,94 @@ class Chef
description "Use the **registry_key** resource to create and delete registry keys in Microsoft Windows. Note: 64-bit versions of Microsoft Windows have a 32-bit compatibility layer in the registry that reflects and redirects certain keys (and their values) into specific locations (or logical views) of the registry hive.\n\n#{ChefUtils::Dist::Infra::PRODUCT} can access any reflected or redirected registry key. The machine architecture of the system on which #{ChefUtils::Dist::Infra::PRODUCT} is running is used as the default (non-redirected) location. Access to the SysWow64 location is redirected must be specified. Typically, this is only necessary to ensure compatibility with 32-bit applications that are running on a 64-bit operating system.\n\nFor more information, see: [Registry Reflection](https://docs.microsoft.com/en-us/windows/win32/winprog64/registry-reflection)."
examples <<~'DOC'
- **Create a registry key**
-
- ```ruby
- registry_key 'HKEY_LOCAL_MACHINE\\path-to-key\\Policies\\System' do
- values [{
- name: 'EnableLUA',
- type: :dword,
- data: 0
- }]
- action :create
- end
- ```
-
- **Create a registry key with binary data: "\x01\x02\x03"**:
-
- ```ruby
- registry_key 'HKEY_CURRENT_USER\ChefTest' do
- values [{
- :name => "test",
- :type => :binary,
- :data => [0, 1, 2].map(&:chr).join
- }]
- action :create
- end
- ```
+ **Create a registry key**
+
+ ```ruby
+ registry_key 'HKEY_LOCAL_MACHINE\\path-to-key\\Policies\\System' do
+ values [{
+ name: 'EnableLUA',
+ type: :dword,
+ data: 0
+ }]
+ action :create
+ end
+ ```
- **Create 32-bit key in redirected wow6432 tree**
+ **Create a registry key with binary data: "\x01\x02\x03"**:
- In 64-bit versions of Microsoft Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Example is a re-directed key. In the following examples, because HKEY_LOCAL_MACHINE\SOFTWARE\Example is a 32-bit key, the output will be “Found 32-bit key” if they are run on a version of Microsoft Windows that is 64-bit:
+ ```ruby
+ registry_key 'HKEY_CURRENT_USER\ChefTest' do
+ values [{
+ :name => "test",
+ :type => :binary,
+ :data => [0, 1, 2].map(&:chr).join
+ }]
+ action :create
+ end
+ ```
- ```ruby
- registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Example' do
- architecture :i386
- recursive true
- action :create
- end
- ```
-
- **Set proxy settings to be the same as those used by #{ChefUtils::Dist::Infra::PRODUCT}**
-
- ```ruby
- proxy = URI.parse(Chef::Config[:http_proxy])
- registry_key 'HKCU\Software\Microsoft\path\to\key\Internet Settings' do
- values [{name: 'ProxyEnable', type: :reg_dword, data: 1},
- {name: 'ProxyServer', data: "#{proxy.host}:#{proxy.port}"},
- {name: 'ProxyOverride', type: :reg_string, data: <local>},
- ]
- action :create
- end
- ```
+ **Create 32-bit key in redirected wow6432 tree**
- **Set the name of a registry key to "(Default)"**
+ In 64-bit versions of Microsoft Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Example is a re-directed key. In the following examples, because HKEY_LOCAL_MACHINE\SOFTWARE\Example is a 32-bit key, the output will be “Found 32-bit key” if they are run on a version of Microsoft Windows that is 64-bit:
- ```ruby
- registry_key 'Set (Default) value' do
- key 'HKLM\Software\Test\Key\Path'
- values [
- {name: '', type: :string, data: 'test'},
- ]
- action :create
- end
- ```
+ ```ruby
+ registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Example' do
+ architecture :i386
+ recursive true
+ action :create
+ end
+ ```
+
+ **Set proxy settings to be the same as those used by #{ChefUtils::Dist::Infra::PRODUCT}**
+
+ ```ruby
+ proxy = URI.parse(Chef::Config[:http_proxy])
+ registry_key 'HKCU\Software\Microsoft\path\to\key\Internet Settings' do
+ values [{name: 'ProxyEnable', type: :reg_dword, data: 1},
+ {name: 'ProxyServer', data: "#{proxy.host}:#{proxy.port}"},
+ {name: 'ProxyOverride', type: :reg_string, data: <local>},
+ ]
+ action :create
+ end
+ ```
- **Delete a registry key value**
+ **Set the name of a registry key to "(Default)"**
- ```ruby
- registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\path\to\key\AU' do
- values [{
- name: 'NoAutoRebootWithLoggedOnUsers',
- type: :dword,
- data: ''
- }]
- action :delete
- end
- ```
+ ```ruby
+ registry_key 'Set (Default) value' do
+ key 'HKLM\Software\Test\Key\Path'
+ values [
+ {name: '', type: :string, data: 'test'},
+ ]
+ action :create
+ end
+ ```
+
+ **Delete a registry key value**
+
+ ```ruby
+ registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\path\to\key\AU' do
+ values [{
+ name: 'NoAutoRebootWithLoggedOnUsers',
+ type: :dword,
+ data: ''
+ }]
+ action :delete
+ end
+ ```
- Note: If data: is not specified, you get an error: Missing data key in RegistryKey values hash
+ Note: If data: is not specified, you get an error: Missing data key in RegistryKey values hash
- **Delete a registry key and its subkeys, recursively**
+ **Delete a registry key and its subkeys, recursively**
- ```ruby
- registry_key 'HKCU\SOFTWARE\Policies\path\to\key\Themes' do
- recursive true
- action :delete_key
- end
- ```
+ ```ruby
+ registry_key 'HKCU\SOFTWARE\Policies\path\to\key\Themes' do
+ recursive true
+ action :delete_key
+ end
+ ```
- Note: Be careful when using the :delete_key action with the recursive attribute. This will delete the registry key, all of its values and all of the names, types, and data associated with them. This cannot be undone by #{ChefUtils::Dist::Infra::PRODUCT}.
+ Note: Be careful when using the :delete_key action with the recursive attribute. This will delete the registry key, all of its values and all of the names, types, and data associated with them. This cannot be undone by #{ChefUtils::Dist::Infra::PRODUCT}.
DOC
default_action :create