summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-06-02 16:23:34 -0700
committerNick Lewis <nick@puppetlabs.com>2011-06-06 15:49:08 -0700
commitc629958fb45f9ae3581f01835bf89654dd7967b7 (patch)
tree959a62362d5fc5e0dd235793c72696d16647c217 /lib
parentcd4fe148aae923f1167a3db450b64ead87418018 (diff)
downloadpuppet-c629958fb45f9ae3581f01835bf89654dd7967b7.tar.gz
puppet-c629958fb45f9ae3581f01835bf89654dd7967b7.tar.xz
puppet-c629958fb45f9ae3581f01835bf89654dd7967b7.zip
(#2128) Get facts before retrieving catalog
Retrieving a catalog and getting the facts to submit with the catalog request are distinct operations, and should be done separately. This is also to prepare for adding the ability to determine the node name based on a fact, in which case the node name needs to be determined before it is used for either the catalog or the report. Paired-With: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/configurer.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index d0251de82..596d2dc53 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -84,16 +84,8 @@ class Puppet::Configurer
end
# Get the remote catalog, yo. Returns nil if no catalog can be found.
- def retrieve_catalog
- if Puppet::Resource::Catalog.indirection.terminus_class == :rest
- # This is a bit complicated. We need the serialized and escaped facts,
- # and we need to know which format they're encoded in. Thus, we
- # get a hash with both of these pieces of information.
- fact_options = facts_for_uploading
- else
- fact_options = {}
- end
-
+ def retrieve_catalog(fact_options)
+ fact_options ||= {}
# First try it with no cache, then with the cache.
unless (Puppet[:use_cached_catalog] and result = retrieve_catalog_from_cache(fact_options)) or result = retrieve_new_catalog(fact_options)
if ! Puppet[:usecacheonfailure]
@@ -130,13 +122,20 @@ class Puppet::Configurer
Puppet.err "Failed to prepare catalog: #{detail}"
end
+ if Puppet::Resource::Catalog.indirection.terminus_class == :rest
+ # This is a bit complicated. We need the serialized and escaped facts,
+ # and we need to know which format they're encoded in. Thus, we
+ # get a hash with both of these pieces of information.
+ fact_options = facts_for_uploading
+ end
+
options[:report] ||= Puppet::Transaction::Report.new("apply")
report = options[:report]
Puppet::Util::Log.newdestination(report)
if catalog = options[:catalog]
options.delete(:catalog)
- elsif ! catalog = retrieve_catalog
+ elsif ! catalog = retrieve_catalog(fact_options)
Puppet.err "Could not retrieve catalog; skipping run"
return
end