Created
March 9, 2016 14:20
-
-
Save jeremymv2/386d4bbf29b3c793dc20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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