summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-31 22:25:59 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-07-31 22:25:59 +0000
commitf974ffc950235e55274a3abf4bc360af4557d5c8 (patch)
treea87e84d06c3c53b7667700a102934fc9bc05467c
parenteb8c6878c37bf32dc2a7079ce1b0b959774d6fde (diff)
downloadpuppet-f974ffc950235e55274a3abf4bc360af4557d5c8.tar.gz
puppet-f974ffc950235e55274a3abf4bc360af4557d5c8.tar.xz
puppet-f974ffc950235e55274a3abf4bc360af4557d5c8.zip
Fixing the master server so that it always uses the Facter hostname, not the cert or IP hostname.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1433 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/server/master.rb8
-rw-r--r--lib/puppet/util.rb2
-rw-r--r--test/server/master.rb39
3 files changed, 44 insertions, 5 deletions
diff --git a/lib/puppet/server/master.rb b/lib/puppet/server/master.rb
index 72f7e7abf..8de8c080d 100644
--- a/lib/puppet/server/master.rb
+++ b/lib/puppet/server/master.rb
@@ -97,6 +97,7 @@ class Server
# XXX this should definitely be done in the protocol, somehow
case format
when "marshal":
+ Puppet.warning "You should upgrade your client. 'Marshal' will not be supported much longer."
begin
facts = Marshal::load(CGI.unescape(facts))
rescue => detail
@@ -119,10 +120,9 @@ class Server
end
end
- unless client
- client = facts["hostname"]
- clientip = facts["ipaddress"]
- end
+ # Always use the hostname from Facter.
+ client = facts["hostname"]
+ clientip = facts["ipaddress"]
# Add any server-side facts to our server.
addfacts(facts)
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index b3ad8ec39..03ef93d21 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -342,7 +342,7 @@ module Util
end
# Only benchmark if our log level is high enough
- if Puppet::Log.sendlevel?(level)
+ if level != :none and Puppet::Log.sendlevel?(level)
result = nil
seconds = Benchmark.realtime {
yield
diff --git a/test/server/master.rb b/test/server/master.rb
index 18e23311c..dd2b283bd 100644
--- a/test/server/master.rb
+++ b/test/server/master.rb
@@ -195,6 +195,45 @@ class TestMaster < Test::Unit::TestCase
assert(facts.include?(fact), "Fact %s was not set" % fact)
end
end
+
+ # Make sure we're using the facter hostname
+ def test_facterhostname_in_getconfig
+ master = nil
+ file = tempfile()
+ #@createdfile = File.join(tmpdir(), self.class.to_s + "manifesttesting" +
+ # "_" + @method_name)
+ nope = tempfile()
+ yep = tempfile()
+
+ fakename = "y4yn3ss"
+ realname = Facter["hostname"].value
+
+ File.open(file, "w") { |f|
+ f.puts %{
+ node #{fakename} { file { "#{nope}": ensure => file, mode => 755 } }
+ node #{realname} { file { "#{yep}": ensure => file, mode => 755 } }
+}
+ }
+ # create our master
+ assert_nothing_raised() {
+ # this is the default server setup
+ master = Puppet::Server::Master.new(
+ :Manifest => file,
+ :UseNodes => true,
+ :Local => true
+ )
+ }
+
+ result = nil
+ assert_nothing_raised {
+ result = master.getconfig({"hostname" => realname}, "yaml", fakename, "127.0.0.1")
+ }
+
+ result = result.flatten
+
+ assert(result.find { |obj| obj.name == yep },
+ "Could not find correct file")
+ end
end
# $Id$