Last active
June 16, 2016 20:11
-
-
Save dannyim/6f25f0d4bc9625cb41a322468f6faaa3 to your computer and use it in GitHub Desktop.
registry key check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::Chef::Recipe.send(:include, Windows::RegistryHelper) | |
registry_key 'foobar' do | |
key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\foobar' | |
action :create | |
end | |
ruby_block 'checkfoobar' do | |
block do | |
if Registry.key_exists?('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\foobar') | |
puts 'registry key exists' | |
else | |
puts 'registry key does not exist' | |
end | |
end | |
action :run | |
subscribes :action, 'resource[foobar]', :immediate | |
end | |
registry_key 'delfoobar' do | |
key 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\foobar' | |
action :delete_key | |
subscribes :action, 'resource[checkfoobar]', :immediate | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment