diff options
| author | Dominic Cleal <dcleal@redhat.com> | 2010-11-27 13:36:04 +0000 |
|---|---|---|
| committer | Dominic Cleal <dcleal@redhat.com> | 2010-11-27 13:36:04 +0000 |
| commit | afe2d014feb2210a8666c93465d11e9c9d555f8b (patch) | |
| tree | 208f5ac82b2c29610d2021821c8fca9b079e638b /lib/puppet/application | |
| parent | 143fc744a839affd328234fca26246d49d15d3d8 (diff) | |
| parent | 4b35402ba85d8842d757becec5c8a7bf4d6f6654 (diff) | |
| download | puppet-afe2d014feb2210a8666c93465d11e9c9d555f8b.tar.gz puppet-afe2d014feb2210a8666c93465d11e9c9d555f8b.tar.xz puppet-afe2d014feb2210a8666c93465d11e9c9d555f8b.zip | |
Merge branch 'master' of github.com:domcleal/puppet into master-old
Diffstat (limited to 'lib/puppet/application')
| -rw-r--r-- | lib/puppet/application/agent.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/application/apply.rb | 23 | ||||
| -rw-r--r-- | lib/puppet/application/describe.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/application/doc.rb | 38 | ||||
| -rw-r--r-- | lib/puppet/application/master.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/application/queue.rb | 1 |
6 files changed, 19 insertions, 54 deletions
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index f0e7f4d8f..c5ad72068 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -219,12 +219,18 @@ class Puppet::Application::Agent < Puppet::Application Puppet.settings.use :main, :agent, :ssl + # Always ignoreimport for agent. It really shouldn't even try to import, + # but this is just a temporary band-aid. + Puppet[:ignoreimport] = true + # We need to specify a ca location for all of the SSL-related i # indirected classes to work; in fingerprint mode we just need # access to the local files and we don't need a ca. Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote Puppet::Transaction::Report.terminus_class = :rest + # we want the last report to be persisted locally + Puppet::Transaction::Report.cache_class = :yaml # Override the default; puppetd needs this, usually. # You can still override this on the command-line with, e.g., :compiler. diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index bb4186dbd..8ec3fab6b 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. @@ -120,20 +123,9 @@ class Puppet::Application::Apply < Puppet::Application require 'puppet/configurer' configurer = Puppet::Configurer.new - configurer.execute_prerun_command - - # And apply it - transaction = catalog.apply - - configurer.execute_postrun_command + report = configurer.run(:skip_plugin_download => true, :catalog => catalog) - status = 0 - if not Puppet[:noop] and options[:detailed_exitcodes] - transaction.generate_report - exit(transaction.report.exit_status) - else - exit(0) - end + exit( Puppet[:noop] ? 0 : options[:detailed_exitcodes] ? report.exit_status : 0 ) rescue => detail puts detail.backtrace if Puppet[:trace] $stderr.puts detail.message @@ -156,6 +148,9 @@ class Puppet::Application::Apply < Puppet::Application exit(1) end + # we want the last report to be persisted locally + Puppet::Transaction::Report.cache_class = :yaml + if options[:debug] Puppet::Util::Log.level = :debug elsif options[:verbose] diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 5abe3ea14..e76b347f6 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -130,7 +130,7 @@ class TypeDoc a[0].to_s <=> b[0].to_s }.each { |name, doc| print "\n- **#{name}**" - if type.namevar == name and name != :name + if type.key_attributes.include?(name) and name != :name puts " (*namevar*)" else puts "" diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb index 66aa6c8a1..1f6c63286 100644 --- a/lib/puppet/application/doc.rb +++ b/lib/puppet/application/doc.rb @@ -56,7 +56,7 @@ class Puppet::Application::Doc < Puppet::Application end def run_command - return[:rdoc, :trac, :markdown].include?(options[:mode]) ? send(options[:mode]) : other + return[:rdoc].include?(options[:mode]) ? send(options[:mode]) : other end def rdoc @@ -72,7 +72,7 @@ class Puppet::Application::Doc < Puppet::Application Puppet.settings.setdefaults( "puppetdoc", - + "document_all" => [false, "Document all resources"] ) Puppet.settings[:document_all] = options[:all] || false @@ -92,40 +92,6 @@ class Puppet::Application::Doc < Puppet::Application exit exit_code end - def trac - require 'puppet/util/reference' - options[:references].each do |name| - section = Puppet::Util::Reference.reference(name) or raise "Could not find section #{name}" - section.trac unless options[:mode] == :pdf - end - end - - def markdown - text = "" - with_contents = false - exit_code = 0 - require 'puppet/util/reference' - options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name| - raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name) - - begin - # Add the per-section text, but with no ToC - text += section.send(options[:format], with_contents) - text += Puppet::Util::Reference.footer - text.gsub!(/`\w+\s+([^`]+)`:trac:/) { |m| $1 } - Puppet::Util::Reference.markdown(name, text) - text = "" - rescue => detail - puts detail.backtrace - $stderr.puts "Could not generate reference #{name}: #{detail}" - exit_code = 1 - next - end - end - - exit exit_code - end - def other text = "" with_contents = options[:references].length <= 1 diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb index 777a50eaa..fde474907 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/application/queue.rb b/lib/puppet/application/queue.rb index 6df825dd1..239f6b2ad 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 '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 |
