Skip to content

Instantly share code, notes, and snippets.

@dannyim
Last active June 16, 2016 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyim/6f25f0d4bc9625cb41a322468f6faaa3 to your computer and use it in GitHub Desktop.
Save dannyim/6f25f0d4bc9625cb41a322468f6faaa3 to your computer and use it in GitHub Desktop.
registry key check
::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