summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-08-27 12:49:54 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-08-27 12:50:26 -0700
commit21afb51a1b84116b2a906a6959ae588f45135104 (patch)
tree48fa0438d0a50202194956344d0cf1f10b17b818 /lib/puppet
parent1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac (diff)
parent8be1929043f4560bb17a4b06293b3f9a4efcfdbf (diff)
downloadpuppet-21afb51a1b84116b2a906a6959ae588f45135104.tar.gz
puppet-21afb51a1b84116b2a906a6959ae588f45135104.tar.xz
puppet-21afb51a1b84116b2a906a6959ae588f45135104.zip
Merge commit '2.6.1rc3'
This synchronizes the 2.7 master branch with 2.6.1RC3 The 2.7 next branch has now diverged from master for the first time, as if contains code that has not reached "release quality" status.
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application/apply.rb20
-rw-r--r--lib/puppet/application/queue.rb1
-rwxr-xr-xlib/puppet/daemon.rb2
-rw-r--r--lib/puppet/file_serving/indirection_hooks.rb4
-rw-r--r--lib/puppet/indirector/yaml.rb15
-rw-r--r--lib/puppet/network/format_handler.rb6
-rw-r--r--lib/puppet/network/formats.rb8
-rw-r--r--lib/puppet/parser/compiler.rb19
-rw-r--r--lib/puppet/resource/type.rb1
-rwxr-xr-xlib/puppet/type/cron.rb2
10 files changed, 42 insertions, 36 deletions
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb
index bb4186dbd..59a95d35a 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.
@@ -123,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
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
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
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/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index c7c053f4b..23997e97a 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -41,19 +41,16 @@ 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)
- File.join(base, self.class.indirection_name.to_s, name.to_s + ".yaml")
+ 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 + ext)
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) }
+ Dir.glob(path(request.key,'')).collect do |file|
+ YAML.load_file(file)
+ end
end
private
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])
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/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/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