Best unofficial Apache Server developers community |
| Aug 12, 2010 | |||
|
Paul Berry |
|
||
| Tags: | |||
Similar Threads
PATCH/puppet 1/1] [#4149] TypeCollection should assign itself to its environment as the known_resou
Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
lib/puppet/node/environment.rb | 4 ++++
lib/puppet/resource/type_collection.rb | 2 ++
spec/unit/node/environment_spec.rb | 2 ++
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/puppet/node/environment.rb
b/lib/puppet/node/environment.rb
index 81f8f2c..eacbb97 100644
--- a/lib/puppet/node/environment.rb
+++ b/lib/puppet/node/environment.rb
@@ -77,6 +77,10 @@ class Puppet::Node::Environment
@known_resource_types
end
+ def known_resource_types=(type_collection)
+ @known_resource_types = type_collection
+ end
+
def module(name)
mod = Puppet::Module.new(name, self)
return nil unless mod.exist?
diff --git a/lib/puppet/resource/type_collection.rb
b/lib/puppet/resource/type_collection.rb
index 4dbf753..1ee1173 100644
--- a/lib/puppet/resource/type_collection.rb
+++ b/lib/puppet/resource/type_collection.rb
@@ -9,6 +9,8 @@ class Puppet::Resource::TypeCollection
def initialize(env)
@environment = env.is_a?(String) ?
Puppet::Node::Environment.new(env) : env
+ @environment.known_resource_types = self
+
@hostclasses = {}
@definitions = {}
@nodes = {}
diff --git a/spec/unit/node/environment_spec.rb
b/spec/unit/node/environment_spec.rb
index d0db250..86dbf27 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -56,6 +56,7 @@ describe Puppet::Node::Environment do
end
it "should create a resource type collection if none exists" do
+ @env.known_resource_types = nil
Puppet::Resource::TypeCollection.expects(:new).with(@env).returns
@collection
@env.known_resource_types.should equal(@collection)
end
@@ -65,6 +66,7 @@ describe Puppet::Node::Environment do
end
it "should perform the initial import when creating a new
collection" do
+ @env.known_resource_types = nil
@collection.expects(:perform_initial_import)
Puppet::Resource::TypeCollection.expects(:new).returns
@collection
PATCH/puppet 1/1] [#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the AST re
Move type-name resolution out of Puppet::Resource into the AST resources. Move find_resource_type out of Puppet::Resource into Scope Thus, never pass unqualified type names to Puppet::Resource objects. Thus, Puppet::Resource objects don't need the namespace property, and Puppet::Resource objects never consult the harddrive to look for .pp files that might contain their type definitions, Thus, performance is improved. Also removes the temporary fix for #4257 that caused #4397 (The code was too eager to look for a class in the topscope) Paired-With: Paul Berry <pa### @puppetlabs.com> Signed-off-by: Jesse Wolfe <jes### @gmail.com> --- lib/puppet/parser/ast/resource.rb | 6 +- lib/puppet/parser/ast/resource_reference.rb | 25 ++++- lib/puppet/parser/resource.rb | 6 +- lib/puppet/parser/scope.rb | 14 +++ lib/puppet/resource.rb | 128 +++
PATCH/puppet 1/1] [#4247] storeconfigs was calling Puppet::Parser::Resource.new with the wrong argu
When the interface to Puppet::Resource changed, its subclass
Puppet::Parser::Resource was also affected. One case of initializing
those objects did not get updated when the code changed, causing
storeconfigs to break.
Also, this patch adds a error message that would have made it easier to
catch this problem (as puppet could consume all memory and die trying to
print the old error message)
Signed-off-by: Jesse Wolfe <jes5### @gmail.com>
---
lib/puppet/rails/resource.rb | 6 +++---
lib/puppet/resource.rb | 3 +++
spec/unit/rails/resource_spec.rb | 16 ++++++++++++++++
spec/unit/resource_spec.rb | 6 ++++++
4 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index a5cdd0c..cac9de2 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -212,16 +212,16 @@ class Puppet::Rails::Resource <
ActiveRecord::Base
end
hash[:scope] = scope
hash[:source] = scope.source
- hash[:params] = []
+ hash[:parameters] = []
names = []
self.param_names.each do |pname|
# We can get the same name multiple times because of how the
# db layout works.
next if names.include?(pname.name)
names << pname.name
- hash[:params] << pname.to_resourceparam(self, scope.source)
+ hash[:parameters] << pname.to_resourceparam(self,
scope.source)
end
- obj = Puppet::Parser::Resource.new(hash)
+ obj = Puppet::Parser::Resource.new(hash["type"], hash["title"], hash)
# Store the ID, so we can check if we're re-collecting the same
resource.
obj.rails_id = self.id
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 31237e3..d68e0ee 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -409,6 +409,9 @@ class Puppet::Resource
if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1,
$2 ]
elsif argtitle then [
argtype, argtitle ]
elsif argtype.is_a?(Puppet::Type) then [
argtype.class.name, argtype.title ]
+ elsif argtype.is_a?(Hash) then
+ raise ArgumentError, "Puppet::Resource.new does not take a hash as
the first argument. "+
+ "Did you mean (#{(argtype[:type] || argtype["type"]).inspect},
#{(argtype[:title] || argtype["title"]).inspect }) ?"
else raise ArgumentError, "No title provided and #{argtype.inspect}
is not a valid resource reference"
end
end
diff --git a/spec/unit/rails/resource_spec.rb
b/spec/unit/rails/resource_spec.rb
index ac74693..08deda6 100755
--- a/spec/unit/rails/resource_spec.rb
+++ b/spec/unit/rails/resource_spec.rb
@@ -104,4 +104,20 @@ describe "Puppet::Rails::Resource" do
@resource.merge_parameters(merge_resource)
end
end
+
+ describe "#to_resource" do
+ it "should instantiate a Puppet::Parser::Resource" do
+ scope = stub "scope", :source => nil
+
+ @resource = Puppet::Rails::Resource.new
+ @resource.stubs(:attributes).returns({
+ "restype" => 'notify',
+ "title" => 'hello'
+ })
+ @resource.stubs(:param_names).returns([])
+
+ @resource.to_resource(scope).should be_a(Puppet::Parser::Resource)
+
+ end
+ end
end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 95f0dd0..204a2b0 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -98,6 +98,12 @@ describe Puppet::Resource do
lambda { Puppet::Resource.new("foo") }.should
raise_error(ArgumentError)
end
+ it "should fail if the title is a hash and the type is not a valid
resource reference string" do
+ lambda { Puppet::Resource.new({:type => "foo", :title =>
"bar"}) }.should raise_error(ArgumentError,
+ 'Puppet::Resource.new does not take a hash as the first argument.
Did you mean ("foo", "bar") ?'
+ )
+ end
+
it "should be able to produce a backward-compatible reference array" do
Puppet::Resource.new("foobar", "/f").to_trans_ref.should == %w{Foobar
/f}
end
unique behavior on puppet agent running on puppet master node
(reposted from irc) Having just upgraded to 2.6, I am seeing different behavior between the agent running on the master node and the rest of the agents. Most importantly, it complains about "warning: You cannot collect without storeconfigs being set" even though storeconfigs=true in the [master] section of puppet.conf Less important, but still curious: the logging is quite different, including lots of "info: Automatically imported <blah>" lines). my puppet.conf: http://pastebin.com/nLZu9zrf ~jon
PATCH/puppet 1/1] [#4467] Make Puppet Master respect facts_terminus settings
* Remove hard-coded facts terminus in master
* Change facts_terminus default to 'yaml' for master and 'facter' for
everything else.
Paired-with: Matt Robinson <ma### @puppetlabs.com>
Signed-off-by: Rein Henrichs <re### @puppetlabs.com>
---
lib/puppet/application/master.rb | 3 ---
lib/puppet/defaults.rb | 2 +-
spec/unit/indirector/node/ldap_spec.rb | 4 ----
spec/unit/node/facts_spec.rb | 15 +++++++++++++--
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/lib/puppet/application/master.rb
b/lib/puppet/application/master.rb
index 777a50e..fde4749 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -138,9 +138,6 @@ class Puppet::Application::Master <
Puppet::Application
Puppet.settings.use :main, :master, :ssl
- # A temporary solution, to at least make the master work for now.
- Puppet::Node::Facts.terminus_class = :yaml
-
# Cache our nodes in yaml. Currently not configurable.
Puppet::Node.cache_class = :yaml
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 84e2d93..3c79439 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -115,7 +115,7 @@ module Puppet
:node_terminus => ["plain", "Where to find information about
nodes."],
:catalog_terminus => ["compiler", "Where to get node catalogs.
This is useful to change if, for instance,
you'd like to pre-compile catalogs and store them in memcached or
some other easily-accessed store."],
- :facts_terminus => ["facter", "Where to get node facts."],
+ :facts_terminus => [Puppet.application_name.to_s == "master" ?
'yaml' : 'facter', "The node facts terminus."],
:httplog => { :default => "$logdir/http.log",
:owner => "root",
:mode => 0640,
diff --git a/spec/unit/indirector/node/ldap_spec.rb
b/spec/unit/indirector/node/ldap_spec.rb
index f9c5efa..a5f14fc 100755
--- a/spec/unit/indirector/node/ldap_spec.rb
+++ b/spec/unit/indirector/node/ldap_spec.rb
@@ -5,10 +5,6 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/indirector/node/ldap'
describe Puppet::Node::Ldap do
- before do
- Puppet::Node::Facts.stubs(:terminus_class).returns :yaml
- end
-
describe "when searching for a single node" do
before :each do
@searcher = Puppet::Node::Ldap.new
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index a2f4ab9..394db79 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -88,9 +88,20 @@ describe Puppet::Node::Facts, "when indirecting" do
@facts.save
end
- it "should default to the 'facter' terminus" do
- Puppet::Node::Facts.indirection.terminus_class.should == :facter
+ describe "when the Puppet application is 'master'" do
+ it "should default to the 'yaml' terminus" do
+ pending "Cannot test the behavior of defaults in defaults.rb"
+ # Puppet::Node::Facts.indirection.terminus_class.should == :yaml
+ end
end
+
+ describe "when the Puppet application is not 'master'" do
+ it "should default to the 'facter' terminus" do
+ pending "Cannot test the behavior of defaults in defaults.rb"
+ # Puppet::Node::Facts.indirection.terminus_class.should ==
:facter
+ end
+ end
+
end
describe "when storing and retrieving" do
PATCH/puppet 1/1] [#4264] Fix failing specs run as root due to missing puppet group
These specs 'use' some settings which create directories belonging
to the 'service' user/group. If the default service group doesn't
exist, these fail. This patch explicitly sets the service group to
the gid of the process, which is known to be accessible by the user.
Signed-off-by: Nick Lewis <ni### @puppetlabs.com>
---
.../indirector/bucket_file/rest_spec.rb | 1 +
.../indirector/certificate/rest_spec.rb | 1 +
.../indirector/certificate_request/rest_spec.rb | 1 +
.../certificate_revocation_list/rest_spec.rb | 1 +
spec/integration/indirector/report/rest_spec.rb | 1 +
spec/integration/indirector/rest_spec.rb | 1 +
spec/integration/network/server/webrick_spec.rb | 1 +
spec/integration/ssl/certificate_authority_spec.rb | 1 +
spec/integration/ssl/certificate_request_spec.rb | 1 +
.../ssl/certificate_revocation_list_spec.rb | 1 +
spec/integration/ssl/host_spec.rb | 1 +
11 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/spec/integration/indirector/bucket_file/rest_spec.rb
b/spec/integration/indirector/bucket_file/rest_spec.rb
index 4d90a8c..dc10faa 100644
--- a/spec/integration/indirector/bucket_file/rest_spec.rb
+++ b/spec/integration/indirector/bucket_file/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Filebucket REST Terminus" do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git a/spec/integration/indirector/certificate/rest_spec.rb
b/spec/integration/indirector/certificate/rest_spec.rb
index 356a7d3..58aa96c 100755
--- a/spec/integration/indirector/certificate/rest_spec.rb
+++ b/spec/integration/indirector/certificate/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Certificate REST Terminus" do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git a/spec/integration/indirector/certificate_request/rest_spec.rb
b/spec/integration/indirector/certificate_request/rest_spec.rb
index 2c98ef6..c718b78 100755
--- a/spec/integration/indirector/certificate_request/rest_spec.rb
+++ b/spec/integration/indirector/certificate_request/rest_spec.rb
@@ -19,6 +19,7 @@ describe "Certificate Request REST Terminus" do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git
a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
index 62a2f80..86f2b01 100755
--- a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
+++ b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Certificate REST Terminus" do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git a/spec/integration/indirector/report/rest_spec.rb
b/spec/integration/indirector/report/rest_spec.rb
index 089f8fd..fdc2189 100644
--- a/spec/integration/indirector/report/rest_spec.rb
+++ b/spec/integration/indirector/report/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Report REST Terminus" do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git a/spec/integration/indirector/rest_spec.rb
b/spec/integration/indirector/rest_spec.rb
index e904839..14e9e95 100755
--- a/spec/integration/indirector/rest_spec.rb
+++ b/spec/integration/indirector/rest_spec.rb
@@ -39,6 +39,7 @@ describe Puppet::Indirector::REST do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet.settings[:server] = "127.0.0.1"
Puppet.settings[:masterport] = "34343"
diff --git a/spec/integration/network/server/webrick_spec.rb
b/spec/integration/network/server/webrick_spec.rb
index 2809df7..2b14dfb 100755
--- a/spec/integration/network/server/webrick_spec.rb
+++ b/spec/integration/network/server/webrick_spec.rb
@@ -18,6 +18,7 @@ describe Puppet::Network::Server do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet::SSL::Host.ca_location = :local
diff --git a/spec/integration/ssl/certificate_authority_spec.rb
b/spec/integration/ssl/certificate_authority_spec.rb
index be82b5f..fca17b4 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::CertificateAuthority do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet::SSL::Host.ca_location = :local
@ca = Puppet::SSL::CertificateAuthority.new
diff --git a/spec/integration/ssl/certificate_request_spec.rb
b/spec/integration/ssl/certificate_request_spec.rb
index 365ecce..8426b9d 100755
--- a/spec/integration/ssl/certificate_request_spec.rb
+++ b/spec/integration/ssl/certificate_request_spec.rb
@@ -21,6 +21,7 @@ describe Puppet::SSL::CertificateRequest do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet::SSL::Host.ca_location = :none
diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb
b/spec/integration/ssl/certificate_revocation_list_spec.rb
index 127654c..44eee36 100755
--- a/spec/integration/ssl/certificate_revocation_list_spec.rb
+++ b/spec/integration/ssl/certificate_revocation_list_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::CertificateRevocationList do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet::SSL::Host.ca_location = :local
end
diff --git a/spec/integration/ssl/host_spec.rb
b/spec/integration/ssl/host_spec.rb
index 9b4152e..05862df 100755
--- a/spec/integration/ssl/host_spec.rb
+++ b/spec/integration/ssl/host_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::Host do
Puppet.settings[:confdir] = @dir
Puppet.settings[:vardir] = @dir
+ Puppet.settings[:group] = Process.gid
Puppet::SSL::Host.ca_location = :local
PATCH/puppet] [#4219] Install misses command_line dir, puppet $app --help fails
---
install.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/install.rb b/install.rb
index d35aaa0..b06ec09 100755
--- a/install.rb
+++ b/install.rb
@@ -84,7 +84,7 @@ bins = glob(%w{bin/*})
rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG
TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
ri = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~
/\.(bat|cmd)$/ }
man = glob(%w{man/man[0-9]/*})
-libs = glob(%w{lib/**/*.rb lib/**/*.py})
+libs = glob(%w{lib/**/*.rb lib/**/*.py lib/puppet/util/command_line/*})
tests = glob(%w{test/**/*.rb})
def do_bins(bins, target, strip = 's?bin/')
PATCH/puppet 1/1] added md5 support as requested in http://serverfault.com/questions/166199/puppet-
From: Alice Kærast <kaer### @newscloud.com> Signed-off-by: James Turnbull <ja### @lovedthanlost.net> --- lib/puppet/parser/functions/md5.rb | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) create mode 100644 lib/puppet/parser/functions/md5.rb diff --git a/lib/puppet/parser/functions/md5.rb b/lib/puppet/parser/functions/md5.rb new file mode 100644 index 0000000..f7a4f72 --- /dev/null +++ b/lib/puppet/parser/functions/md5.rb @@ -0,0 +1,5 @@ +Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :doc => "Returns a MD5 hash value from a provided string.") do |args| + require 'md5' + + Digest::MD5.hexdigest(args[0]) +end
PATCH/puppet 1/1] Fix #4458 - Do not dump the whole environment when instances can't be found
When generating the error message when we can't find any instances for a
search request, we were "inspect"ing the request which now contains
an environment instance which itself contains a lots of things (including
all the known resource types).
Thus it was generating a very large "reason" (ie the HTTP error string).
On some environments (ie proxied mongrel) this was too large and the
proxy would produce an error 500.
I just changed the error message to just log the indirection name and
request key (which should be enough to understand what is wrong).
Signed-off-by: Brice Figureau <brice-pup### @daysofwonder.com>
---
lib/puppet/network/http/handler.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/network/http/handler.rb
b/lib/puppet/network/http/handler.rb
index 03d24b3..61ae2d2 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -117,7 +117,7 @@ module Puppet::Network::HTTP::Handler
result = indirection_request.model.search(indirection_request.key,
indirection_request.to_hash)
if result.nil? or (result.is_a?(Array) and result.empty?)
- return do_exception(response, "Could not find instances in
#{indirection_request.indirection_name} with
'#{indirection_request.to_hash.inspect}'", 404)
+ return do_exception(response, "Could not find instances in
#{indirection_request.indirection_name} with '#{indirection_request.key}'",
404)
end
format = format_to_use(request)
PATCH/puppet 1/1] Fix #4348 - Puppet doc single manifest broken
The refactoring of using environment instances instead of strings
for initializing the parser, rdoc wasn't updated, thus was unable
to initialize the parser.
Signed-off-by: Brice Figureau <brice-pupp### @daysofwonder.com>
---
lib/puppet/util/rdoc.rb | 2 +-
spec/unit/util/rdoc_spec.rb | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index 4a80b06..085d8ec 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -41,7 +41,7 @@ module Puppet::Util::RDoc
def manifestdoc(files)
Puppet[:ignoreimport] = true
files.select { |f| FileTest.file?(f) }.each do |f|
- parser = Puppet::Parser::Parser.new(:environment =>
Puppet[:environment])
+ parser =
Puppet::Parser::Parser.new(Puppet::Node::Environment.new(Puppet[:environment]))
parser.file = f
ast = parser.parse
output(f, ast)
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 65df261..58c2034 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -75,6 +75,19 @@ describe Puppet::Util::RDoc do
Puppet::Util::RDoc.manifestdoc([])
end
+ it "should use a parser with the correct environment" do
+ FileTest.stubs(:file?).returns(true)
+ Puppet::Util::RDoc.stubs(:output)
+
+ parser = stub_everything
+ Puppet::Parser::Parser.stubs(:new).with{ |env|
env.is_a?(Puppet::Node::Environment) }.returns(parser)
+
+ parser.expects(:file=).with("file")
+ parser.expects(:parse)
+
+ Puppet::Util::RDoc.manifestdoc(["file"])
+ end
+
it "should puppet parse all given files" do
FileTest.stubs(:file?).returns(true)
Puppet::Util::RDoc.stubs(:output)
PATCH/puppet 0/4] Some random puppet fix for JRuby
Hi, Here is the first stab of JRuby Puppet compatibility. There looks to be more thread issue (the last ones I found are parser functions initializations), which will be addressed in subsequent patches. No patch in this serie have tests, because they most deal with threading issues that can be reproduced only under JRuby. Please review, Brice Brice Figureau (4): JRuby doesn't implement Process.maxgroups Fix #4244 - Cached Attributes is not thread safe Fix race condition in rack autoloading of request/response Fix #4245 - default insertion of ACL is not thread safe lib/puppet/network/http/rack.rb | 3 +++ lib/puppet/network/rest_authconfig.rb | 9 ++++++--- lib/puppet/util/cacher.rb | 31 +++++++++++++++++++++
Version control of Puppet Dashboard external node data
Hi. We're restructuring our puppet code and have put all our puppet code in subversion. This gives us a good setup for version control of our modules and manifests. The data defined in Puppet Dashboard, however, is not under any form of version control. How have others managed version control of external data such as data defined in a dashboard? Best regards, Kenneth Holter
PATCH/puppet 1/1] [#4149] Don't create two Resource::TypeCollections
By asking the environment for known resources instead of creating a type
collection ourselves, we avoid accidentally creating two
Resource::TypeCollection objects.
Signed-off-by: Jesse Wolfe <jes5### @gmail.com>
---
lib/puppet/application/apply.rb | 2 +-
lib/puppet/application/master.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/application/apply.rb
b/lib/puppet/application/apply.rb
index 8909939..1814858 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -67,7 +67,7 @@ class Puppet::Application::Apply <
Puppet::Application
Puppet[:manifest] = command_line.args.shift
end
begin
-
Puppet::Resource::TypeCollection.new(Puppet[:environment]).perform_initial_import
+
Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types
rescue => detail
Puppet.err detail
exit 1
diff --git a/lib/puppet/application/master.rb
b/lib/puppet/application/master.rb
index fdcd7d3..484ec08 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -67,7 +67,7 @@ class Puppet::Application::Master <
Puppet::Application
def parseonly
begin
-
Puppet::Resource::TypeCollection.new(Puppet[:environment]).perform_initial_import
+
Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types
rescue => detail
Puppet.err detail
exit 1
PATCH/puppet 1/1] [#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 <nic### @puppetlabs.com>
Signed-off-by: Matt Robinson <ma### @puppetlabs.com>
---
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 bb4186d..152b754 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 0b00d1a..8c53136 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
PATCH/puppet 1/1] [#4233] Ruby regexps are not multiline by default, but Resource titles can be mul
Puppet allows resource titles to contain newlines. We recently
introduced several regexps that were failing on resources with multiline
titles.
Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
lib/puppet/resource/catalog.rb | 2 +-
lib/puppet/type.rb | 2 +-
lib/puppet/type/file.rb | 2 +-
spec/unit/resource/catalog_spec.rb | 9 +++++++++
spec/unit/type/file_spec.rb | 14 ++++++++++++++
spec/unit/type_spec.rb | 21 +++++++++++++++++++++
6 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/lib/puppet/resource/catalog.rb
b/lib/puppet/resource/catalog.rb
index d163fc1..4ac99ee 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -57,7 +57,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
end
def title_key_for_ref( ref )
- ref =~ /^(.+)\[(.*)\]/
+ ref =~ /^(.+)\[(.*)\]/m
[$1, $2]
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index d0fea97..627271f 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -193,7 +193,7 @@ class Type
when 0; []
when 1;
identity = lambda {|x| x}
- [ [ /(.*)/, [ [key_attributes.first, identity ] ] ] ]
+ [ [ /(.*)/m, [ [key_attributes.first, identity ] ] ] ]
else
raise Puppet::DevError,"you must specify title patterns when there
are two or more key attributes"
end
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 195e8c8..71f2756 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -25,7 +25,7 @@ Puppet::Type.newtype(:file) do
native resource to support what you are doing."
def self.title_patterns
- [ [ /^(.*?)\/?$/, [ [ :path, lambda{|x| x} ] ] ] ]
+ [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ]
end
newparam(:path) do
diff --git a/spec/unit/resource/catalog_spec.rb
b/spec/unit/resource/catalog_spec.rb
index b6f96f0..10cff91 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -1066,4 +1066,13 @@ describe Puppet::Resource::Catalog, "when
converting from pson" do
lambda { PSON.parse @pson.to_pson }.should raise_error(ArgumentError)
end
+
+ describe "#title_key_for_ref" do
+ it "should parse a resource ref string into a pair" do
+ @catalog.title_key_for_ref("Title[name]").should == ["Title",
"name"]
+ end
+ it "should parse a resource ref string into a pair, even if there's a
newline inside the name" do
+ @catalog.title_key_for_ref("Title[na\nme]").should == ["Title",
"na\nme"]
+ end
+ end
end
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index 845bf3d..7d93dfd 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -1053,4 +1053,18 @@ describe Puppet::Type.type(:file) do
file.retrieve
end
end
+
+ describe ".title_patterns" do
+ before do
+ @type_class = Puppet::Type.type(:file)
+ end
+
+ it "should have a regexp that captures the entire string, except for
a terminating slash" do
+ patterns = @type_class.title_patterns
+ string = "abc/\n\tdef/"
+ patterns[0][0] =~ string
+ $1.should == "abc/\n\tdef"
+ end
+ end
+
end
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index 683529d..71d415d 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -406,6 +406,27 @@ describe Puppet::Type do
end
end
+ describe ".title_patterns" do
+ describe "when there's one namevar" do
+ before do
+ @type_class = Puppet::Type.type(:notify)
+ @type_class.stubs(:key_attributes).returns([:one])
+ end
+
+ it "should have a default pattern for when there's one namevar" do
+ patterns = @type_class.title_patterns
+ patterns.length.should == 1
+ patterns[0].length.should == 2
+ end
+
+ it "should have a regexp that captures the entire string" do
+ patterns = @type_class.title_patterns
+ string = "abc\n\tdef"
+ patterns[0][0] =~ string
+ $1.should == "abc\n\tdef"
+ end
+ end
+ end
describe "when in a catalog" do
before do
PATCH/puppet 1/1] [#4404] Remove requirement for source on Parser::Resource::Param
Stage[main] is created without an associated source, to which
Parser::Resource::Param objects. This patch observes that the source
attribute of both Parser::Resource and Parser::Resource::Param seem
not to be used anywhere, and removes the requirement that it be
supplied.
Signed-off-by: Nick Lewis <ni### @puppetlabs.com>
---
lib/puppet/parser/resource/param.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/parser/resource/param.rb
b/lib/puppet/parser/resource/param.rb
index af2d98f..c283223 100644
--- a/lib/puppet/parser/resource/param.rb
+++ b/lib/puppet/parser/resource/param.rb
@@ -13,7 +13,7 @@ class Puppet::Parser::Resource::Param
def initialize(hash)
set_options(hash)
- requiredopts(:name, :value, :source)
+ requiredopts(:name, :value)
@name = symbolize(@name)
end
PATCH/puppet 1/1] [#4347] run_mode was colliding with --mode for "puppet doc"
The run_mode value was incorrectly getting stored to Puppet[:mode], which
was confusing the optparser for applications that declare a --mode
parameter.
Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
lib/puppet/application.rb | 2 +-
lib/puppet/defaults.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 0a8fbc1..2fec38b 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -285,7 +285,7 @@ class Application
Puppet.settings.set_value(:name, Puppet.application_name.to_s,
:mutable_defaults)
Puppet.settings.set_value(:logdir, Puppet.run_mode.logopts,
:mutable_defaults)
Puppet.settings.set_value(:rundir, Puppet.run_mode.run_dir,
:mutable_defaults)
- Puppet.settings.set_value(:mode, Puppet.run_mode.name.to_s,
:mutable_defaults)
+ Puppet.settings.set_value(:run_mode, Puppet.run_mode.name.to_s,
:mutable_defaults)
end
require 'puppet'
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 84e2d93..0de5f20 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -7,7 +7,7 @@ module Puppet
:vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic
and growing data. The default for this parameter is calculated specially,
like `confdir`_."],
:name => [Puppet.application_name.to_s, "The name of the
application, if we are running as one. The
default is essentially $0 without the path or ``.rb``."],
- :mode => [Puppet.run_mode.name.to_s, "The effective 'run mode' of
the application: master, agent, or user."]
+ :run_mode => [Puppet.run_mode.name.to_s, "The effective 'run mode'
of the application: master, agent, or user."]
)
setdefaults(:main, :logdir => Puppet.run_mode.logopts)
Puppet Standalone Client + Fileserving, not working.... (+ nice tutorial for puppet stand-alone) :)
Puppet local fileserving not working, as described here: http://docs.reductivelabs.com/guides/modules.html I've made a project to demonstrate this: https://mindre### @github.com/mindr...alone_testing.git There is more in the README...(http://github.com/mindreframer/ puppet_stand_alone_testing/blob/master/Readme.md) Would be nice to get this working, it seems wasteful the rewrite the modules only for stand-alone usage... Thx!
Could not retrieve information from source(s) puppet://puppet/plugins error message
Hi. After I upgraded to latest puppet, I started receiving this message both in clients and in master. Following the advice below, i create an empty stub module, with empty "lib" directory: http://projects.puppetlabs.com/issues/2244 Any idea if this is a clean solution, or there is another, better fix? Regards.
Re: [Puppet-commit] [SCM] Puppet - System Automation branch, 2.6.x, updated. 2.6.1rc2
Holy cow that's a lot of work. Well done. On Aug 11, 2010, at 10:41 PM, git version control wrote: This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Puppet - System Automation". The branch, 2.6.x has been updated via 0aa27b5cc5df818e3878601e83f83a20590e161a (commit) via 252c9b84f79307e5caa50b50e093ad493993622d (commit) via 1157e8dbaf310cca6f56dda3fa9f100b458662ee (commit) via fef8800acaddd54659602b65bd9fdc728d187c67 (commit) via 79e0a2e5c9e2f654c0f7ed37e1bf3342a54e4525 (commit) via 62435e551b3118b1663c67d66a9cae9f52607bc7 (commit) via e4b2aa6e48af43e83e6954d9253ef9b38d8c36ae (commit) via 8ddea2afba170a3d3e1e2917a049dfa01ad3d8a7 (commit) via f43e87bb638b30608e1773a9afb48a8639feb3cd (commit) via a23d80aebabf981a34fcca5c8bd2aa5f44ea832d (commit) via 8e31b528e139a2940d6932ab80375bb5eebfbe29 (commit) via 037bb329f090ce86227fc62b51d081831fa9de03 (commit) via 0e4bc62716a37cc82a8a5dbb5865ac7f45cf71b2 (commit) via 3a6ca54a6e8ad353f207bc85433d1204b5ca48bc (commit) via d909827942fa571bea202818c92d081e7957a574 (commit) via 47005aa20199455e8cea7679b0c40efbebe473e4 (commit) via 6aac8f0185db1d153583230de726c30ce949fc78 (commit) via 1cba9a7a713261fd62ceec440a3e57667eb103ba (commit) via 1dfd2b6ba30f7a4c06688e18d0d6cd73a2e45d91 (commit) via be2b1f360fc15596098280265e6aa76e8043eb92 (commit) via 03808fdc05c4660c1559cf8a09be80664096e0ad (commit) via 539b57c1f119be60c774db183dcaec37b1fd5cd5 (commit) via 1faebdd7b54a55b023f151976644dbc3405c486b (commit) via 37568bdd3f8cc3514eb9d0bf0eae3302686bc13d (commit) via 449315a2c705df2396852462a1d1e14774b9f117 (commit) via daa801b9ff8c81e6812a08a3f6ef82f593248e9d (commit) via 00ebf01227745edc84084d10a9d8be7439551b0f (commit) via e32320ee2c65275e3c695c555f506a499209efa1 (commit) via 0f9672a545ac057282b9add87ee602e3200d11de (commit) via f54d843e4e585274f724c97f1b10288d8798a63b (commit) via 2c21faec04f0029bfef381dfa4341a916ee28967 (commit) via 83c2419771de45317e4bf79e7f71469d9a19a09a (commit) via 8237f686c53e8d1e45097c65c7d50b84ca83bb39 (commit) from d5ad0fbd44aa45f38b399b0f3da6b59833fc74db (commit) | |||
(18 lines) Aug 12, 2010 17:06
(29 lines) Aug 12, 2010 18:08