From cd4fe148aae923f1167a3db450b64ead87418018 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 2 Jun 2011 16:16:12 -0700 Subject: (#2128) Add the ability to specify a node name The setting node_name_value may now be used for 'puppet apply' or 'puppet agent' to specify the name for the node. This will not affect the certificate used by the node, and the node will still be authenticated based on its certname. The default value for node_name_value is the certname. This is useful for eg. EC2 nodes whose random hostnames cannot be easily used to classify them. Paired-With: Jacob Helwig --- lib/puppet/application/apply.rb | 8 ++++---- lib/puppet/configurer.rb | 4 ++-- lib/puppet/configurer/fact_handler.rb | 2 +- lib/puppet/defaults.rb | 1 + lib/puppet/transaction/report.rb | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 7f0b95a89..3f423a4c4 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -85,13 +85,13 @@ 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 # 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..d0251de82 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -220,7 +220,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 +233,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..4d80e17b6 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -16,7 +16,7 @@ module Puppet::Configurer::FactHandler # compile them and then "cache" them on the server. begin reload_facter - Puppet::Node::Facts.find(Puppet[:certname]) + Puppet::Node::Facts.find(Puppet[:node_name_value]) rescue SystemExit,NoMemoryError raise rescue Exception => detail diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 2a1ded592..17c2850e5 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -486,6 +486,7 @@ module Puppet ) setdefaults(:agent, + :node_name_value => ["$certname", "The name of the node."], :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 -- cgit