lib/chef/client.rb in chef-0.7.10 vs lib/chef/client.rb in chef-0.7.12
- old
+ new
@@ -1,7 +1,8 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Christopher Walters (<cw@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -54,10 +55,14 @@
# Do a full run for this Chef::Client. Calls:
#
# * build_node - Get the last known state, merge with local changes
# * register - Make sure we have an openid
# * authenticate - Authenticate with our openid
+ # * sync_library_files - Populate the local cache with all the library files
+ # * sync_provider_files - Populate the local cache with all the provider files
+ # * sync_resource_files - Populate the local cache with all the resource files
+ # * sync_attribute_files - Populate the local cache with all the attribute files
# * sync_definitions - Populate the local cache with all the definitions
# * sync_recipes - Populate the local cache with all the recipes
# * do_attribute_files - Populate the local cache with all attributes, and execute them
# * save_node - Store the new node configuration
# * converge - Bring this system up to date, based on the local cache
@@ -73,10 +78,12 @@
register
authenticate
build_node(@node_name)
save_node
sync_library_files
+ sync_provider_files
+ sync_resource_files
sync_attribute_files
sync_definitions
sync_recipes
save_node
converge
@@ -95,11 +102,11 @@
# === Returns
# true:: Always returns true.
def run_solo
start_time = Time.now
Chef::Log.info("Starting Chef Solo Run")
-
+
determine_node_name
build_node(@node_name, true)
converge(true)
end_time = Time.now
@@ -115,11 +122,11 @@
end
end
def determine_node_name
run_ohai
- unless @safe_name && @node_name
+ unless safe_name && node_name
@node_name ||= @ohai[:fqdn] ? @ohai[:fqdn] : @ohai[:hostname]
@safe_name = @node_name.gsub(/\./, '_')
end
@node_name
end
@@ -322,11 +329,33 @@
def sync_library_files
Chef::Log.debug("Synchronizing libraries")
update_file_cache("libraries", @rest.get_rest("cookbooks/_library_files?node=#{@node.name}"))
true
end
+
+ # Gets all the provider files included in all the cookbooks available on the server,
+ # and loads them.
+ #
+ # === Returns
+ # true:: Always returns true
+ def sync_provider_files
+ Chef::Log.debug("Synchronizing providers")
+ update_file_cache("providers", @rest.get_rest("cookbooks/_provider_files?node=#{@node.name}"))
+ true
+ end
+ # Gets all the resource files included in all the cookbooks available on the server,
+ # and loads them.
+ #
+ # === Returns
+ # true:: Always returns true
+ def sync_resource_files
+ Chef::Log.debug("Synchronizing resources")
+ update_file_cache("resources", @rest.get_rest("cookbooks/_resource_files?node=#{@node.name}"))
+ true
+ end
+
# Gets all the definition files included in all the cookbooks available on the server,
# and loads them.
#
# === Returns
# true:: Always returns true
@@ -370,16 +399,12 @@
Chef::Log.debug("Compiling recipes for node #{@safe_name}")
unless solo
Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
end
compile = Chef::Compile.new(@node)
- compile.load_libraries
- compile.load_attributes
- compile.load_definitions
- compile.load_recipes
-
+
Chef::Log.debug("Converging node #{@safe_name}")
- cr = Chef::Runner.new(@node, compile.collection)
+ cr = Chef::Runner.new(@node, compile.collection, compile.definitions, compile.cookbook_loader)
cr.converge
true
end
protected