Commit 47688765 authored by Chris Roberts's avatar Chris Roberts
Browse files

Add heavyweight resource/provider. Fix #2

parent 15bb4a67
require 'chef/provider'
class Chef
class Provider
class DpkgAutostart < Chef::Provider
def initialize(*args)
super
end
def load_current_resource
end
def action_run
Chef::Log.debug 'DpkgAutostart: Compat method. Action does nothing.'
end
def action_create
template = Chef::Resource::Template.new('dpkg_autostart_file', run_context)
template.cookbook 'dpkg_autostart'
template.source 'policy-rc.d.erb'
template.path '/usr/sbin/policy-rc.d'
template.mode 0755
template.run_action(:create)
# Force this to the front of the line
end
end
end
end
require 'chef/resource'
class Chef
class Resource
class DpkgAutostart < Chef::Resource
def initialize(name, run_context=nil)
super
@resource_name = :dpkg_autostart
@provider = Chef::Provider::DpkgAutostart
@action = :nothing
@allowed_actions = [:nothing, :create]
end
def allow(val)
node.run_state[:dpkg_autostart_disabled] ||= []
node.run_state[:dpkg_autostart_disabled].push(name) unless val
begin
node.run_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)
end
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