diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-06-02 16:16:12 -0700 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-06-06 15:48:58 -0700 |
commit | cd4fe148aae923f1167a3db450b64ead87418018 (patch) | |
tree | 84f24295a1767b6bad7daceae012147152186902 /spec | |
parent | a00fd25547db6dec8fcd57a004fbec58324ce3dc (diff) | |
download | puppet-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 'spec')
-rwxr-xr-x | spec/integration/defaults_spec.rb | 7 | ||||
-rwxr-xr-x | spec/unit/application/apply_spec.rb | 4 | ||||
-rwxr-xr-x | spec/unit/configurer/fact_handler_spec.rb | 11 | ||||
-rwxr-xr-x | spec/unit/configurer_spec.rb | 6 | ||||
-rwxr-xr-x | spec/unit/transaction/report_spec.rb | 6 |
5 files changed, 26 insertions, 8 deletions
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) diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 5bd902a03..83a5ded7f 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -192,10 +192,10 @@ describe Puppet::Application::Apply do Puppet::Node::Facts.terminus_class = :memory Puppet::Node.terminus_class = :memory - @facts = Puppet::Node::Facts.new(Puppet[:certname]) + @facts = Puppet::Node::Facts.new(Puppet[:node_name_value]) @facts.save - @node = Puppet::Node.new(Puppet[:certname]) + @node = Puppet::Node.new(Puppet[:node_name_value]) @node.save @catalog = Puppet::Resource::Catalog.new diff --git a/spec/unit/configurer/fact_handler_spec.rb b/spec/unit/configurer/fact_handler_spec.rb index 241da57d6..ddb541174 100755 --- a/spec/unit/configurer/fact_handler_spec.rb +++ b/spec/unit/configurer/fact_handler_spec.rb @@ -50,6 +50,17 @@ describe Puppet::Configurer::FactHandler do Puppet::Node::Facts.terminus_class = :memory end + it "should use the node name value to retrieve the facts" do + foo_facts = Puppet::Node::Facts.new('foo') + bar_facts = Puppet::Node::Facts.new('bar') + foo_facts.save + bar_facts.save + Puppet[:certname] = 'foo' + Puppet[:node_name_value] = 'bar' + + @facthandler.find_facts.should == bar_facts + end + it "should reload Facter before finding facts" do @facthandler.expects(:reload_facter) diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb index 1504ae5c0..6c4f9b90a 100755 --- a/spec/unit/configurer_spec.rb +++ b/spec/unit/configurer_spec.rb @@ -77,7 +77,7 @@ describe Puppet::Configurer do Puppet.settings.stubs(:use).returns(true) @agent.stubs(:prepare) Puppet::Node::Facts.terminus_class = :memory - @facts = Puppet::Node::Facts.new(Puppet[:certname]) + @facts = Puppet::Node::Facts.new(Puppet[:node_name_value]) @facts.save @catalog = Puppet::Resource::Catalog.new @@ -392,9 +392,9 @@ describe Puppet::Configurer do @agent.retrieve_catalog end - it "should use its certname to retrieve the catalog" do + it "should use its node_name_value to retrieve the catalog" do Facter.stubs(:value).returns "eh" - Puppet.settings[:certname] = "myhost.domain.com" + Puppet.settings[:node_name_value] = "myhost.domain.com" Puppet::Resource::Catalog.expects(:find).with { |name, options| name == "myhost.domain.com" }.returns @catalog @agent.retrieve_catalog diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb index 81efa340e..26d90acb4 100755 --- a/spec/unit/transaction/report_spec.rb +++ b/spec/unit/transaction/report_spec.rb @@ -9,9 +9,9 @@ describe Puppet::Transaction::Report do Puppet::Util::Storage.stubs(:store) end - it "should set its host name to the certname" do - Puppet.settings.expects(:value).with(:certname).returns "myhost" - Puppet::Transaction::Report.new("apply").host.should == "myhost" + it "should set its host name to the node_name_value" do + Puppet[:node_name_value] = 'mynode' + Puppet::Transaction::Report.new("apply").host.should == "mynode" end it "should return its host name as its name" do |