puppet-debugger 0.15.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +21 -45
- data/.rubocop.yml +64 -233
- data/.rubocop_todo.yml +89 -147
- data/.ruby-version +1 -1
- data/.vscode/launch.json +15 -0
- data/CHANGELOG.md +34 -2
- data/Gemfile +7 -5
- data/README.md +29 -261
- data/Rakefile +11 -12
- data/bin/pdb +1 -1
- data/lib/awesome_print/ext/awesome_puppet.rb +22 -8
- data/lib/plugins/puppet-debugger/input_responders/benchmark.rb +5 -4
- data/lib/plugins/puppet-debugger/input_responders/classes.rb +14 -2
- data/lib/plugins/puppet-debugger/input_responders/classification.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/commands.rb +18 -18
- data/lib/plugins/puppet-debugger/input_responders/datatypes.rb +22 -6
- data/lib/plugins/puppet-debugger/input_responders/environment.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/exit.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/facterdb_filter.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/facts.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/functions.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/help.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/krt.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/play.rb +22 -24
- data/lib/plugins/puppet-debugger/input_responders/reset.rb +5 -3
- data/lib/plugins/puppet-debugger/input_responders/resources.rb +16 -7
- data/lib/plugins/puppet-debugger/input_responders/set.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/stacktrace.rb +23 -0
- data/lib/plugins/puppet-debugger/input_responders/types.rb +6 -2
- data/lib/plugins/puppet-debugger/input_responders/vars.rb +8 -7
- data/lib/plugins/puppet-debugger/input_responders/whereami.rb +5 -3
- data/lib/puppet-debugger.rb +1 -45
- data/lib/puppet-debugger/cli.rb +120 -92
- data/lib/puppet-debugger/code/code_file.rb +13 -14
- data/lib/puppet-debugger/code/code_range.rb +5 -3
- data/lib/puppet-debugger/code/loc.rb +1 -1
- data/lib/puppet-debugger/debugger_code.rb +2 -0
- data/lib/puppet-debugger/hooks.rb +15 -16
- data/lib/puppet-debugger/input_responder_plugin.rb +54 -52
- data/lib/puppet-debugger/monkey_patches.rb +57 -0
- data/lib/puppet-debugger/plugin_test_helper.rb +9 -8
- data/lib/puppet-debugger/support.rb +27 -17
- data/lib/puppet-debugger/support/environment.rb +10 -3
- data/lib/puppet-debugger/support/errors.rb +25 -27
- data/lib/puppet-debugger/support/facts.rb +5 -5
- data/lib/puppet-debugger/support/node.rb +4 -7
- data/lib/puppet-debugger/support/scope.rb +29 -0
- data/lib/puppet-debugger/trollop.rb +38 -31
- data/lib/puppet-debugger/version.rb +1 -1
- data/lib/puppet/application/debugger.rb +151 -126
- data/output.json +1 -0
- data/puppet-debugger.gemspec +17 -15
- data/spec/awesome_print/ext/awesome_puppet_spec.rb +30 -30
- data/spec/fixtures/pe-xl-core-0.puppet.vm.json +1 -0
- data/spec/fixtures/sample_start_debugger.pp +3 -2
- data/spec/hooks_spec.rb +33 -35
- data/spec/input_responder_plugin_spec.rb +7 -6
- data/spec/input_responders/benchmark_spec.rb +3 -1
- data/spec/input_responders/classes_spec.rb +12 -13
- data/spec/input_responders/classification_spec.rb +4 -2
- data/spec/input_responders/commands_spec.rb +2 -0
- data/spec/input_responders/datatypes_spec.rb +8 -2
- data/spec/input_responders/environment_spec.rb +2 -0
- data/spec/input_responders/exit_spec.rb +9 -11
- data/spec/input_responders/facterdb_filter_spec.rb +2 -0
- data/spec/input_responders/facts_spec.rb +2 -0
- data/spec/input_responders/functions_spec.rb +30 -28
- data/spec/input_responders/help_spec.rb +5 -3
- data/spec/input_responders/krt_spec.rb +3 -1
- data/spec/input_responders/play_spec.rb +10 -20
- data/spec/input_responders/reset_spec.rb +2 -0
- data/spec/input_responders/resources_spec.rb +7 -1
- data/spec/input_responders/set_spec.rb +3 -1
- data/spec/input_responders/stacktrace_spec.rb +15 -0
- data/spec/input_responders/types_spec.rb +2 -0
- data/spec/input_responders/vars_spec.rb +4 -4
- data/spec/input_responders/whereami_spec.rb +2 -0
- data/spec/pdb_spec.rb +0 -9
- data/spec/puppet/application/debugger_spec.rb +35 -17
- data/spec/puppet_debugger_spec.rb +81 -83
- data/spec/remote_node_spec.rb +1 -5
- data/spec/spec_helper.rb +22 -18
- data/spec/support_spec.rb +3 -5
- data/test_matrix.rb +1 -1
- metadata +53 -19
@@ -1,68 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
require 'puppet-debugger/support/errors'
|
3
5
|
require 'forwardable'
|
4
6
|
|
5
7
|
module PuppetDebugger
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
class InputResponderPlugin
|
9
|
+
include Singleton
|
10
|
+
extend Forwardable
|
11
|
+
attr_accessor :debugger
|
12
|
+
def_delegators :debugger, :scope, :node, :environment, :loaders, :puppet_environment,
|
13
|
+
:add_hook, :handle_input, :delete_hook, :puppet_lib_dir
|
14
|
+
def_delegators :scope, :compiler, :catalog
|
15
|
+
def_delegators :node, :facts
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
# @return [Array[String]] an array of words the user can call the command with
|
18
|
+
def self.command_words
|
19
|
+
self::COMMAND_WORDS
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def modules_paths
|
23
|
+
debugger.puppet_environment.full_modulepath
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
# @return [String] a summary of the plugin
|
27
|
+
def self.summary
|
28
|
+
self::SUMMARY
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
# @return [String] the name of the command group the plugin is in
|
32
|
+
def self.command_group
|
33
|
+
self::COMMAND_GROUP
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
# @return [Hash] a has of all the details of the plugin
|
37
|
+
def self.details
|
38
|
+
{ words: command_words, summary: summary, group: command_group }
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
# @param buffer_words [Array[String]] a array of words the user has typed in
|
42
|
+
# @return Array[String] - an array of words that will help the user with word completion
|
43
|
+
# By default this returns an empty array, your plugin can chose to override this method in order to
|
44
|
+
# provide the user with a list of key words based on the user's input
|
45
|
+
def self.command_completion(_buffer_words)
|
46
|
+
[]
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
# @param args [Array[String]] - an array of arguments to pass to the plugin command
|
50
|
+
# @param debugger PuppetDebugger::Cli - an instance of the PuppetDebugger::Cli object
|
51
|
+
# @return the output of the plugin command
|
52
|
+
def self.execute(args = [], debugger)
|
53
|
+
instance.debugger = debugger
|
54
|
+
instance.run(args)
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
# @param args [Array[String]] - an array of arguments to pass to the plugin command
|
58
|
+
# @return the output of the plugin command
|
59
|
+
def run(args = [])
|
60
|
+
raise NotImplementedError
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
63
|
+
# this is the lib directory of this gem
|
64
|
+
# in order to load any puppet functions from this gem we need to add the lib path
|
65
|
+
# of this gem
|
66
|
+
def puppet_debugger_lib_dir
|
67
|
+
File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib'))
|
67
68
|
end
|
69
|
+
end
|
68
70
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# monkey patch in some color effects string methods
|
4
|
+
class String
|
5
|
+
def red
|
6
|
+
"\033[31m#{self}\033[0m"
|
7
|
+
end
|
8
|
+
|
9
|
+
def bold
|
10
|
+
"\033[1m#{self}\033[22m"
|
11
|
+
end
|
12
|
+
|
13
|
+
def black
|
14
|
+
"\033[30m#{self}\033[0m"
|
15
|
+
end
|
16
|
+
|
17
|
+
def green
|
18
|
+
"\033[32m#{self}\033[0m"
|
19
|
+
end
|
20
|
+
|
21
|
+
def cyan
|
22
|
+
"\033[36m#{self}\033[0m"
|
23
|
+
end
|
24
|
+
|
25
|
+
def yellow
|
26
|
+
"\033[33m#{self}\033[0m"
|
27
|
+
end
|
28
|
+
|
29
|
+
def warning
|
30
|
+
yellow
|
31
|
+
end
|
32
|
+
|
33
|
+
def fatal
|
34
|
+
red
|
35
|
+
end
|
36
|
+
|
37
|
+
def info
|
38
|
+
green
|
39
|
+
end
|
40
|
+
|
41
|
+
def camel_case
|
42
|
+
return self if self !~ /_/ && self =~ /[A-Z]+.*/
|
43
|
+
|
44
|
+
split('_').map(&:capitalize).join
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Bolt plans utilize the PAL Script Compiler to compile the code and thus
|
49
|
+
# don't store a catalog with the scope. This is due to not needing the catalog
|
50
|
+
# in the scope. The debugger relies on the catalog being present in the scope
|
51
|
+
# and thus uses all the methods to discover various data in the catalog
|
52
|
+
# We monkey patch in a catalog here instead of changing our API for simplicity.
|
53
|
+
class Puppet::Parser::ScriptCompiler
|
54
|
+
def catalog
|
55
|
+
@catalog ||= Puppet::Resource::Catalog.new(@node_name, @environment, 'bolt')
|
56
|
+
end
|
57
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# https://relishapp.com/rspec/rspec-core/v/3-6/docs/example-groups/shared-examples
|
2
|
-
RSpec.shared_examples
|
4
|
+
RSpec.shared_examples 'plugin_tests' do |_parameter|
|
3
5
|
let(:plugin) do
|
4
6
|
instance = PuppetDebugger::InputResponders::Commands.plugin_from_command(subject.to_s).instance
|
5
7
|
instance.debugger = debugger
|
@@ -18,20 +20,20 @@ RSpec.shared_examples "plugin_tests" do |parameter|
|
|
18
20
|
{}
|
19
21
|
end
|
20
22
|
|
21
|
-
it
|
23
|
+
it 'commands contant is an array' do
|
22
24
|
expect(plugin.class::COMMAND_WORDS).to be_a(Array)
|
23
25
|
end
|
24
26
|
|
25
|
-
it
|
26
|
-
expect(plugin.class::COMMAND_WORDS.count).to
|
27
|
+
it 'commands must contain at least one word' do
|
28
|
+
expect(plugin.class::COMMAND_WORDS.count).to be > 0
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
31
|
+
it 'summary must be a string' do
|
30
32
|
expect(plugin.class::SUMMARY).to be_a(String)
|
31
33
|
end
|
32
34
|
|
33
35
|
it 'implements run' do
|
34
|
-
expect{plugin.run([])}.not_to raise_error
|
36
|
+
expect { plugin.run([]) }.not_to raise_error
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'be looked up via any command words' do
|
@@ -40,5 +42,4 @@ RSpec.shared_examples "plugin_tests" do |parameter|
|
|
40
42
|
expect(actual).to eq(plugin.class)
|
41
43
|
end
|
42
44
|
end
|
43
|
-
|
44
|
-
end
|
45
|
+
end
|
@@ -83,14 +83,14 @@ module PuppetDebugger
|
|
83
83
|
nodes: scope.environment.known_resource_types.nodes.keys
|
84
84
|
}
|
85
85
|
if sites = scope.environment.known_resource_types.instance_variable_get(:@sites)
|
86
|
-
res[:sites] =
|
86
|
+
res[:sites] = sites
|
87
87
|
end
|
88
|
-
if scope.environment.known_resource_types.respond_to?(:applications)
|
89
|
-
res[:applications] =
|
88
|
+
if apps = scope.environment.known_resource_types.respond_to?(:applications)
|
89
|
+
res[:applications] = apps
|
90
90
|
end
|
91
91
|
# some versions of puppet do not support capabilities
|
92
|
-
if scope.environment.known_resource_types.respond_to?(:capability_mappings)
|
93
|
-
res[:capability_mappings] =
|
92
|
+
if maps = scope.environment.known_resource_types.respond_to?(:capability_mappings)
|
93
|
+
res[:capability_mappings] = maps
|
94
94
|
end
|
95
95
|
res
|
96
96
|
end
|
@@ -100,8 +100,8 @@ module PuppetDebugger
|
|
100
100
|
Puppet.initialize_settings
|
101
101
|
Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8
|
102
102
|
Puppet[:trusted_node_data] = true
|
103
|
-
rescue ArgumentError
|
104
|
-
rescue Puppet::DevError
|
103
|
+
rescue ArgumentError
|
104
|
+
rescue Puppet::DevError
|
105
105
|
# do nothing otherwise calling init twice raises an error
|
106
106
|
end
|
107
107
|
|
@@ -131,31 +131,41 @@ module PuppetDebugger
|
|
131
131
|
::Puppet::Parser::AST::Hostclass.new('', code: ast_code)
|
132
132
|
end
|
133
133
|
|
134
|
+
# @return [String] the path to the manifest file
|
135
|
+
# @param input [String] the manfiest content
|
136
|
+
# @summary creates a manifest file unless one already exist
|
137
|
+
def manifest_file(input)
|
138
|
+
file = Tempfile.new(['puppet_debugger_input', '.pp'])
|
139
|
+
File.open(file, 'w') do |f|
|
140
|
+
f.write(input)
|
141
|
+
end
|
142
|
+
file
|
143
|
+
end
|
144
|
+
|
134
145
|
# @param String - any valid puppet language code
|
135
146
|
# @return Object - returns either a string of the result or object from puppet evaulation
|
136
|
-
def puppet_eval(input)
|
147
|
+
def puppet_eval(input, file: nil)
|
137
148
|
# in order to add functions to the scope the loaders must be created
|
138
149
|
# in order to call native functions we need to set the global_scope
|
139
|
-
ast = generate_ast(input)
|
140
150
|
# record the input for puppet to retrieve and reference later
|
141
|
-
|
142
|
-
File.
|
143
|
-
|
144
|
-
|
145
|
-
Puppet.override({ current_environment: puppet_environment,
|
151
|
+
manifest_file = file || manifest_file(input)
|
152
|
+
manfifest_content = input || File.read(manifest_file)
|
153
|
+
ast = generate_ast(manfifest_content)
|
154
|
+
|
155
|
+
Puppet.override({ current_environment: puppet_environment, manifest: manifest_file,
|
146
156
|
global_scope: scope, loaders: scope.compiler.loaders }, 'For puppet-debugger') do
|
147
|
-
# because the
|
157
|
+
# because the debugger is not a module we leave the modname blank
|
148
158
|
scope.environment.known_resource_types.import_ast(ast, '')
|
149
159
|
|
150
160
|
exec_hook :before_eval, '', self, self
|
151
161
|
if bench
|
152
162
|
result = nil
|
153
163
|
time = Benchmark.realtime do
|
154
|
-
result = parser.evaluate_string(scope,
|
164
|
+
result = parser.evaluate_string(scope, manfifest_content, File.expand_path(manifest_file))
|
155
165
|
end
|
156
166
|
out = [result, "Time elapsed #{(time * 1000).round(2)} ms"]
|
157
167
|
else
|
158
|
-
out = parser.evaluate_string(scope,
|
168
|
+
out = parser.evaluate_string(scope, manfifest_content, File.expand_path(manifest_file))
|
159
169
|
end
|
160
170
|
exec_hook :after_eval, out, self, self
|
161
171
|
out
|
@@ -8,7 +8,7 @@ module PuppetDebugger
|
|
8
8
|
def puppet_environment
|
9
9
|
@puppet_environment ||= create_environment
|
10
10
|
end
|
11
|
-
alias
|
11
|
+
alias environment puppet_environment
|
12
12
|
|
13
13
|
# returns an array of module directories, generally this is the only place
|
14
14
|
# to look for puppet code by default. This is read from the puppet configuration
|
@@ -17,7 +17,14 @@ module PuppetDebugger
|
|
17
17
|
# add the puppet-debugger directory so we can load any defined functions
|
18
18
|
dirs << File.join(Puppet[:environmentpath], default_puppet_env_name, 'modules') unless Puppet[:environmentpath].empty?
|
19
19
|
dirs << Puppet.settings[:basemodulepath].split(File::PATH_SEPARATOR)
|
20
|
-
dirs.
|
20
|
+
dirs << Puppet.settings[:vendormoduledir].split(File::PATH_SEPARATOR) if Puppet.settings[:vendormoduledir]
|
21
|
+
dirs << bolt_modules
|
22
|
+
dirs.flatten.compact.uniq
|
23
|
+
end
|
24
|
+
|
25
|
+
def bolt_modules
|
26
|
+
spec = Gem::Specification.latest_specs.find { |s| s.name.eql?('bolt') }
|
27
|
+
File.join(spec.full_gem_path, 'bolt-modules') if spec
|
21
28
|
end
|
22
29
|
|
23
30
|
# returns all the modules paths defined in the environment
|
@@ -60,7 +67,7 @@ module PuppetDebugger
|
|
60
67
|
|
61
68
|
# currently this is not being used
|
62
69
|
def environment_loaders
|
63
|
-
|
70
|
+
compiler.loaders.public_environment_loader.loader_name
|
64
71
|
end
|
65
72
|
end
|
66
73
|
end
|
@@ -9,8 +9,6 @@ module PuppetDebugger
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
12
|
class FatalError < Error
|
15
13
|
end
|
16
14
|
|
@@ -22,9 +20,9 @@ module PuppetDebugger
|
|
22
20
|
|
23
21
|
class ConnectError < Error
|
24
22
|
def message
|
25
|
-
|
26
|
-
#{data[:message]}
|
27
|
-
|
23
|
+
<<~OUT
|
24
|
+
#{data[:message]}
|
25
|
+
OUT
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
@@ -36,9 +34,9 @@ EOF
|
|
36
34
|
|
37
35
|
class UndefinedNode < FatalError
|
38
36
|
def message
|
39
|
-
|
40
|
-
Cannot find node with name: #{data[:name]} on remote server
|
41
|
-
|
37
|
+
<<~OUT
|
38
|
+
Cannot find node with name: #{data[:name]} on remote server
|
39
|
+
OUT
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
@@ -48,36 +46,36 @@ Cannot find node with name: #{data[:name]} on remote server
|
|
48
46
|
|
49
47
|
class NoClassError < FatalError
|
50
48
|
def message
|
51
|
-
|
52
|
-
#{data[:message]}
|
53
|
-
You are missing puppet classes that are required for compilation.
|
54
|
-
Please ensure these classes are installed on this machine in any of the following paths:
|
55
|
-
#{data[:default_modules_paths]}
|
56
|
-
|
49
|
+
<<~OUT
|
50
|
+
#{data[:message]}
|
51
|
+
You are missing puppet classes that are required for compilation.
|
52
|
+
Please ensure these classes are installed on this machine in any of the following paths:
|
53
|
+
#{data[:default_modules_paths]}
|
54
|
+
OUT
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
class NodeDefinitionError < FatalError
|
61
59
|
def message
|
62
|
-
out =
|
63
|
-
You are missing a default node definition in your site.pp that is required for compilation.
|
64
|
-
Please ensure you have at least the following default node definition
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
in your #{data[:default_site_manifest]} file.
|
69
|
-
|
60
|
+
out = <<~OUT
|
61
|
+
You are missing a default node definition in your site.pp that is required for compilation.
|
62
|
+
Please ensure you have at least the following default node definition
|
63
|
+
node default {
|
64
|
+
# include classes here
|
65
|
+
}
|
66
|
+
in your #{data[:default_site_manifest]} file.
|
67
|
+
OUT
|
70
68
|
out.fatal
|
71
69
|
end
|
72
70
|
end
|
73
71
|
|
74
72
|
class AuthError < FatalError
|
75
73
|
def message
|
76
|
-
|
77
|
-
#{data[:message]}
|
78
|
-
You will need to edit your auth.conf or conf.d/auth.conf (puppetserver) to allow node calls.
|
79
|
-
|
80
|
-
|
74
|
+
<<~OUT
|
75
|
+
#{data[:message]}
|
76
|
+
You will need to edit your auth.conf or conf.d/auth.conf (puppetserver) to allow node calls.
|
77
|
+
OUT
|
78
|
+
end
|
81
79
|
end
|
82
80
|
end
|
83
81
|
end
|
@@ -46,11 +46,11 @@ module PuppetDebugger
|
|
46
46
|
def node_facts
|
47
47
|
node_facts = FacterDB.get_facts(dynamic_facterdb_filter).first
|
48
48
|
if node_facts.nil?
|
49
|
-
message =
|
50
|
-
Using filter: #{dynamic_facterdb_filter}
|
51
|
-
Bad FacterDB filter, please change the filter so it returns a result set.
|
52
|
-
See https://github.com/camptocamp/facterdb/#with-a-string-filter
|
53
|
-
|
49
|
+
message = <<~OUT
|
50
|
+
Using filter: #{dynamic_facterdb_filter}
|
51
|
+
Bad FacterDB filter, please change the filter so it returns a result set.
|
52
|
+
See https://github.com/camptocamp/facterdb/#with-a-string-filter
|
53
|
+
OUT
|
54
54
|
raise PuppetDebugger::Exception::BadFilter, message: message
|
55
55
|
end
|
56
56
|
# fix for when --show-legacy facts are not part of the facter 3 fact set
|
@@ -8,8 +8,6 @@ module PuppetDebugger
|
|
8
8
|
# creates a node object using defaults or gets the remote node
|
9
9
|
# object if the remote_node_name is defined
|
10
10
|
def create_node
|
11
|
-
Puppet[:trusted_server_facts] = true if Puppet.version.to_f >= 4.1 && Puppet.version.to_f < 6.0
|
12
|
-
|
13
11
|
if remote_node_name
|
14
12
|
# refetch
|
15
13
|
node_obj = set_node_from_name(remote_node_name)
|
@@ -34,6 +32,7 @@ module PuppetDebugger
|
|
34
32
|
# Collect our facts.
|
35
33
|
facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value])
|
36
34
|
raise "Could not find facts for #{Puppet[:node_name_value]}" unless facts
|
35
|
+
|
37
36
|
Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
|
38
37
|
facts.name = Puppet[:node_name_value]
|
39
38
|
end
|
@@ -41,6 +40,7 @@ module PuppetDebugger
|
|
41
40
|
# Find our Node
|
42
41
|
node = Puppet::Node.indirection.find(Puppet[:node_name_value])
|
43
42
|
raise "Could not find node #{Puppet[:node_name_value]}" unless node
|
43
|
+
|
44
44
|
# Merge in the facts.
|
45
45
|
node.merge(facts.values) if facts
|
46
46
|
end
|
@@ -93,11 +93,8 @@ module PuppetDebugger
|
|
93
93
|
def set_node_from_name(name)
|
94
94
|
out_buffer.puts "Fetching node #{name}"
|
95
95
|
remote_node = get_remote_node(name)
|
96
|
-
|
97
|
-
|
98
|
-
raise PuppetDebugger::Exception::UndefinedNode, name: remote_node.name
|
99
|
-
end
|
100
|
-
remote_node_name = remote_node.name
|
96
|
+
raise PuppetDebugger::Exception::UndefinedNode, name: remote_node.name if remote_node&.parameters&.empty?
|
97
|
+
|
101
98
|
node_object = convert_remote_node(remote_node)
|
102
99
|
set_node(node_object)
|
103
100
|
end
|