diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-06-06 15:59:01 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-06-06 15:59:01 -0700 |
| commit | 3d09ca82e57d0c8836b77623d876cd5dc9a3a5e6 (patch) | |
| tree | 8a55f2319be5042200b66e6c547f02ad52ac3c0f /lib | |
| parent | 8ebec1effc8038b1f59537450f3fe27249d543ee (diff) | |
| parent | 1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e (diff) | |
| download | puppet-3d09ca82e57d0c8836b77623d876cd5dc9a3a5e6.tar.gz puppet-3d09ca82e57d0c8836b77623d876cd5dc9a3a5e6.tar.xz puppet-3d09ca82e57d0c8836b77623d876cd5dc9a3a5e6.zip | |
Merge branch 'ticket/2.6.x/2128' into 2.6.x
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/application/apply.rb | 13 | ||||
| -rw-r--r-- | lib/puppet/configurer.rb | 25 | ||||
| -rw-r--r-- | lib/puppet/configurer/fact_handler.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/defaults.rb | 9 | ||||
| -rw-r--r-- | lib/puppet/transaction/report.rb | 2 |
5 files changed, 37 insertions, 19 deletions
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 7f0b95a89..717935640 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -85,13 +85,18 @@ class Puppet::Application::Apply < Puppet::Application end # Collect our facts. - unless facts = Puppet::Node::Facts.find(Puppet[:certname]) - raise "Could not find facts for #{Puppet[:certname]}" + unless facts = Puppet::Node::Facts.find(Puppet[:node_name_value]) + raise "Could not find facts for #{Puppet[:node_name_value]}" + end + + unless Puppet[:node_name_fact].empty? + Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]] + facts.name = Puppet[:node_name_value] end # Find our Node - unless node = Puppet::Node.find(Puppet[:certname]) - raise "Could not find node #{Puppet[:certname]}" + unless node = Puppet::Node.find(Puppet[:node_name_value]) + raise "Could not find node #{Puppet[:node_name_value]}" end # Merge in the facts. diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 9f68ca499..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 @@ -220,7 +219,7 @@ class Puppet::Configurer def retrieve_catalog_from_cache(fact_options) result = nil @duration = thinmark do - result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true)) + result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_terminus => true)) end Puppet.notice "Using cached catalog" result @@ -233,7 +232,7 @@ class Puppet::Configurer def retrieve_new_catalog(fact_options) result = nil @duration = thinmark do - result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_cache => true)) + result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_cache => true)) end result rescue SystemExit,NoMemoryError diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 075a59458..77bd1e5f1 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -16,7 +16,12 @@ module Puppet::Configurer::FactHandler # compile them and then "cache" them on the server. begin reload_facter - Puppet::Node::Facts.find(Puppet[:certname]) + facts = Puppet::Node::Facts.find(Puppet[:node_name_value]) + unless Puppet[:node_name_fact].empty? + Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]] + facts.name = Puppet[:node_name_value] + end + facts rescue SystemExit,NoMemoryError raise rescue Exception => detail diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 2a1ded592..4502dae16 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -486,6 +486,15 @@ module Puppet ) setdefaults(:agent, + :node_name_value => ["$certname", "The name of the node."], + :node_name_fact => { :default => "", + :desc => "The fact to use as the node name.", + :hook => proc do |value| + if !value.empty? and Puppet[:node_name_value] != Puppet[:certname] + raise "Cannot specify both the node_name_value and node_name_fact settings" + end + end + }, :localconfig => { :default => "$statedir/localconfig", :owner => "root", :mode => 0660, diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 16fee42ae..841c56968 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -67,7 +67,7 @@ class Puppet::Transaction::Report @logs = [] @resource_statuses = {} @external_times ||= {} - @host = Puppet[:certname] + @host = Puppet[:node_name_value] @time = Time.now @kind = kind @report_format = 2 |
