Skip to content

Instantly share code, notes, and snippets.

@jeremymv2
Created March 9, 2016 14:20
Show Gist options
  • Save jeremymv2/386d4bbf29b3c793dc20 to your computer and use it in GitHub Desktop.
Save jeremymv2/386d4bbf29b3c793dc20 to your computer and use it in GitHub Desktop.
# TODO throwing error:
# Cannot find a resource for to_ary on ubuntu version 12.04
require 'set'
file "/root/chef_resources-#{node.name}.json" do
resource_clxn = Chef::ResourceCollection.new
run_context.resource_collection.each do |r|
next if r.class.to_s == 'Chef::Resource::NodeMetadata'
r = r.dup
r.instance_eval do
content('') if respond_to?(:content)
variables({}) if respond_to?(:variables)
remove_instance_variable('@options') rescue nil
params.delete(:options) if respond_to?(:params)
# if respond_to?(:options)
# begin ; options({}) ; rescue options('') ; end
# end
@delayed_notifications = []
@immediate_notifications = []
end
resource_clxn << r
end
content resource_clxn.to_json(JSON::PRETTY_STATE_PROTOTYPE)+"\n"
action :create
owner 'root'
group 'root'
mode "0600" # only readable by root
end
def walk_resource_path
Chef::Log.info('Resources Used In Order')
run_context.resource_collection.each do |resource|
# puts "resource start"
puts resource.class.name
# puts resource.instance_variables.inspect
# Chef::Log.info(resource.instance_variables.inspect)
# puts "resource stop"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment