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 --- spec/integration/defaults_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/integration') diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb index 2f30014e8..572d98cde 100755 --- a/spec/integration/defaults_spec.rb +++ b/spec/integration/defaults_spec.rb @@ -23,6 +23,13 @@ describe "Puppet defaults" do end end + describe "when setting :node_name_value" do + it "should default to the value of :certname" do + Puppet.settings[:certname] = 'blargle' + Puppet.settings[:node_name_value].should == 'blargle' + end + end + describe "when configuring the :crl" do it "should warn if :cacrl is set to false" do Puppet.expects(:warning) -- cgit From 1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 2 Jun 2011 16:24:16 -0700 Subject: (#2128) Add support for setting node name based on a fact This adds the node_name_fact setting, which specifies a fact to use to determine the node name. This allows dynamically determining the node name without having to modify puppet.conf or command line options. Using this setting requires modifying auth.conf to allow nodes to request catalogs not matching their certnames. For example, this would allow any authenticated node to retrieve any catalog: # $confdir/auth.conf path ~ /catalog/.+ allow * The node_name_fact and node_name_value options are mutually exclusive, because it is ambiguous which setting should take precedence. Paired-With: Jacob Helwig --- spec/integration/defaults_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec/integration') diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb index 572d98cde..3178fca11 100755 --- a/spec/integration/defaults_spec.rb +++ b/spec/integration/defaults_spec.rb @@ -30,6 +30,21 @@ describe "Puppet defaults" do end end + describe "when setting the :node_name_fact" do + it "should fail when also setting :node_name_value" do + lambda do + Puppet.settings[:node_name_value] = "some value" + Puppet.settings[:node_name_fact] = "some_fact" + end.should raise_error("Cannot specify both the node_name_value and node_name_fact settings") + end + + it "should not fail when using the default for :node_name_value" do + lambda do + Puppet.settings[:node_name_fact] = "some_fact" + end.should_not raise_error + end + end + describe "when configuring the :crl" do it "should warn if :cacrl is set to false" do Puppet.expects(:warning) -- cgit