summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-06-02 16:16:12 -0700
committerNick Lewis <nick@puppetlabs.com>2011-06-06 15:48:58 -0700
commitcd4fe148aae923f1167a3db450b64ead87418018 (patch)
tree84f24295a1767b6bad7daceae012147152186902 /lib/puppet
parenta00fd25547db6dec8fcd57a004fbec58324ce3dc (diff)
downloadpuppet-cd4fe148aae923f1167a3db450b64ead87418018.tar.gz
puppet-cd4fe148aae923f1167a3db450b64ead87418018.tar.xz
puppet-cd4fe148aae923f1167a3db450b64ead87418018.zip
(#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
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application/apply.rb8
-rw-r--r--lib/puppet/configurer.rb4
-rw-r--r--lib/puppet/configurer/fact_handler.rb2
-rw-r--r--lib/puppet/defaults.rb1
-rw-r--r--lib/puppet/transaction/report.rb2
5 files changed, 9 insertions, 8 deletions
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