From 3b53bfcd0dd20a43c751b2b0d5dbb0e3463ef47b Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Mon, 18 Oct 2010 14:25:17 -0700 Subject: Fix for #5022 -- Escaped newlines should be elided This was a regression, not covered by a test; previously the string "foo\ bar" would be interpreded as "foobar" but this was changed to "foo\\\nbar" in 2.6.x with my string interpolation refactor. This change restores the behaviour. --- lib/puppet/parser/lexer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 9036d652e..31d39ae2f 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -522,13 +522,14 @@ class Puppet::Parser::Lexer # backslash; the caret is there to match empty strings str = @scanner.scan_until(/([^\\]|^|[^\\])([\\]{2})*[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'" @line += str.count("\n") # literal carriage returns add to the line count. - str.gsub!(/\\(.)/) { + str.gsub!(/\\(.)/m) { ch = $1 if escapes.include? ch case ch when 'n'; "\n" when 't'; "\t" when 's'; " " + when "\n": '' else ch end else -- cgit From 7d35a479b760e382638a2efe1881b8bd94704a45 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 27 Oct 2010 09:23:00 +1100 Subject: Fixed to #5108 - Change default of service hasstatus property to true --- lib/puppet/type/service.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c00f02789..786a50448 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -100,6 +100,8 @@ module Puppet looked for in the process table." newvalues(:true, :false) + + defaultto :true end newparam(:name) do desc "The name of the service to run. This name is used to find -- cgit From 65ef24e5c1c33b7d42012891d368917fd6aaf68c Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 8 Oct 2010 15:26:28 -0700 Subject: (#4534/#4778) -- Normalize parameterized classes This is a reconciliation/melding of Paul's (#4534) Class inheritance with parameterized classes is no longer ignored and Markus's Fix for #4778 -- evaluate parameterized classes when they are instantiated Extracted the code from Resource::Type#mk_plain_resource that evaluates parents and tags the catalog, and moved that into a new method called instantiate_resource. Instantiate_resource is now also called from Parser::Ast::Resource#evaluate, so that the notation "class { classname: }" now executes this code too. Likewise adds class evaluation so that it behaves the same (with regard to lazy / strict evaluation) as include classname --- lib/puppet/parser/ast/resource.rb | 7 ++++--- lib/puppet/parser/compiler.rb | 4 ++-- lib/puppet/resource/type.rb | 31 ++++++++++++++++++------------- 3 files changed, 24 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index 6909c85c2..b019e6aac 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -49,10 +49,11 @@ class Resource < AST::ResourceReference :strict => true ) - # And then store the resource in the compiler. - # At some point, we need to switch all of this to return - # resources instead of storing them like this. + if resource.resource_type.is_a? Puppet::Resource::Type + resource.resource_type.instantiate_resource(scope, resource) + end scope.compiler.add_resource(scope, resource) + scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class' resource end }.reject { |resource| resource.nil? } diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index e1227e753..c60e1d4fb 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -144,7 +144,7 @@ class Puppet::Parser::Compiler if klass = scope.find_hostclass(name) found << name and next if scope.class_scope(klass) - resource = klass.mk_plain_resource(scope) + resource = klass.ensure_in_catalog(scope) # If they've disabled lazy evaluation (which the :include function does), # then evaluate our resource immediately. @@ -220,7 +220,7 @@ class Puppet::Parser::Compiler # Create a resource to model this node, and then add it to the list # of resources. - resource = astnode.mk_plain_resource(topscope) + resource = astnode.ensure_in_catalog(topscope) resource.evaluate diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 7b21e55dc..d40adc145 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -138,21 +138,15 @@ class Puppet::Resource::Type end end - # Make an instance of our resource type. This is only possible - # for those classes and nodes that don't have any arguments, and is - # only useful for things like the 'include' function. - def mk_plain_resource(scope) + # Make an instance of the resource type, and place it in the catalog + # if it isn't in the catalog already. This is only possible for + # classes and nodes. No parameters are be supplied--if this is a + # parameterized class, then all parameters take on their default + # values. + def ensure_in_catalog(scope) type == :definition and raise ArgumentError, "Cannot create resources for defined resource types" resource_type = type == :hostclass ? :class : :node - # Make sure our parent class has been evaluated, if we have one. - if parent - parent_resource = scope.catalog.resource(resource_type, parent) - unless parent_resource - parent_type(scope).mk_plain_resource(scope) - end - end - # Do nothing if the resource already exists; this makes sure we don't # get multiple copies of the class resource, which helps provide the # singleton nature of classes. @@ -161,11 +155,22 @@ class Puppet::Resource::Type end resource = Puppet::Parser::Resource.new(resource_type, name, :scope => scope, :source => self) + instantiate_resource(scope, resource) scope.compiler.add_resource(scope, resource) - scope.catalog.tag(*resource.tags) resource end + def instantiate_resource(scope, resource) + # Make sure our parent class has been evaluated, if we have one. + if parent && !scope.catalog.resource(resource.type, parent) + parent_type(scope).ensure_in_catalog(scope) + end + + if ['Class', 'Node'].include? resource.type + scope.catalog.tag(*resource.tags) + end + end + def name return @name unless @name.is_a?(Regexp) @name.source.downcase.gsub(/[^-\w:.]/,'').sub(/^\.+/,'') -- cgit From 31118fe85aca4ee46903b17a3eb7aee07b8c0d69 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sat, 23 Oct 2010 08:26:24 -0700 Subject: Kludge for #5048 -- serialization compatibility with 0.25.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 0.25.x the type & title of a resource were wrapped in a Puppet::Resource::Reference object whereas in 2.6.x they are attributes of the resource itself without the additional indirection (see 7089446697ad550c22012bc2b5572030727d67e1). When pson serialization is used this isn’t a problem but with formats in which we just blindly emit the structure either because we have no choice (marshal) or because we just use the default (yaml) it is a compatibility-breaking change. This patch resoloves the problem by adding a dummy reference object to cause the "correct" serialization; it is intended as a stop-gap for 2.6.x and should NOT be merged into next. --- lib/puppet/resource.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 39803b077..7dea270e8 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -154,6 +154,14 @@ class Puppet::Resource end end + # This stub class is only needed for serialization compatibility with 0.25.x + class Reference + attr_accessor :type,:title + def initialize(type,title) + @type,@title = type,title + end + end + # Create our resource. def initialize(type, title = nil, attributes = {}) @parameters = {} @@ -180,6 +188,8 @@ class Puppet::Resource tag(self.type) tag(self.title) if valid_tag?(self.title) + @reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x + raise ArgumentError, "Invalid resource type #{type}" if strict? and ! resource_type end -- cgit From 776ea2a17de7834ecdaded9fcaabc48446d2f29d Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 28 Oct 2010 20:10:59 +1100 Subject: Fixed #5137 - Removed no longer required TOC references --- lib/puppet/util/reference.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 99458aa57..ab201cde4 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -32,7 +32,6 @@ class Puppet::Util::Reference section = reference(name) or raise "Could not find section #{name}" depth = section.depth if section.depth < depth end - text = "* TOC text.\n{:toc}\n\n" end def self.pdf(text) @@ -141,7 +140,6 @@ class Puppet::Util::Reference # First the header text = h(@title, 1) text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n" - text += "* TOC Text.\n{:toc}\n\n" if withcontents text += @header -- cgit From 76ac1f88ce2a13cabbda38eb56ed21a43e6923a7 Mon Sep 17 00:00:00 2001 From: donavan Date: Wed, 27 Oct 2010 17:57:03 -0700 Subject: Fixed #5112 - Launchd Service broke in 2.6.2 with OS X 10.4 Clients. Just to follow up on 5112 I have a dirty patch that appears to work. Nominally tested it on 10.4, 10.5, & 10.6. 10.4 now applies catalogs instead of failing. All versions successfully manage a test services state as well. Does anyone have a better suggestion than '-o /dev/stdout'? Seems a mite hacky to me. Also I think that the 10.4 machines are going to a have a \ ( slash ) file in whatever puppets working dir was. plutil seems to have been interpreting as literal file name. --- lib/puppet/provider/service/launchd.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index b296e0a38..1632edabf 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -56,7 +56,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do # Read a plist, whether its format is XML or in Apple's "binary1" # format. def self.read_plist(path) - Plist::parse_xml(plutil('-convert', 'xml1', '-o', '-', path)) + Plist::parse_xml(plutil('-convert', 'xml1', '-o', '/dev/stdout', path)) end # returns a label => path map for either all jobs, or just a single -- cgit From 91ac1629dbefa70382636d6e08768038aeb7f298 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Wed, 3 Nov 2010 16:36:43 -0700 Subject: (#5198) add gigabyte reference to docs for tidy type's size parameter --- lib/puppet/type/tidy.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 65cc077cf..897ee90da 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -141,9 +141,10 @@ Puppet::Type.newtype(:tidy) do newparam(:size) do desc "Tidy files whose size is equal to or greater than the specified size. Unqualified values are in kilobytes, but - *b*, *k*, and *m* can be appended to specify *bytes*, *kilobytes*, - and *megabytes*, respectively. Only the first character is - significant, so the full word can also be used." + *b*, *k*, *m*, and *g* can be appended to specify *bytes*, + *kilobytes*, *megabytes*, and *gigabytes*, respectively. + Only the first character is significant, so the full word can also + be used." @@sizeconvertors = { :b => 0, -- cgit From 71a0ceadffc816c08dd979e139fbbf2fa94023a0 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Wed, 3 Nov 2010 16:38:06 -0700 Subject: (#5198) add terabyte support to tidy type's size parameter --- lib/puppet/type/tidy.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 897ee90da..93a7e96cf 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -141,8 +141,8 @@ Puppet::Type.newtype(:tidy) do newparam(:size) do desc "Tidy files whose size is equal to or greater than the specified size. Unqualified values are in kilobytes, but - *b*, *k*, *m*, and *g* can be appended to specify *bytes*, - *kilobytes*, *megabytes*, and *gigabytes*, respectively. + *b*, *k*, *m*, *g*, and *t* can be appended to specify *bytes*, + *kilobytes*, *megabytes*, *gigabytes*, and *terabytes*, respectively. Only the first character is significant, so the full word can also be used." @@ -150,7 +150,8 @@ Puppet::Type.newtype(:tidy) do :b => 0, :k => 1, :m => 2, - :g => 3 + :g => 3, + :t => 4 } def convert(unit, multi) -- cgit From 4506dfeab3eead32f44f4baa461ebba88fe098ab Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Fri, 5 Nov 2010 11:37:27 -0700 Subject: (#5150) Make fact REST terminus configurable to connect to inventory service Puppet masters can now set the inventory_server and inventory_port option to point to another puppet master that will function as the central inventory service. When agents connect to the puppet master, this will send fact data from the puppet master over REST to the inventory service. The puppet master itself will still store the client fact data in the local yaml dir by setting the cache class to yaml. Getting puppet masters to talk to each other using certs is difficult. Paired-with: Jesse Wolfe --- lib/puppet/defaults.rb | 19 +++++++++++++++++-- lib/puppet/indirector/facts/rest.rb | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index c7bebf8f5..7ae553827 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -115,7 +115,16 @@ 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 => [Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', "The node facts terminus."], + :facts_terminus => { + :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', + :desc => "The node facts terminus.", + :hook => proc do |value| + require 'puppet/node/facts' + if value.to_s == "rest" + Puppet::Node::Facts.cache_class = :yaml + end + end + }, :inventory_terminus => [ "$facts_terminus", "Should usually be the same as the facts terminus" ], :httplog => { :default => "$logdir/http.log", :owner => "root", @@ -579,11 +588,17 @@ module Puppet end }, :report_server => ["$server", - "The server to which to send transaction reports." + "The server to send transaction reports to." ], :report_port => ["$masterport", "The port to communicate with the report_server." ], + :inventory_server => ["$server", + "The server to send facts to." + ], + :inventory_port => ["$masterport", + "The port to communicate with the inventory_server." + ], :report => [false, "Whether to send reports after every transaction." ], diff --git a/lib/puppet/indirector/facts/rest.rb b/lib/puppet/indirector/facts/rest.rb index 07491fc77..e2afa14b2 100644 --- a/lib/puppet/indirector/facts/rest.rb +++ b/lib/puppet/indirector/facts/rest.rb @@ -3,4 +3,6 @@ require 'puppet/indirector/rest' class Puppet::Node::Facts::Rest < Puppet::Indirector::REST desc "Find and save facts about nodes over HTTP via REST." + use_server_setting(:inventory_server) + use_port_setting(:inventory_port) end -- cgit From 5c2457952660e3e531e085757fd85c382676a96e Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Thu, 4 Nov 2010 17:32:11 -0700 Subject: maint: prevent fork bombs by disabling ActiveSupport's Kernel.daemonize ActiveSupport provides a "daemonize" method on all objects that causes the ruby process to fork to the background. This is extremely surprising and dangerous, and some of our spec tests could trigger this accidentally. This patch adds a "daemonize" method to Object which shadows the ActiveSupport version, preventing it from ever being called. --- lib/puppet/util/monkey_patches.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index 6b5af8350..bdce5ec1d 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -48,3 +48,11 @@ if RUBY_VERSION == '1.8.7' end end +class Object + # ActiveSupport 2.3.x mixes in a dangerous method + # that can cause rspec to fork bomb + # and other strange things like that. + def daemonize + raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it." + end +end -- cgit From 2ec1b552e24d3b42391a6471e477422f67ea00bd Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 9 Nov 2010 12:05:49 -0800 Subject: Maint: Added missing requires to fileserver.rb. --- lib/puppet/network/handler/fileserver.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index 27b913ab9..8844ab990 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -4,9 +4,11 @@ require 'webrick/httpstatus' require 'cgi' require 'delegate' require 'sync' +require 'xmlrpc/server' require 'puppet/file_serving' require 'puppet/file_serving/metadata' +require 'puppet/network/handler' class Puppet::Network::Handler AuthStoreError = Puppet::AuthStoreError -- cgit