diff options
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/application/apply.rb | 5 | ||||
-rw-r--r-- | lib/puppet/configurer/fact_handler.rb | 7 | ||||
-rw-r--r-- | lib/puppet/defaults.rb | 8 |
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 3f423a4c4..717935640 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -89,6 +89,11 @@ class Puppet::Application::Apply < Puppet::Application 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[:node_name_value]) raise "Could not find node #{Puppet[:node_name_value]}" diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 4d80e17b6..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[:node_name_value]) + 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 17c2850e5..4502dae16 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -487,6 +487,14 @@ 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, |