puppet-debugger 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +5 -0
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -4
- data/Gemfile.lock +26 -15
- data/README.md +31 -24
- data/lib/puppet-debugger/cli.rb +6 -5
- data/lib/puppet-debugger/support.rb +4 -27
- data/lib/puppet-debugger/support/compiler.rb +1 -1
- data/lib/puppet-debugger/support/environment.rb +32 -5
- data/lib/puppet-debugger/support/functions.rb +4 -17
- data/lib/puppet-debugger/support/input_responders.rb +1 -0
- data/lib/puppet-debugger/support/loader.rb +34 -0
- data/lib/puppet-debugger/support/node.rb +21 -0
- data/lib/puppet-debugger/support/scope.rb +9 -8
- data/lib/puppet/application/debugger.rb +7 -19
- data/lib/trollop.rb +740 -739
- data/lib/version.rb +1 -1
- data/puppet-debugger.gemspec +5 -4
- data/spec/environment_spec.rb +22 -0
- data/spec/puppet/application/debugger_spec.rb +72 -17
- data/spec/puppet_debugger_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf5bf556d8e8b1810aff75dc4ca595b8d52d1f2e
|
4
|
+
data.tar.gz: 57513b64926b0107ecff995c4ce81985dce6ea6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8de0ef4a70b41de5ed03f119f1332e16222ba9fd3a8405ae31526004be2c69ab2cbf6abf56c02862113eca6e60d90fe69711519de30667155b1763922275247
|
7
|
+
data.tar.gz: a1bd4e25633ee39854aad9a4ff74489eb22773c03012c23b4b8926e57583f4922f8f5c9da0ec9007b12f9b0f832923daa48666fea503514c18a605d8f718e81a
|
data/.dockerignore
CHANGED
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## 0.5.0
|
4
|
+
* Fixes #gh-49 - puppet 4 functions don't seem to work
|
5
|
+
* Disables trying to set trusted_node_data for puppet versions that do not support it
|
6
|
+
## 0.4.4
|
7
|
+
* Refactor to upcoming puppet 5.0 (minor fix, requires a few more changes)
|
8
|
+
* Fixes issue with frozen string literal under ruby 2.3.x
|
9
|
+
## 0.4.3
|
10
|
+
* Fixes issue with older facterdb filter not working
|
11
|
+
## 0.4.2
|
12
|
+
* Fixes #44 - error when running under puppet apply
|
1
13
|
## 0.4.1
|
2
14
|
* Adds a puppet application face
|
3
15
|
* Fixes #41 - add file reference when showing code during code break
|
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || "
|
2
|
+
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || "~> 4.9.0"
|
3
3
|
gem 'facterdb', ">= 0.3.8"
|
4
4
|
gem 'awesome_print', "~> 1.6"
|
5
5
|
|
@@ -12,12 +12,10 @@ group :test do
|
|
12
12
|
gem "simplecov", ">= 0"
|
13
13
|
gem 'rake'
|
14
14
|
gem 'release_me'
|
15
|
+
gem 'pry'
|
15
16
|
end
|
16
17
|
|
17
18
|
group :validate do
|
18
19
|
gem 'rubocop'
|
19
20
|
end
|
20
21
|
|
21
|
-
group :development do
|
22
|
-
gem 'pry'
|
23
|
-
end
|
data/Gemfile.lock
CHANGED
@@ -5,36 +5,46 @@ GEM
|
|
5
5
|
ast (2.3.0)
|
6
6
|
awesome_print (1.7.0)
|
7
7
|
coderay (1.1.1)
|
8
|
-
diff-lcs (1.
|
8
|
+
diff-lcs (1.3)
|
9
9
|
docile (1.1.5)
|
10
10
|
facter (2.4.6)
|
11
11
|
CFPropertyList (~> 2.2.6)
|
12
|
-
facterdb (0.3.
|
12
|
+
facterdb (0.3.10)
|
13
13
|
facter
|
14
14
|
jgrep
|
15
|
-
|
15
|
+
fast_gettext (1.1.0)
|
16
|
+
gettext (3.2.2)
|
17
|
+
locale (>= 2.0.5)
|
18
|
+
text (>= 1.3.0)
|
19
|
+
gettext-setup (0.16)
|
20
|
+
fast_gettext (~> 1.1.0)
|
21
|
+
gettext (>= 3.0.2)
|
22
|
+
locale
|
23
|
+
hiera (3.3.1)
|
16
24
|
jgrep (1.4.1)
|
17
25
|
json
|
18
|
-
json (1.8.
|
19
|
-
json_pure (1.8.
|
26
|
+
json (1.8.6)
|
27
|
+
json_pure (1.8.6)
|
28
|
+
locale (2.1.2)
|
20
29
|
method_source (0.8.2)
|
21
|
-
parser (2.
|
30
|
+
parser (2.4.0.0)
|
22
31
|
ast (~> 2.2)
|
23
32
|
powerpack (0.1.1)
|
24
33
|
pry (0.10.4)
|
25
34
|
coderay (~> 1.1.0)
|
26
35
|
method_source (~> 0.8.1)
|
27
36
|
slop (~> 3.4)
|
28
|
-
puppet (4.
|
29
|
-
CFPropertyList (~> 2.2.6)
|
37
|
+
puppet (4.9.4)
|
30
38
|
facter (> 2.0, < 4)
|
39
|
+
gettext-setup (>= 0.10, < 1)
|
31
40
|
hiera (>= 2.0, < 4)
|
32
41
|
json_pure (~> 1.8)
|
42
|
+
locale (~> 2.1)
|
33
43
|
rainbow (2.2.1)
|
34
44
|
rake (12.0.0)
|
35
45
|
rdoc (3.12.2)
|
36
46
|
json (~> 1.4)
|
37
|
-
release_me (0.1.
|
47
|
+
release_me (0.1.4)
|
38
48
|
rspec (3.5.0)
|
39
49
|
rspec-core (~> 3.5.0)
|
40
50
|
rspec-expectations (~> 3.5.0)
|
@@ -48,20 +58,21 @@ GEM
|
|
48
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
59
|
rspec-support (~> 3.5.0)
|
50
60
|
rspec-support (3.5.0)
|
51
|
-
rubocop (0.
|
52
|
-
parser (>= 2.3.
|
61
|
+
rubocop (0.47.1)
|
62
|
+
parser (>= 2.3.3.1, < 3.0)
|
53
63
|
powerpack (~> 0.1)
|
54
64
|
rainbow (>= 1.99.1, < 3.0)
|
55
65
|
ruby-progressbar (~> 1.7)
|
56
66
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
57
67
|
ruby-progressbar (1.8.1)
|
58
|
-
simplecov (0.
|
68
|
+
simplecov (0.14.1)
|
59
69
|
docile (~> 1.1.0)
|
60
70
|
json (>= 1.8, < 3)
|
61
71
|
simplecov-html (~> 0.10.0)
|
62
72
|
simplecov-html (0.10.0)
|
63
73
|
slop (3.6.0)
|
64
|
-
|
74
|
+
text (1.3.1)
|
75
|
+
unicode-display_width (1.1.3)
|
65
76
|
|
66
77
|
PLATFORMS
|
67
78
|
ruby
|
@@ -72,7 +83,7 @@ DEPENDENCIES
|
|
72
83
|
facterdb (>= 0.3.8)
|
73
84
|
json_pure (<= 2.0.1)
|
74
85
|
pry
|
75
|
-
puppet (
|
86
|
+
puppet (~> 4.9.0)
|
76
87
|
rake
|
77
88
|
rdoc (~> 3.12)
|
78
89
|
release_me
|
@@ -81,4 +92,4 @@ DEPENDENCIES
|
|
81
92
|
simplecov
|
82
93
|
|
83
94
|
BUNDLED WITH
|
84
|
-
1.
|
95
|
+
1.14.6
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+

|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
|
1
6
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
2
7
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
3
8
|
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
@@ -27,7 +32,6 @@
|
|
27
32
|
- [Copyright](#copyright)
|
28
33
|
|
29
34
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
30
|
-

|
31
35
|
[](https://badge.fury.io/rb/puppet-debugger)
|
32
36
|
# puppet-debugger
|
33
37
|
|
@@ -37,7 +41,7 @@ A interactive command line tool for evaluating and debugging the puppet language
|
|
37
41
|
Requires Puppet 3.8+ and only uses the future parser.
|
38
42
|
|
39
43
|
## Production usage
|
40
|
-
The puppet
|
44
|
+
The puppet debugger is a developer tool that should only be used when writing puppet code. Although it might seem useful
|
41
45
|
to install on your production puppet master. Please do not install because of the puppet-debugger gem dependencies that might conflict with your existing environment.
|
42
46
|
|
43
47
|
## Installation
|
@@ -47,7 +51,7 @@ to install on your production puppet master. Please do not install because of th
|
|
47
51
|
puppet-debugger will load all functions from your basemodulepath and environmentpath.
|
48
52
|
|
49
53
|
This means if you run `puppet module install puppetlabs-stdlib` and they will be available
|
50
|
-
in the
|
54
|
+
in the debugger.
|
51
55
|
|
52
56
|
## Interactive demo
|
53
57
|
I have put together a repo with a few setup instructions that will assist you in setting up a "mock" environment
|
@@ -58,41 +62,44 @@ https://github.com/nwops/puppet-debugger-demo
|
|
58
62
|
|
59
63
|
## Web demo
|
60
64
|
There is a web version of the [puppet-debugger](https://www.puppet-debugger.com) online but is somewhat
|
61
|
-
limited at this time. In the future we will be adding lots of awesome features to the web
|
65
|
+
limited at this time. In the future we will be adding lots of awesome features to the web debugger.
|
62
66
|
|
63
67
|
## Usage
|
64
|
-
puppet
|
65
|
-
|
68
|
+
The puppet debugger is a puppet application so once you install the gem, just fire it up using `puppet debugger`.
|
69
|
+
If you have used `puppet apply` to evaulate puppet code, this replaces all of that with a simple debugger REPL console.
|
70
|
+
The debugger will only parse and evaluate your code. It will not build a catalog
|
71
|
+
and try to enforce the catalog. This has a few side affects. This means you can type any puppet code in the debugger
|
72
|
+
and see what it would actual do when compiling a resource.
|
66
73
|
|
67
74
|
1. Type and provider code will not get run.
|
68
75
|
2. Nothing is created or destroyed on your system.
|
69
76
|
|
70
|
-
`
|
77
|
+
`puppet debugger`
|
71
78
|
|
72
79
|
Example Usage
|
73
80
|
```
|
74
|
-
MacBook-Pro-2/tmp %
|
81
|
+
MacBook-Pro-2/tmp % puppet debugger
|
75
82
|
Ruby Version: 2.0.0
|
76
|
-
Puppet Version:
|
77
|
-
Puppet Debugger Version: 0.
|
83
|
+
Puppet Version: 4.8.1
|
84
|
+
Puppet Debugger Version: 0.4.3
|
78
85
|
Created by: NWOps <corey@nwops.io>
|
79
|
-
Type "exit", "functions", "vars", "krt", "facts", "
|
86
|
+
Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "classes",
|
87
|
+
"play", "classification", "reset", or "help" for more information.
|
80
88
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
89
|
+
1:>> ['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }
|
90
|
+
=> [
|
91
|
+
[0] "/tmp/test3",
|
92
|
+
[1] "/tmp/test4"
|
93
|
+
]
|
94
|
+
2:>>
|
87
95
|
|
88
|
-
```
|
89
96
|
|
90
|
-
|
97
|
+
```
|
91
98
|
|
92
99
|
## Using Variables
|
93
100
|
|
94
101
|
```
|
95
|
-
MacBook-Pro-2/tmp %
|
102
|
+
MacBook-Pro-2/tmp % puppet debugger
|
96
103
|
Ruby Version: 2.0.0
|
97
104
|
Puppet Version: 3.8.5
|
98
105
|
Puppet Debugger Version: 0.0.7
|
@@ -206,7 +213,7 @@ There are two ways of using the remote node feature. You can either
|
|
206
213
|
pass in the node name from the command line or set the node name from the debugger session.
|
207
214
|
|
208
215
|
#### Command line:
|
209
|
-
`
|
216
|
+
`puppet debugger -n node_name`
|
210
217
|
|
211
218
|

|
212
219
|
|
@@ -248,9 +255,9 @@ You can also playback a file that contains puppet code and debugger commands.
|
|
248
255
|
|
249
256
|
or
|
250
257
|
|
251
|
-
`
|
258
|
+
`puppet debugger -p https://gist.githubusercontent.com/logicminds/f9b1ac65a3a440d562b0/raw`
|
252
259
|
|
253
|
-
or just use STDIN `
|
260
|
+
or just use STDIN `puppet debugger <some_file>` or `echo "abs(-3)" | puppet debugger`
|
254
261
|
|
255
262
|
### Web based playback support
|
256
263
|
If using the [web based debugger](https://www.puppet-debugger.com) you can playback a shared url
|
@@ -274,5 +281,5 @@ Pull requests welcomed.
|
|
274
281
|
|
275
282
|
## Copyright
|
276
283
|
|
277
|
-
Copyright (c)
|
284
|
+
Copyright (c) 2017 Corey Osman. See LICENSE.txt for
|
278
285
|
further details.
|
data/lib/puppet-debugger/cli.rb
CHANGED
@@ -11,6 +11,12 @@ module PuppetDebugger
|
|
11
11
|
attr_accessor :settings, :log_level, :in_buffer, :out_buffer, :html_mode
|
12
12
|
|
13
13
|
def initialize(options = {})
|
14
|
+
do_initialize if Puppet[:codedir].nil?
|
15
|
+
Puppet.settings[:name] = :debugger
|
16
|
+
Puppet.settings[:trusted_server_facts] = true unless Puppet.settings[:trusted_server_facts].nil?
|
17
|
+
Puppet[:static_catalogs] = false unless Puppet.settings[:static_catalogs].nil?
|
18
|
+
set_remote_node_name(options[:node_name])
|
19
|
+
initialize_from_scope(options[:scope])
|
14
20
|
@log_level = 'notice'
|
15
21
|
@out_buffer = options[:out_buffer] || $stdout
|
16
22
|
@html_mode = options[:html_mode] || false
|
@@ -28,7 +34,6 @@ module PuppetDebugger
|
|
28
34
|
sort_keys: true,
|
29
35
|
indent: 2
|
30
36
|
}
|
31
|
-
do_initialize
|
32
37
|
end
|
33
38
|
|
34
39
|
# returns a cached list of key words
|
@@ -197,8 +202,6 @@ Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "clas
|
|
197
202
|
def self.start_without_stdin(options = { scope: nil })
|
198
203
|
puts print_repl_desc unless options[:quiet]
|
199
204
|
repl_obj = PuppetDebugger::Cli.new(options)
|
200
|
-
repl_obj.remote_node_name = options[:node_name] if options[:node_name]
|
201
|
-
repl_obj.initialize_from_scope(options[:scope])
|
202
205
|
# TODO: make the output optional so we can have different output destinations
|
203
206
|
puts repl_obj.whereami if options[:source_file] && options[:source_line]
|
204
207
|
repl_obj.play_back(options) if options[:play]
|
@@ -219,8 +222,6 @@ Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "clas
|
|
219
222
|
options = opts.merge(options)
|
220
223
|
puts print_repl_desc unless options[:quiet]
|
221
224
|
repl_obj = PuppetDebugger::Cli.new(options)
|
222
|
-
repl_obj.remote_node_name = opts[:node_name] if opts[:node_name]
|
223
|
-
repl_obj.initialize_from_scope(options[:scope])
|
224
225
|
if options[:play]
|
225
226
|
repl_obj.play_back(opts)
|
226
227
|
# when the user supplied a file name without using the args (stdin)
|
@@ -16,6 +16,7 @@ module PuppetDebugger
|
|
16
16
|
include PuppetDebugger::Support::Scope
|
17
17
|
include PuppetDebugger::Support::Functions
|
18
18
|
include PuppetDebugger::Support::Node
|
19
|
+
include PuppetDebugger::Support::Loader
|
19
20
|
include PuppetDebugger::Support::InputResponders
|
20
21
|
include PuppetDebugger::Support::Play
|
21
22
|
|
@@ -44,17 +45,6 @@ module PuppetDebugger
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
|
-
# returns an array of module directories, generally this is the only place
|
48
|
-
# to look for puppet code by default. This is read from the puppet configuration
|
49
|
-
def default_modules_paths
|
50
|
-
dirs = []
|
51
|
-
do_initialize if Puppet[:codedir].nil?
|
52
|
-
# add the puppet-debugger directory so we can load any defined functions
|
53
|
-
dirs << File.join(Puppet[:environmentpath], default_puppet_env_name, 'modules') unless Puppet[:environmentpath].empty?
|
54
|
-
dirs << Puppet.settings[:basemodulepath].split(':')
|
55
|
-
dirs.flatten
|
56
|
-
end
|
57
|
-
|
58
48
|
# this is the lib directory of this gem
|
59
49
|
# in order to load any puppet functions from this gem we need to add the lib path
|
60
50
|
# of this gem
|
@@ -62,14 +52,9 @@ module PuppetDebugger
|
|
62
52
|
File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib'))
|
63
53
|
end
|
64
54
|
|
65
|
-
# returns all the modules paths defined in the environment
|
66
|
-
def modules_paths
|
67
|
-
puppet_environment.full_modulepath
|
68
|
-
end
|
69
|
-
|
70
55
|
def initialize_from_scope(value)
|
71
56
|
set_scope(value)
|
72
|
-
|
57
|
+
if value
|
73
58
|
set_environment(value.environment)
|
74
59
|
set_node(value.compiler.node)
|
75
60
|
set_compiler(value.compiler)
|
@@ -105,7 +90,6 @@ module PuppetDebugger
|
|
105
90
|
Puppet[:parser] = 'future' # this is required in order to work with puppet 3.8
|
106
91
|
Puppet[:trusted_node_data] = true
|
107
92
|
rescue ArgumentError => e
|
108
|
-
|
109
93
|
rescue Puppet::DevError => e
|
110
94
|
# do nothing otherwise calling init twice raises an error
|
111
95
|
end
|
@@ -147,7 +131,8 @@ module PuppetDebugger
|
|
147
131
|
File.open(file, 'w') do |f|
|
148
132
|
f.write(input)
|
149
133
|
end
|
150
|
-
Puppet.override({
|
134
|
+
Puppet.override({ current_environment: puppet_environment, code: input,
|
135
|
+
global_scope: scope, loaders: scope.compiler.loaders }, 'For puppet-debugger') do
|
151
136
|
# because the repl is not a module we leave the modname blank
|
152
137
|
scope.environment.known_resource_types.import_ast(ast, '')
|
153
138
|
parser.evaluate_string(scope, input, File.expand_path(file))
|
@@ -164,13 +149,5 @@ module PuppetDebugger
|
|
164
149
|
def parser
|
165
150
|
@parser ||= ::Puppet::Pops::Parser::EvaluatingParser.new
|
166
151
|
end
|
167
|
-
|
168
|
-
def default_manifests_dir
|
169
|
-
File.join(Puppet[:environmentpath], default_puppet_env_name, 'manifests')
|
170
|
-
end
|
171
|
-
|
172
|
-
def default_site_manifest
|
173
|
-
File.join(default_manifests_dir, 'site.pp')
|
174
|
-
end
|
175
152
|
end
|
176
153
|
end
|
@@ -8,12 +8,39 @@ module PuppetDebugger
|
|
8
8
|
@puppet_environment ||= create_environment
|
9
9
|
end
|
10
10
|
|
11
|
+
# returns an array of module directories, generally this is the only place
|
12
|
+
# to look for puppet code by default. This is read from the puppet configuration
|
13
|
+
def default_modules_paths
|
14
|
+
dirs = []
|
15
|
+
# add the puppet-debugger directory so we can load any defined functions
|
16
|
+
dirs << File.join(Puppet[:environmentpath], default_puppet_env_name, 'modules') unless Puppet[:environmentpath].empty?
|
17
|
+
dirs << Puppet.settings[:basemodulepath].split(File::PATH_SEPARATOR)
|
18
|
+
dirs.flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
# returns all the modules paths defined in the environment
|
22
|
+
def modules_paths
|
23
|
+
puppet_environment.full_modulepath
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_manifests_dir
|
27
|
+
File.join(Puppet[:environmentpath], Puppet[:environment], 'manifests')
|
28
|
+
end
|
29
|
+
|
30
|
+
def default_site_manifest
|
31
|
+
File.join(default_manifests_dir, 'site.pp')
|
32
|
+
end
|
33
|
+
|
34
|
+
# returns the environment
|
11
35
|
def create_environment
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
36
|
+
Puppet::Node::Environment.create(Puppet[:environment],
|
37
|
+
default_modules_paths,
|
38
|
+
default_manifests_dir)
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_node_environment(manifest = nil)
|
42
|
+
env = Puppet.lookup(:current_environment)
|
43
|
+
manifest ? env.override_with(manifest: manifest) : env
|
17
44
|
end
|
18
45
|
|
19
46
|
def set_environment(value)
|