lib/puppet/application/debugger.rb in puppet-debugger-0.17.0 vs lib/puppet/application/debugger.rb in puppet-debugger-0.18.0

- old
+ new

@@ -26,10 +26,14 @@ option("--log-level LEVEL", "-l") do |arg| Puppet::Util::Log.level = arg.to_sym end + option("--catalog catalog", "-c catalog") do |arg| + options[:catalog] = arg + end + option("--quiet", "-q") { |_arg| options[:quiet] = true } option("--play URL", "-p") do |arg| options[:play] = arg end @@ -130,18 +134,25 @@ Return the result from the debugger and exit * --stdin Read from stdin instead of starting the debugger right away. Useful when piping code into the debugger. +* --catalog: + Import a JSON catalog (such as one generated with 'puppet master --compile'). You need to + specify a valid JSON encoded catalog file. Gives you the ability + to inspect the catalog and all the parameter values that make up the resources. Can + specify a file or pipe to stdin with '-'. + * --node-name Retrieves the node information remotely via the puppet server given the node name. This is extremely useful when trying to debug classification issues, as this can show classes and parameters retrieved from the ENC. You can also play around with the real facts of the remote node as well. Note: this requires special permission in your puppet server's auth.conf file to allow - access to make remote calls from this node: #{Puppet[:certname]} + access to make remote calls from this node: #{Puppet[:certname]}. If you are running + the debugger from the puppet server as root you do not need any special setup. You must also have a signed cert and be able to connect to the server from this system. Mutually exclusive with --facterdb-filter @@ -173,11 +184,13 @@ HELP end def initialize(command_line = Puppet::Util::CommandLine.new) @command_line = CommandLineArgs.new(command_line.subcommand_name, command_line.args.dup) - @options = { use_facterdb: true, play: nil, run_once: false, node_name: nil, quiet: false, help: false, scope: nil } + @options = { use_facterdb: true, play: nil, run_once: false, + node_name: nil, quiet: false, help: false, scope: nil, + catalog: nil } @use_stdin = false begin require "puppet-debugger" rescue LoadError => e Puppet.err("You must install the puppet-debugger: gem install puppet-debugger") @@ -189,18 +202,18 @@ # if just the code we put in a file and use the play feature of the debugger # we could do the same thing with the passed in manifest file but that might be too much code to show if options[:code] code_input = options.delete(:code) - file = Tempfile.new(["puppet_repl_input", ".pp"]) + file = Tempfile.new(["puppet_debugger_input", ".pp"]) File.open(file, "w") do |f| f.write(code_input) end options[:play] = file elsif command_line.args.empty? && use_stdin code_input = STDIN.read - file = Tempfile.new(["puppet_repl_input", ".pp"]) + file = Tempfile.new(["puppet_debugger_input", ".pp"]) File.open(file, "w") do |f| f.write(code_input) end options[:play] = file elsif !command_line.args.empty? @@ -218,11 +231,17 @@ # start_debugger(scope) options[:scope] = scope end ::PuppetDebugger::Cli.start_without_stdin(options) rescue Exception => e - puts e - exit 1 + case e.class.to_s + when 'SystemExit' + return + else + puts e.message + puts e.backtrace + exit 1 + end end end def create_environment(manifest) configured_environment = Puppet.lookup(:current_environment)