class Chef::Application::Rehai
Attributes
chef_client_json[R]
Public Instance Methods
run_application()
click to toggle source
The meat of our task, do an ohai run and update the nodes attributes then post back to
# File bin/rehai, line 67 def run_application # Do an ohai run to find the current system state ohai = Ohai::System.new ohai.all_plugins # Create a reference to the node node_name = Chef::Config[:node_name] || ohai[:fqdn] || ohai[:hostname] Chef::Config[:node_name] = node_name node = Chef::Node.find_or_create(node_name) # Clear out existing attributes, some of these may have been deleted node.reset_defaults_and_overrides # Set the new attributes, the second argument here is the list of user # supplied attributes from the command line or possibly a config file node.consume_external_attrs(ohai.data, {}) # Write back to the server node.save # puts Chef::JSONCompat.to_json(node) end
setup_application()
click to toggle source
pull configuration settings from the config file(s), most likely in /etc/chef/client.rb
# File bin/rehai, line 57 def setup_application parse_options ::File::open(config[:config_file]) { |f| Chef::Config.from_file(f.path) Chef::Config.merge!(config) } end