summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-06 20:42:39 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-03-07 14:02:17 -0800
commit28095d7435bcab15b76ddfa4435d61653f2f890d (patch)
tree74ae5f037aaee78ed31de178c6e6f4203e9d7959 /lib/puppet/application
parent6869385300dc694c4f087e134949dff9e1e43df9 (diff)
parente8145f91debc863b341a270e1d8cff6c43d93ef5 (diff)
downloadpuppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.gz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.tar.xz
puppet-28095d7435bcab15b76ddfa4435d61653f2f890d.zip
Merge branch '2.6.next' into next
This was a particularly nasty merge, so rather than hold up merges into next any longer, I'm going to push this merge with a few outstanding problems. The tests that were failing in the following areas have been marked pending, and will be addressed separately, immediately following this push. TODO: Verify that brice's rdoc change is still valid: tests to show that line numbers from class, define and node get into the ast Fix mount parsed_spec spec/unit/provider/mount/parsed_spec.rb * 2.6.next: (85 commits) (#5148) Fix failing spec due to timezone (#5148) Add support for PSON to facts (#6338) Remove inventory indirection, and move to facts indirection (#6445) Fix inline docs: puppet agent does not accept --mkusers Update CHANGELOG and version for 2.6.6rc1 (#6541) Fix content with checksum truncation bug (#6418) Recursive files shouldn't be audited (#6541) maint: whitespace cleanup on the file integration spec (#6541) Fix content with checksum truncation bug (#5466) Write specs for output of puppet resource (#5466) Monkey patch Symbol so that you can sort them (#5466) Fixed puppet resource bug with trailing , Update CHANGELOG for 2.6.5 (#4922) Don't truncate remotely-sourced files on 404 (#6338) Remove unused version control tags Maint: Align tabs in a code block in the Augeas type. (#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type Maint: Rewrite comments about symlinks to reflect best practice. (#6509) Inline docs: Fix broken lists in Launchd provider. (#6509) Inline docs: Fix broken code blocks in zpool type ... Manually Resolved Conflicts: lib/puppet/application/inspect.rb lib/puppet/defaults.rb lib/puppet/file_bucket/dipper.rb lib/puppet/network/http/handler.rb lib/puppet/node/facts.rb lib/puppet/parser/parser.rb lib/puppet/parser/parser_support.rb lib/puppet/util/command_line/puppet lib/puppet/util/command_line/puppetd lib/puppet/util/command_line/puppetmasterd lib/puppet/util/monkey_patches.rb lib/puppet/util/rdoc/parser.rb spec/unit/application/agent_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector/file_bucket_file/file_spec.rb spec/unit/network/http/handler_spec.rb spec/unit/parser/parser_spec.rb spec/unit/provider/mount/parsed_spec.rb
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/agent.rb4
-rw-r--r--lib/puppet/application/apply.rb4
-rw-r--r--lib/puppet/application/cert.rb41
-rw-r--r--lib/puppet/application/filebucket.rb2
-rw-r--r--lib/puppet/application/inspect.rb118
-rw-r--r--lib/puppet/application/kick.rb4
-rw-r--r--lib/puppet/application/master.rb2
-rw-r--r--lib/puppet/application/queue.rb4
8 files changed, 99 insertions, 80 deletions
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index fa06aae36..2ee40227e 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -9,7 +9,7 @@ class Puppet::Application::Agent < Puppet::Application
def preinit
# Do an initial trap, so that cancels don't get a stack trace.
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Cancelling startup"
exit(0)
end
@@ -330,7 +330,7 @@ License
if not report
exit(1)
- elsif not Puppet[:noop] and options[:detailed_exitcodes] then
+ elsif options[:detailed_exitcodes] then
exit(report.exit_status)
else
exit(0)
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb
index a1edf6243..2b7c9f8fb 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -222,7 +222,7 @@ License
configurer = Puppet::Configurer.new
report = configurer.run(:skip_plugin_download => true, :catalog => catalog)
- exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? report.exit_status : 0 )
+ exit( options[:detailed_exitcodes] ? report.exit_status : 0 )
rescue => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts detail.message
@@ -240,7 +240,7 @@ License
client = nil
server = nil
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Exiting"
exit(1)
end
diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb
index 0808a42da..f02fc893c 100644
--- a/lib/puppet/application/cert.rb
+++ b/lib/puppet/application/cert.rb
@@ -5,17 +5,19 @@ class Puppet::Application::Cert < Puppet::Application
should_parse_config
run_mode :master
- attr_accessor :cert_mode, :all, :ca, :digest, :signed
+ attr_accessor :all, :ca, :digest, :signed
- def find_mode(opt)
- require 'puppet/ssl/certificate_authority'
- modes = Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS
- tmp = opt.sub("--", '').to_sym
- @cert_mode = modes.include?(tmp) ? tmp : nil
+ def subcommand
+ @subcommand
+ end
+ def subcommand=(name)
+ # Handle the nasty, legacy mapping of "clean" to "destroy".
+ sub = name.to_sym
+ @subcommand = (sub == :clean ? :destroy : sub)
end
option("--clean", "-c") do
- @cert_mode = :destroy
+ self.subcommand = "destroy"
end
option("--all", "-a") do
@@ -37,7 +39,7 @@ class Puppet::Application::Cert < Puppet::Application
require 'puppet/ssl/certificate_authority/interface'
Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject {|m| m == :destroy }.each do |method|
option("--#{method}", "-#{method.to_s[0,1]}") do
- find_mode("--#{method}")
+ self.subcommand = method
end
end
@@ -46,7 +48,7 @@ class Puppet::Application::Cert < Puppet::Application
end
def help
- <<-HELP
+ puts <<-HELP
puppet-cert(8) -- Manage certificates and requests
========
@@ -165,6 +167,7 @@ Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public
License
HELP
+ exit
end
def main
@@ -176,8 +179,8 @@ License
hosts = command_line.args.collect { |h| h.downcase }
end
begin
- @ca.apply(:revoke, :to => hosts) if @cert_mode == :destroy
- @ca.apply(@cert_mode, :to => hosts, :digest => @digest)
+ @ca.apply(:revoke, :to => hosts) if subcommand == :destroy
+ @ca.apply(subcommand, :to => hosts, :digest => @digest)
rescue => detail
puts detail.backtrace if Puppet[:trace]
puts detail.to_s
@@ -186,11 +189,12 @@ License
end
def setup
+ require 'puppet/ssl/certificate_authority'
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
Puppet::Util::Log.newdestination :console
- if [:generate, :destroy].include? @cert_mode
+ if [:generate, :destroy].include? subcommand
Puppet::SSL::Host.ca_location = :local
else
Puppet::SSL::Host.ca_location = :only
@@ -204,4 +208,17 @@ License
exit(23)
end
end
+
+ def parse_options
+ # handle the bareword subcommand pattern.
+ result = super
+ unless self.subcommand then
+ if sub = self.command_line.args.shift then
+ self.subcommand = sub
+ else
+ help
+ end
+ end
+ result
+ end
end
diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb
index 460115586..063d97db8 100644
--- a/lib/puppet/application/filebucket.rb
+++ b/lib/puppet/application/filebucket.rb
@@ -155,7 +155,7 @@ License
@client = nil
@server = nil
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Cancelling"
exit(1)
end
diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb
index 578588144..e448cb9e8 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -85,7 +85,7 @@ Licensed under the GNU General Public License version 2
Puppet::Util::Log.newdestination(@report)
Puppet::Util::Log.newdestination(:console) unless options[:logset]
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Exiting"
exit(1)
end
@@ -101,79 +101,81 @@ Licensed under the GNU General Public License version 2
end
def run_command
- retrieval_starttime = Time.now
+ benchmark(:notice, "Finished inspection") do
+ retrieval_starttime = Time.now
- unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname])
- raise "Could not find catalog for #{Puppet[:certname]}"
- end
+ unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname])
+ raise "Could not find catalog for #{Puppet[:certname]}"
+ end
- @report.configuration_version = catalog.version
+ @report.configuration_version = catalog.version
- inspect_starttime = Time.now
- @report.add_times("config_retrieval", inspect_starttime - retrieval_starttime)
+ inspect_starttime = Time.now
+ @report.add_times("config_retrieval", inspect_starttime - retrieval_starttime)
- if Puppet[:archive_files]
- dipper = Puppet::FileBucket::Dipper.new(:Server => Puppet[:archive_file_server])
- end
+ if Puppet[:archive_files]
+ dipper = Puppet::FileBucket::Dipper.new(:Server => Puppet[:archive_file_server])
+ end
- catalog.to_ral.resources.each do |ral_resource|
- audited_attributes = ral_resource[:audit]
- next unless audited_attributes
+ catalog.to_ral.resources.each do |ral_resource|
+ audited_attributes = ral_resource[:audit]
+ next unless audited_attributes
- status = Puppet::Resource::Status.new(ral_resource)
+ status = Puppet::Resource::Status.new(ral_resource)
- begin
- audited_resource = ral_resource.to_resource
- rescue StandardError => detail
- puts detail.backtrace if Puppet[:trace]
- ral_resource.err "Could not inspect #{ral_resource}; skipping: #{detail}"
- audited_attributes.each do |name|
- event = ral_resource.event(
- :property => name,
- :status => "failure",
- :audited => true,
- :message => "failed to inspect #{name}"
- )
- status.add_event(event)
- end
- else
- audited_attributes.each do |name|
- next if audited_resource[name].nil?
- # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW
- if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent
+ begin
+ audited_resource = ral_resource.to_resource
+ rescue StandardError => detail
+ puts detail.backtrace if Puppet[:trace]
+ ral_resource.err "Could not inspect #{ral_resource}; skipping: #{detail}"
+ audited_attributes.each do |name|
event = ral_resource.event(
- :previous_value => audited_resource[name],
- :property => name,
- :status => "audit",
- :audited => true,
- :message => "inspected value is #{audited_resource[name].inspect}"
- )
+ :property => name,
+ :status => "failure",
+ :audited => true,
+ :message => "failed to inspect #{name}"
+ )
status.add_event(event)
end
+ else
+ audited_attributes.each do |name|
+ next if audited_resource[name].nil?
+ # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW
+ if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent
+ event = ral_resource.event(
+ :previous_value => audited_resource[name],
+ :property => name,
+ :status => "audit",
+ :audited => true,
+ :message => "inspected value is #{audited_resource[name].inspect}"
+ )
+ status.add_event(event)
+ end
+ end
end
- end
- if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content)
- path = ral_resource[:path]
- if File.readable?(path)
- begin
- dipper.backup(path)
- rescue StandardError => detail
- Puppet.warning detail
+ if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content)
+ path = ral_resource[:path]
+ if File.readable?(path)
+ begin
+ dipper.backup(path)
+ rescue StandardError => detail
+ Puppet.warning detail
+ end
end
end
+ @report.add_resource_status(status)
end
- @report.add_resource_status(status)
- end
- finishtime = Time.now
- @report.add_times("inspect", finishtime - inspect_starttime)
- @report.finalize_report
+ finishtime = Time.now
+ @report.add_times("inspect", finishtime - inspect_starttime)
+ @report.finalize_report
- begin
- Puppet::Transaction::Report.indirection.save(@report)
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- Puppet.err "Could not send report: #{detail}"
+ begin
+ Puppet::Transaction::Report.indirection.save(@report)
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not send report: #{detail}"
+ end
end
end
end
diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb
index 9612a72aa..604132818 100644
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@ -292,7 +292,7 @@ License
def preinit
[:INT, :TERM].each do |signal|
- trap(signal) do
+ Signal.trap(signal) do
$stderr.puts "Cancelling"
exit(1)
end
@@ -336,7 +336,7 @@ License
# If we get a signal, then kill all of our children and get out.
[:INT, :TERM].each do |signal|
- trap(signal) do
+ Signal.trap(signal) do
Puppet.notice "Caught #{signal}; shutting down"
@children.each do |pid, host|
Process.kill("INT", pid)
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index f689b9e01..3bfad89f4 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -112,7 +112,7 @@ License
end
def preinit
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Cancelling startup"
exit(0)
end
diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb
index 00ace37fa..de8aea32a 100644
--- a/lib/puppet/application/queue.rb
+++ b/lib/puppet/application/queue.rb
@@ -15,13 +15,13 @@ class Puppet::Application::Queue < Puppet::Application
# Do an initial trap, so that cancels don't get a stack trace.
# This exits with exit code 1
- trap(:INT) do
+ Signal.trap(:INT) do
$stderr.puts "Caught SIGINT; shutting down"
exit(1)
end
# This is a normal shutdown, so code 0
- trap(:TERM) do
+ Signal.trap(:TERM) do
$stderr.puts "Caught SIGTERM; shutting down"
exit(0)
end