d-i
6/16/2016 - 8:10 PM

registry key check

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