Commit 01476e09 authored by Chris Roberts's avatar Chris Roberts
Browse files

Access `run_context` correctly for 10 (#3). Update `resource_collection` properly (#4).

parent d83e0eab
......@@ -15,13 +15,18 @@ class Chef
def allow(val)
node.run_state[:dpkg_autostart_disabled] ||= []
node.run_state[:dpkg_autostart_disabled].push(name) unless val
chef_version = Gem::Version.new(Chef::VERSION)
context = chef_version < Gem::Version.new('11.0.0') ? run_context : node.run_context
begin
node.run_context.resource_collection.lookup('dpkg_autostart[bin_file]')
context.resource_collection.lookup('dpkg_autostart[bin_file]')
true
rescue Chef::Exceptions::ResourceNotFound
bin = Chef::Resource::DpkgAutostart.new('bin_file', node.run_context)
bin.action :create
node.run_context.resource_collection.all_resources.unshift(bin)
current_resources = context.resource_collection.all_resources
[bin, all_resources].flatten.each_with_index do |res, i|
context.resource_collection[i] = res
end
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment