From 1b3d7824c03fc5c57cb2aeee070745281810f3c3 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Fri, 13 Aug 2010 03:53:40 +1000 Subject: Updated config.ru example for 2.6.1 --- ext/rack/files/config.ru | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/rack/files/config.ru b/ext/rack/files/config.ru index 995a9f8c5..9dda3da06 100644 --- a/ext/rack/files/config.ru +++ b/ext/rack/files/config.ru @@ -4,7 +4,7 @@ # if puppet is not in your RUBYLIB: # $:.unshift('/opt/puppet/lib') -$0 = "puppetmasterd" +$0 = "master" require 'puppet' # if you want debugging: -- cgit From 5d4f2224a0544d550be0f502fd0defda6697b178 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Fri, 13 Aug 2010 22:06:53 +1000 Subject: Fixed #4527 correctly for 2.6.1 --- ext/rack/files/config.ru | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/rack/files/config.ru b/ext/rack/files/config.ru index 9dda3da06..f9c492dd7 100644 --- a/ext/rack/files/config.ru +++ b/ext/rack/files/config.ru @@ -5,7 +5,6 @@ # $:.unshift('/opt/puppet/lib') $0 = "master" -require 'puppet' # if you want debugging: # ARGV << "--debug" -- cgit From 3df0490c9dbc59e27869e09864177536400a5ae3 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Thu, 5 Aug 2010 11:09:25 -0700 Subject: [#4298] Puppet apply prints an error if the file to apply doesn't exist Also warns you it's skipping files if you pass it more than one file to apply. Reviewed-by: Nick Lewis Signed-off-by: Matt Robinson --- lib/puppet/application/apply.rb | 5 ++++- spec/unit/application/apply_spec.rb | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index bb4186dbd..152b75442 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -78,7 +78,10 @@ class Puppet::Application::Apply < Puppet::Application if options[:code] or command_line.args.length == 0 Puppet[:code] = options[:code] || STDIN.read else - Puppet[:manifest] = command_line.args.shift + manifest = command_line.args.shift + raise "Could not find file #{manifest}" unless File.exist?(manifest) + Puppet.warning("Only one file can be applied per run. Skipping #{command_line.args.join(', ')}") if command_line.args.size > 0 + Puppet[:manifest] = manifest end # Collect our facts. diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 0b00d1a2e..8c53136d0 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/application/apply' +require 'puppet/file_bucket/dipper' describe Puppet::Application::Apply do before :each do @@ -53,7 +54,6 @@ describe Puppet::Application::Apply do Puppet.stubs(:trap) Puppet::Log.stubs(:level=) Puppet.stubs(:parse_config) - require 'lib/puppet/file_bucket/dipper' Puppet::FileBucket::Dipper.stubs(:new) STDIN.stubs(:read) @@ -212,7 +212,8 @@ describe Puppet::Application::Apply do @apply.main end - it "should set the manifest if some files are passed on command line" do + it "should set the manifest if a file is passed on command line and the file exists" do + File.stubs(:exist?).with('site.pp').returns true @apply.command_line.stubs(:args).returns(['site.pp']) Puppet.expects(:[]=).with(:manifest,"site.pp") @@ -220,6 +221,23 @@ describe Puppet::Application::Apply do @apply.main end + it "should raise an error if a file is passed on command line and the file does not exist" do + File.stubs(:exist?).with('noexist.pp').returns false + @apply.command_line.stubs(:args).returns(['noexist.pp']) + lambda { @apply.main }.should raise_error(RuntimeError, 'Could not find file noexist.pp') + end + + it "should set the manifest to the first file and warn other files will be skipped" do + File.stubs(:exist?).with('starwarsIV').returns true + File.expects(:exist?).with('starwarsI').never + @apply.command_line.stubs(:args).returns(['starwarsIV', 'starwarsI', 'starwarsII']) + + Puppet.expects(:[]=).with(:manifest,"starwarsIV") + Puppet.expects(:warning).with('Only one file can be applied per run. Skipping starwarsI, starwarsII') + + @apply.main + end + it "should collect the node facts" do Puppet::Node::Facts.expects(:find).returns(@facts) @@ -232,7 +250,7 @@ describe Puppet::Application::Apply do lambda { @apply.main }.should raise_error end - it "should find the node" do + it "should look for the node" do Puppet::Node.expects(:find).returns(@node) @apply.main -- cgit From 0c3075443c80227c1e35cfb4952d3971c1c0adeb Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 14 Aug 2010 17:31:22 -0700 Subject: Maint. Removing code at the request of the original author A contributor has requested that his changes be removed from puppet. --- ext/puppetlast | 16 ---------------- lib/puppet/indirector/yaml.rb | 11 +---------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100755 ext/puppetlast diff --git a/ext/puppetlast b/ext/puppetlast deleted file mode 100755 index 7434368a3..000000000 --- a/ext/puppetlast +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# Puppetlast, a script to output the last check-in time of nodes. Also outputs the cached configuration state, if expired or not. -# -# AJ "Fujin" Christensen -# -require 'puppet' -require 'time' - -Puppet[:config] = "/etc/puppet/puppet.conf" -Puppet.parse_config -Puppet[:name] = "puppetmasterd" -Puppet::Node::Facts.terminus_class = :yaml - -Puppet::Node::Facts.search("*").sort { |a,b| a.name <=> b.name }.each do |node| - puts "#{node.name} checked in #{((Time.now - Time.parse(node.values[:_timestamp].to_s)) / 60).floor} minutes ago. Version #{node.values['puppetversion']}#{node.expired? ? ' Cache expired.' : ''}" -end diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index c7c053f4b..13f3c1e79 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -41,21 +41,12 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus end end - # Get the yaml directory - def base - Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir] - end - # Return the path to a given node's file. def path(name) + base = Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir] File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml") end - # Do a glob on the yaml directory, loading each file found - def search(request) - Dir.glob(File.join(base, self.class.indirection_name.to_s, request.key)).collect { |f| YAML.load_file(f) } - end - private def from_yaml(text) -- cgit From 82b4f04f6b8fee7ada275fc63e519a08e1c2b0a5 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 14 Aug 2010 18:25:24 -0700 Subject: Maint. -- Fix test failures broken by previous commit This basically involved adding a search method to the yaml indirector, which I did by copying the one from ssl_file and fiddling with it until the tests passed. Since the most straight forward way to do this required extending the interface to the path method I added tests for the additional behaviour. --- lib/puppet/indirector/yaml.rb | 10 ++++++++-- spec/unit/indirector/yaml_spec.rb | 24 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 13f3c1e79..23997e97a 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -42,9 +42,15 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus end # Return the path to a given node's file. - def path(name) + def path(name,ext='.yaml') base = Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir] - File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml") + File.join(base, self.class.indirection_name.to_s, name.to_s + ext) + end + + def search(request) + Dir.glob(path(request.key,'')).collect do |file| + YAML.load_file(file) + end end private diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb index 134d476ba..86c13c5a0 100755 --- a/spec/unit/indirector/yaml_spec.rb +++ b/spec/unit/indirector/yaml_spec.rb @@ -40,6 +40,18 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do @store.path(:me).should =~ %r{^/client/yaml/dir} end + it "should use the extension if one is specified" do + Puppet.run_mode.expects(:master?).returns true + Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir" + @store.path(:me,'.farfignewton').should =~ %r{\.farfignewton$} + end + + it "should assume an extension of .yaml if none is specified" do + Puppet.run_mode.expects(:master?).returns true + Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir" + @store.path(:me).should =~ %r{\.yaml$} + end + it "should store all files in a single file root set in the Puppet defaults" do @store.path(:me).should =~ %r{^#{@dir}} end @@ -120,8 +132,8 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do @request = stub 'request', :key => "*", :instance => @subject @one = mock 'one' @two = mock 'two' - @store.expects(:base).returns "/my/yaml/dir" - Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml two.yaml}) + @store.expects(:path).with(@request.key,'').returns :glob + Dir.expects(:glob).with(:glob).returns(%w{one.yaml two.yaml}) YAML.expects(:load_file).with("one.yaml").returns @one; YAML.expects(:load_file).with("two.yaml").returns @two; @store.search(@request).should == [@one, @two] @@ -130,16 +142,16 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do it "should return an array containing a single instance of fact when globbing 'one*'" do @request = stub 'request', :key => "one*", :instance => @subject @one = mock 'one' - @store.expects(:base).returns "/my/yaml/dir" - Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml}) + @store.expects(:path).with(@request.key,'').returns :glob + Dir.expects(:glob).with(:glob).returns(%w{one.yaml}) YAML.expects(:load_file).with("one.yaml").returns @one; @store.search(@request).should == [@one] end it "should return an empty array when the glob doesn't match anything" do @request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject - @store.expects(:base).returns "/my/yaml/dir" - Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns([]) + @store.expects(:path).with(@request.key,'').returns :glob + Dir.expects(:glob).with(:glob).returns [] @store.search(@request).should == [] end end -- cgit From 57bb06b557c74e227cb0f9799e698aecf90ea9a4 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Mon, 16 Aug 2010 17:15:45 -0700 Subject: [#4545] Remove obsolete 'trac' specs The method that these specs were testing has been removed, causing the specs to fail. --- spec/unit/application/doc_spec.rb | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/spec/unit/application/doc_spec.rb b/spec/unit/application/doc_spec.rb index 7a22f5b2e..55da5e39a 100755 --- a/spec/unit/application/doc_spec.rb +++ b/spec/unit/application/doc_spec.rb @@ -27,10 +27,6 @@ describe Puppet::Application::Doc do @doc.should respond_to(:rdoc) end - it "should declare a trac command" do - @doc.should respond_to(:trac) - end - it "should declare a fallback for unknown options" do @doc.should respond_to(:handle_unknown) end @@ -270,21 +266,6 @@ describe Puppet::Application::Doc do end describe "when running" do - before :each do - end - - describe "in trac mode" do - it "should call trac for each reference" do - ref = stub 'ref' - Puppet::Util::Reference.stubs(:reference).with(:ref).returns(ref) - @doc.options.stubs(:[]).with(:references).returns([:ref]) - @doc.options.stubs(:[]).with(:mode).returns(:trac) - - ref.expects(:trac) - - @doc.trac - end - end describe "in rdoc mode" do before :each do -- cgit From 20f4b903acd91074778f379631cf7545fdff9eb8 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sun, 15 Aug 2010 18:56:26 -0700 Subject: Fix for #4518 -- classes not getting added to compiler.classes The responsibility for adding classes to the compiler's classes list (for use in constructing classes.txt) moved around a bit in the 0.25 to 2.6 transition before being dropped in a merge conflict resolution. Ooops. This restores it, and adds tests to prevent regression. --- lib/puppet/resource/type.rb | 1 + spec/unit/resource/type_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 6296d26e5..f6d378512 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -69,6 +69,7 @@ class Puppet::Resource::Type end scope = subscope(scope, resource) unless resource.title == :main + scope.compiler.add_class(name) unless definition? set_resource_parameters(resource, scope) diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb index 4d3942c5c..f58092ec5 100755 --- a/spec/unit/resource/type_spec.rb +++ b/spec/unit/resource/type_spec.rb @@ -412,6 +412,23 @@ describe Puppet::Resource::Type do @type = Puppet::Resource::Type.new(:hostclass, "foo") end + it "should add hostclass names to the classes list" do + @type.evaluate_code(@resource) + @compiler.catalog.classes.should be_include("foo") + end + + it "should add node names to the classes list" do + @type = Puppet::Resource::Type.new(:node, "foo") + @type.evaluate_code(@resource) + @compiler.catalog.classes.should be_include("foo") + end + + it "should not add defined resource names to the classes list" do + @type = Puppet::Resource::Type.new(:definition, "foo") + @type.evaluate_code(@resource) + @compiler.catalog.classes.should_not be_include("foo") + end + it "should set all of its parameters in a subscope" do subscope = stub 'subscope', :compiler => @compiler @type.expects(:subscope).with(@scope, @resource).returns subscope -- cgit From d1150e0b91626e4f8843f17c413f88efd4a4ba77 Mon Sep 17 00:00:00 2001 From: Peter Meier Date: Thu, 12 Aug 2010 16:48:22 +0200 Subject: fix #4528 - treat * as absent Internally the cron type is seeing params containing only '*', as absent. However, if a user was setting a parameter explicitely as '*', we weren't munging it to be absent. Hence, we were setting this param over and over again. --- lib/puppet/type/cron.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index 9d827df78..c42f0df55 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -169,7 +169,7 @@ Puppet::Type.newtype(:cron) do end if value == "*" - return value + return :absent end return value unless self.class.boundaries -- cgit From 4c280796f71fd2153ae05dfec227fb4123152088 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Tue, 17 Aug 2010 16:19:38 -0700 Subject: [#4555] puppet queue tries to call code it hasn't required puppet queue was trying to call .subscribe on Puppet::Resource::Catalog::Queue, but that object had not been loaded into the ruby interpreter. This bug was partially masked by ruby's confusing constant resolution, which was incorrectly returning the Puppet::Application::Queue class instead of throwing a NameError --- lib/puppet/application/queue.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb index 6df825dd1..6c90ca0a1 100644 --- a/lib/puppet/application/queue.rb +++ b/lib/puppet/application/queue.rb @@ -38,6 +38,7 @@ class Puppet::Application::Queue < Puppet::Application option("--verbose","-v") def main + require 'lib/puppet/indirector/catalog/queue' # provides Puppet::Indirector::Queue.subscribe Puppet.notice "Starting puppetqd #{Puppet.version}" Puppet::Resource::Catalog::Queue.subscribe do |catalog| # Once you have a Puppet::Resource::Catalog instance, calling save on it should suffice -- cgit From 1ea4ccf44bc45ff7ccccc54720391bbe81c8a8fb Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Fri, 13 Aug 2010 14:55:48 +0200 Subject: Start server before agent --- lib/puppet/daemon.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index aa4a12bfa..ad0edd3b9 100755 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -121,8 +121,8 @@ class Puppet::Daemon create_pidfile raise Puppet::DevError, "Daemons must have an agent, server, or both" unless agent or server - agent.start if agent server.start if server + agent.start if agent EventLoop.current.run end -- cgit From 302d657658db068c0c593545e92923659608c5a3 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 21 Aug 2010 14:35:05 -0700 Subject: Fix for #4501 -- reports not generated in standalone The refactors for 2.6.x stopped "puppet apply" from saving reports; this fix adds report saving back to puppet apply but leaves a number of related issues (code path consolidation, report contents, etc.) unresolved for future patches in the 2.6.x series or more significant refactoring in 2.7.x. --- lib/puppet/application/apply.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 152b75442..59a95d35a 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -126,17 +126,22 @@ class Puppet::Application::Apply < Puppet::Application configurer.execute_prerun_command # And apply it + if Puppet[:report] + report = configurer.initialize_report + Puppet::Util::Log.newdestination(report) + end transaction = catalog.apply configurer.execute_postrun_command - status = 0 - if not Puppet[:noop] and options[:detailed_exitcodes] - transaction.generate_report - exit(transaction.report.exit_status) + if Puppet[:report] + Puppet::Util::Log.close(report) + configurer.send_report(report, transaction) else - exit(0) + transaction.generate_report end + + exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? transaction.report.exit_status : 0 ) rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts detail.message -- cgit From 491c31dcbdb0977c0377cb276cfe32a4c24e0e1a Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sun, 22 Aug 2010 10:14:03 -0700 Subject: Fix for #4542 -- included classes weren't assigned proper stages This commit unifies the code paths on which classes are added, alters the default stage to respect the stage of the parent if any, and assures that the resource is notified if its stage is assigned (turning an implicit stage into an explicit one). --- lib/puppet/parser/compiler.rb | 19 ++++++------------- spec/unit/parser/compiler_spec.rb | 13 ++++++++++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 98cad952c..7504b276b 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -56,13 +56,10 @@ class Puppet::Parser::Compiler # Note that this will fail if the resource is not unique. @catalog.add_resource(resource) - set_container_resource(scope, resource) - end - # Add our container edge. If we're a class, then we get treated specially - we can - # control the stage that the class is applied in. Otherwise, we just - # get added to our parent container. - def set_container_resource(scope, resource) + # Add our container edge. If we're a class, then we get treated specially - we can + # control the stage that the class is applied in. Otherwise, we just + # get added to our parent container. return if resource.type.to_s.downcase == "stage" if resource.type.to_s.downcase != "class" @@ -70,15 +67,14 @@ class Puppet::Parser::Compiler return @catalog.add_edge(scope.resource, resource) end - unless stage = @catalog.resource(:stage, resource[:stage] || :main) + unless stage = @catalog.resource(:stage, resource[:stage] || (scope && scope.resource && scope.resource[:stage]) || :main) raise ArgumentError, "Could not find stage #{resource[:stage] || :main} specified by #{resource}" end + resource[:stage] ||= stage.title @catalog.add_edge(stage, resource) end - private :set_container_resource - # Do we use nodes found in the code, vs. the external node sources? def ast_nodes? known_resource_types.nodes? @@ -289,10 +285,7 @@ class Puppet::Parser::Compiler @main_resource = Puppet::Parser::Resource.new("class", :main, :scope => @topscope, :source => @main) @topscope.resource = @main_resource - @resources << @main_resource - @catalog.add_resource(@main_resource) - - set_container_resource(@topscope, @main_resource) + add_resource(@topscope, @main_resource) @main_resource.evaluate end diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb index e8c06dd0b..22d52f257 100755 --- a/spec/unit/parser/compiler_spec.rb +++ b/spec/unit/parser/compiler_spec.rb @@ -430,7 +430,18 @@ describe Puppet::Parser::Compiler do lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError) end - it "should add edges from the class resources to the main stage if no stage is specified" do + it "should add edges from the class resources to the parent's stage if no stage is specified" do + main = @compiler.catalog.resource(:stage, :main) + foo_stage = resource(:stage, :foo_stage) + @compiler.add_resource(@scope, foo_stage) + resource = resource(:class, "foo") + @scope.stubs(:resource).returns(:stage => :foo_stage) + @compiler.add_resource(@scope, resource) + + @compiler.catalog.should be_edge(foo_stage, resource) + end + + it "should add edges from top-level class resources to the main stage if no stage is specified" do main = @compiler.catalog.resource(:stage, :main) resource = resource(:class, "foo") @compiler.add_resource(@scope, resource) -- cgit From c3185584a0c9f22b7deaff022855b160a945486f Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 21 Aug 2010 19:44:06 -0700 Subject: Fix for #4489 -- apply was using the rest terminus Basing pervasive low-level behaviour changes on the application name isn't a good idea, but if we're going to do it we need to remember to update the test when we rename the application. I am not certain that this change is globally correct; there may be other related problems that will not be fixed (and may in fact be exacerbated) by this patch. --- lib/puppet/file_serving/indirection_hooks.rb | 4 ++-- spec/shared_behaviours/file_serving.rb | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/puppet/file_serving/indirection_hooks.rb b/lib/puppet/file_serving/indirection_hooks.rb index 7e0c17916..a85e90ef1 100644 --- a/lib/puppet/file_serving/indirection_hooks.rb +++ b/lib/puppet/file_serving/indirection_hooks.rb @@ -19,8 +19,8 @@ module Puppet::FileServing::IndirectionHooks return PROTOCOL_MAP["file"] if request.key =~ /^#{::File::SEPARATOR}/ return PROTOCOL_MAP["file"] if request.protocol == "file" - # We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'puppet' - if request.protocol == "puppet" and (request.server or Puppet.settings[:name] != "puppet") + # We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet' + if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name])) return PROTOCOL_MAP["puppet"] end diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb index c86453a03..5f5b2b0af 100644 --- a/spec/shared_behaviours/file_serving.rb +++ b/spec/shared_behaviours/file_serving.rb @@ -15,7 +15,7 @@ describe "Puppet::FileServing::Files", :shared => true do @test_class.find(uri) end - it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet'" do + it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet' or 'apply'" do uri = "puppet:///fakemod/my/file" Puppet.settings.stubs(:value).returns "foo" Puppet.settings.stubs(:value).with(:name).returns("puppetd") @@ -35,6 +35,17 @@ describe "Puppet::FileServing::Files", :shared => true do @test_class.find(uri) end + it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'apply'" do + uri = "puppet:///fakemod/my/file" + Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => [])) + Puppet.settings.stubs(:value).returns "" + Puppet.settings.stubs(:value).with(:name).returns("apply") + Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever") + @indirection.terminus(:file_server).expects(:find) + @indirection.terminus(:file_server).stubs(:authorized?).returns(true) + @test_class.find(uri) + end + it "should use the file terminus when the 'file' URI scheme is used" do uri = "file:///fakemod/my/file" @indirection.terminus(:file).expects(:find) -- cgit From 81a27251f9052337ae9e66962a2a1f670e803a50 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sun, 22 Aug 2010 10:48:40 -0700 Subject: Fix for #4456 -- need to accept some mime-type aliases Rather than just creating a handler for the base mime-type (e.g. "text/yaml") we create some synonyms where appropriate (e.g. "text/x-yaml", "application/yaml", etc.) --- lib/puppet/network/format_handler.rb | 6 ++++++ lib/puppet/network/formats.rb | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb index d378ad6a1..b94a4f902 100644 --- a/lib/puppet/network/format_handler.rb +++ b/lib/puppet/network/format_handler.rb @@ -37,6 +37,12 @@ module Puppet::Network::FormatHandler instance end + def self.create_serialized_formats(name,options = {},&block) + ["application/x-#{name}", "application/#{name}", "text/x-#{name}", "text/#{name}"].each { |mime_type| + create name, {:mime => mime_type}.update(options), &block + } + end + def self.extended(klass) klass.extend(ClassMethods) diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index 8a61ee62a..4ca3240d4 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -1,6 +1,6 @@ require 'puppet/network/format_handler' -Puppet::Network::FormatHandler.create(:yaml, :mime => "text/yaml") do +Puppet::Network::FormatHandler.create_serialized_formats(:yaml) do # Yaml doesn't need the class name; it's serialized. def intern(klass, text) YAML.load(text) @@ -29,7 +29,7 @@ end # This is a "special" format which is used for the moment only when sending facts # as REST GET parameters (see Puppet::Configurer::FactHandler). # This format combines a yaml serialization, then zlib compression and base64 encoding. -Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_yaml") do +Puppet::Network::FormatHandler.create_serialized_formats(:b64_zlib_yaml) do require 'base64' def use_zlib? @@ -127,7 +127,7 @@ Puppet::Network::FormatHandler.create(:raw, :mime => "application/x-raw", :weigh end end -Puppet::Network::FormatHandler.create(:pson, :mime => "text/pson", :weight => 10, :required_methods => [:render_method, :intern_method]) do +Puppet::Network::FormatHandler.create_serialized_formats(:pson, :weight => 10, :required_methods => [:render_method, :intern_method]) do confine :true => Puppet.features.pson? def intern(klass, text) @@ -159,4 +159,4 @@ Puppet::Network::FormatHandler.create(:pson, :mime => "text/pson", :weight => 10 end # This is really only ever going to be used for Catalogs. -Puppet::Network::FormatHandler.create(:dot, :mime => "text/dot", :required_methods => [:render_method]) +Puppet::Network::FormatHandler.create_serialized_formats(:dot, :required_methods => [:render_method]) -- cgit From 8be1929043f4560bb17a4b06293b3f9a4efcfdbf Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 25 Aug 2010 12:45:43 +1000 Subject: Updated CHANGELOG for 2.6.1rc3 --- CHANGELOG | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index d7861e04c..3b51e5dc8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,23 @@ +2.6.1rc3 +======== +81a2725 Fix for #4456 -- need to accept some mime-type aliases +c318558 Fix for #4489 -- apply was using the rest terminus +491c31d Fix for #4542 -- included classes weren't assigned proper stages +302d657 Fix for #4501 -- reports not generated in standalone +1ea4ccf Start server before agent +4c28079 [#4555] puppet queue tries to call code it hasn't required +d1150e0 fix #4528 - treat * as absent +20f4b90 Fix for #4518 -- classes not getting added to compiler.classes +57bb06b [#4545] Remove obsolete 'trac' specs +82b4f04 Maint. -- Fix test failures broken by previous commit +0c30754 Maint. Removing code at the request of the original author +3df0490 [#4298] Puppet apply prints an error if the file to apply doesn't exist +5d4f222 Fixed #4527 correctly for 2.6.1 +1b3d782 Updated config.ru example for 2.6.1 + 2.6.1rc2 ======== +0aa27b5 Updated for 2.6.1rc2 252c9b8 Further RST to Markdown fixes for types, values, tests 1157e8d Updated all types to Markdown output fef8800 Updated reference output to generate valid Markdown -- cgit