puppet-debugger 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +54 -0
  4. data/.gitlab-ci.yml +129 -0
  5. data/.rspec +3 -0
  6. data/CHANGELOG.md +61 -0
  7. data/Gemfile +18 -0
  8. data/Gemfile.lock +67 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.md +276 -0
  11. data/Rakefile +32 -0
  12. data/bin/pdb +4 -0
  13. data/lib/awesome_print/ext/awesome_puppet.rb +40 -0
  14. data/lib/puppet-debugger/cli.rb +247 -0
  15. data/lib/puppet-debugger/code/code_file.rb +98 -0
  16. data/lib/puppet-debugger/code/code_range.rb +69 -0
  17. data/lib/puppet-debugger/code/loc.rb +80 -0
  18. data/lib/puppet-debugger/debugger_code.rb +318 -0
  19. data/lib/puppet-debugger/support/compiler.rb +20 -0
  20. data/lib/puppet-debugger/support/environment.rb +38 -0
  21. data/lib/puppet-debugger/support/errors.rb +75 -0
  22. data/lib/puppet-debugger/support/facts.rb +78 -0
  23. data/lib/puppet-debugger/support/functions.rb +72 -0
  24. data/lib/puppet-debugger/support/input_responders.rb +136 -0
  25. data/lib/puppet-debugger/support/node.rb +90 -0
  26. data/lib/puppet-debugger/support/play.rb +91 -0
  27. data/lib/puppet-debugger/support/scope.rb +42 -0
  28. data/lib/puppet-debugger/support.rb +176 -0
  29. data/lib/puppet-debugger.rb +55 -0
  30. data/lib/trollop.rb +861 -0
  31. data/lib/version.rb +3 -0
  32. data/puppet-debugger.gemspec +36 -0
  33. data/run_container_test.sh +12 -0
  34. data/spec/facts_spec.rb +86 -0
  35. data/spec/fixtures/environments/production/manifests/site.pp +1 -0
  36. data/spec/fixtures/invalid_node_obj.yaml +8 -0
  37. data/spec/fixtures/node_obj.yaml +298 -0
  38. data/spec/fixtures/sample_manifest.pp +2 -0
  39. data/spec/fixtures/sample_start_debugger.pp +13 -0
  40. data/spec/pdb_spec.rb +50 -0
  41. data/spec/puppet-debugger_spec.rb +492 -0
  42. data/spec/remote_node_spec.rb +170 -0
  43. data/spec/spec_helper.rb +57 -0
  44. data/spec/support_spec.rb +190 -0
  45. data/test_matrix.rb +42 -0
  46. metadata +148 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e827c2ef8f176fac5a49ad37ca3aa17ce143595a
4
+ data.tar.gz: bf1db7841f1b6f1e42e49e84819d02482345cb92
5
+ SHA512:
6
+ metadata.gz: 882a35ed85e35402cd10a39379e99168e2d973341910c0ebca62a8896176477c943f0e23e18cd2fd2daadae01ecae2b90ff1ddfaf4c4b10cd8971177603b6b9e
7
+ data.tar.gz: d43765702b3c5f8e3ce6cd1f58b09bc2c1c6e8da49e26ac20bd80f444edb100d709f0abe21dea0dca64b7818a6e810ff1f8671a80e3228ad94fae126fe8017c6
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,54 @@
1
+ # rcov generated
2
+ .puppet_repl_input*
3
+ local_test_results
4
+ bundle
5
+ bundler
6
+ vendor
7
+ coverage
8
+ coverage.data
9
+
10
+ # rdoc generated
11
+ rdoc
12
+
13
+ # yard generated
14
+ doc
15
+ .yardoc
16
+
17
+ # bundler
18
+ .bundle
19
+
20
+ # jeweler generated
21
+ pkg
22
+
23
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
24
+ #
25
+ # * Create a file at ~/.gitignore
26
+ # * Include files you want ignored
27
+ # * Run: git config --global core.excludesfile ~/.gitignore
28
+ #
29
+ # After doing this, these files will be ignored in all your git projects,
30
+ # saving you from having to 'pollute' every project you touch with them
31
+ #
32
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
33
+ #
34
+ # For MacOS:
35
+ #
36
+ #.DS_Store
37
+
38
+ # For TextMate
39
+ #*.tmproj
40
+ #tmtags
41
+
42
+ # For emacs:
43
+ #*~
44
+ #\#*
45
+ #.\#*
46
+
47
+ # For vim:
48
+ #*.swp
49
+
50
+ # For redcar:
51
+ #.redcar
52
+
53
+ # For rubinius:
54
+ #*.rbc
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,129 @@
1
+ stages:
2
+ - test
3
+ - deploy
4
+ - web_deploy
5
+
6
+ .puppet_def: &puppet_job_def
7
+ stage: test
8
+ script:
9
+ - gem update --system > /dev/null
10
+ - gem install bundler > /dev/null
11
+ - bundle install --without development
12
+ - bundle exec puppet module install puppetlabs-stdlib
13
+ - bundle exec rake spec
14
+
15
+ web_trigger_staging:
16
+ type: web_deploy
17
+ variables:
18
+ REF: staging
19
+ only:
20
+ - master
21
+ script:
22
+ - "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
23
+
24
+ web_trigger_production:
25
+ type: web_deploy
26
+ variables:
27
+ REF: production
28
+ only:
29
+ - tags
30
+ script:
31
+ - "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
32
+
33
+ .ruby_193: &ruby193
34
+ image: ruby:1.9.3
35
+
36
+ .ruby_20: &ruby20
37
+ image: ruby:2.0
38
+
39
+ .ruby_21: &ruby21
40
+ image: ruby:2.1
41
+
42
+ .ruby_22: &ruby22
43
+ image: ruby:2.2
44
+
45
+ .ruby_23: &ruby23
46
+ image: ruby:2.3
47
+
48
+ gem_production:
49
+ image: ruby:2.1
50
+ before_script:
51
+ - gem install dpl
52
+ stage: deploy
53
+ script:
54
+ - dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
55
+ only:
56
+ - tags
57
+
58
+ puppet_38_ruby193:
59
+ variables:
60
+ PUPPET_GEM_VERSION: "~> 3.8"
61
+ <<: *puppet_job_def
62
+ <<: *ruby193
63
+
64
+ puppet_38_ruby20:
65
+ variables:
66
+ PUPPET_GEM_VERSION: "~> 3.8"
67
+ <<: *puppet_job_def
68
+ <<: *ruby20
69
+
70
+ puppet_38_ruby21:
71
+ variables:
72
+ PUPPET_GEM_VERSION: "~> 3.8"
73
+ <<: *puppet_job_def
74
+ <<: *ruby21
75
+
76
+ puppet_43_ruby20:
77
+ variables:
78
+ PUPPET_GEM_VERSION: "~> 4.3"
79
+ <<: *puppet_job_def
80
+ <<: *ruby20
81
+
82
+ puppet_43_ruby21:
83
+ variables:
84
+ PUPPET_GEM_VERSION: "~> 4.3"
85
+ <<: *puppet_job_def
86
+ <<: *ruby21
87
+
88
+ puppet_43_ruby22:
89
+ variables:
90
+ PUPPET_GEM_VERSION: "~> 4.3"
91
+ <<: *puppet_job_def
92
+ <<: *ruby22
93
+
94
+ puppet_44_ruby21:
95
+ variables:
96
+ PUPPET_GEM_VERSION: "~> 4.4"
97
+ <<: *puppet_job_def
98
+ <<: *ruby21
99
+
100
+ puppet_44_ruby22:
101
+ variables:
102
+ PUPPET_GEM_VERSION: "~> 4.4"
103
+ <<: *puppet_job_def
104
+ <<: *ruby22
105
+
106
+ puppet_45_ruby21:
107
+ variables:
108
+ PUPPET_GEM_VERSION: "~> 4.5"
109
+ <<: *puppet_job_def
110
+ <<: *ruby21
111
+
112
+ puppet_46_ruby22:
113
+ variables:
114
+ PUPPET_GEM_VERSION: "~> 4.6"
115
+ <<: *puppet_job_def
116
+ <<: *ruby22
117
+
118
+ puppet_47_ruby22:
119
+ variables:
120
+ PUPPET_GEM_VERSION: "~> 4.7"
121
+ <<: *puppet_job_def
122
+ <<: *ruby22
123
+
124
+ puppet_48_ruby22:
125
+ variables:
126
+ PUPPET_GEM_VERSION: "~> 4.8"
127
+ <<: *puppet_job_def
128
+ <<: *ruby22
129
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --no-color
2
+ --format documentation
3
+ --tty
data/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ ## 0.4.0
2
+ * Rename to puppet-debugger
3
+ ## 0.3.4
4
+ * Fixes issue with temporary file not being unique
5
+ ## 0.3.3
6
+ * Adds ability to call breakpoints from within repl
7
+ * Adds newline for each multiline input
8
+ ## 0.3.2
9
+ * Fixes #31 - adds ability to show surrounding code
10
+ ## 0.3.1
11
+ * Fixes #28 - puppet 4.6 support
12
+ * Fixes #27 - repl should throw puppet error message instead of stacktrace
13
+ * adds support for customizing facterdb filter
14
+ * adds support for puppet 4.6
15
+ * Fixes #26 - allow configuration of facter version and facterdb filter
16
+
17
+ ## 0.3.0
18
+ * Fixes #23 - add quiet flag to suppress banner
19
+ * Fixes #11 - cannot declare and use a class or define
20
+ ## 0.2.3
21
+ * fixes #21 - type display causes error
22
+ ## 0.2.2
23
+ * adds better support for playing back puppet code
24
+ * this now allows playback of any manifest
25
+ * allows mixed puppet code and repl commands
26
+ ## 0.2.1
27
+ * Fixes #2 - adds support for multiline input
28
+
29
+ ## 0.2.0
30
+ * Fixes #19 - lock down dependency versions
31
+ * fixes #18 - add ability to filter out functions based on namespace
32
+ * fixes #15 - node classes return error
33
+ * fixes #16 - use auto complete on functions and variables
34
+ * Fixes #14 - add functionality to set node object from remote source
35
+ * adds support for server_facts
36
+ * fixes other minor bugs found along the way
37
+ * adds ability to list classification parameters from ENC
38
+
39
+ ## 0.1.1
40
+ * adds ability to load files or urls
41
+
42
+ ## 0.1.0
43
+ * ensure the title of classes contains quotes
44
+ * adds support to import a file or import from stdin
45
+ * added additional ap support for puppet::pops::types
46
+ * adds ability to print resources and classes
47
+ * adds the ability to pass in a scope
48
+
49
+ ## 0.0.8
50
+ * adds ability to list currently loaded classes
51
+ * adds formatted output using awesome print
52
+ * adds verbose type output when creating resources
53
+
54
+ ## 0.0.7
55
+ * Added ability to list scope variables
56
+
57
+ ## 0.0.6
58
+ * Bug fix for puppet 3.8
59
+
60
+ ## 0.0.5
61
+ * Added ability to set puppet log level
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ gem 'puppet', ENV['PUPPET_GEM_VERSION'] || ">= 3.8"
3
+ gem 'facterdb', "~> 0.3"
4
+ gem 'awesome_print', "~> 1.6"
5
+
6
+ group :test do
7
+ # ruby versions prior to 2.0 cannot install json_pure 2.0.2+
8
+ gem 'json_pure', '<= 2.0.1'
9
+ gem "rdoc", "~> 3.12"
10
+ gem "rspec"
11
+ gem "bundler"
12
+ gem "simplecov", ">= 0"
13
+ gem 'rake'
14
+ end
15
+
16
+ group :development do
17
+ gem 'pry'
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ CFPropertyList (2.2.8)
5
+ awesome_print (1.7.0)
6
+ coderay (1.1.1)
7
+ diff-lcs (1.2.5)
8
+ docile (1.1.5)
9
+ facter (2.4.6)
10
+ CFPropertyList (~> 2.2.6)
11
+ facterdb (0.3.6)
12
+ facter
13
+ jgrep
14
+ hiera (3.2.1)
15
+ jgrep (1.4.1)
16
+ json
17
+ json (1.8.3)
18
+ json_pure (1.8.3)
19
+ method_source (0.8.2)
20
+ pry (0.10.4)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ puppet (4.7.0)
25
+ facter (> 2.0, < 4)
26
+ hiera (>= 2.0, < 4)
27
+ json_pure (~> 1.8)
28
+ rake (11.2.2)
29
+ rdoc (3.12.2)
30
+ json (~> 1.4)
31
+ rspec (3.5.0)
32
+ rspec-core (~> 3.5.0)
33
+ rspec-expectations (~> 3.5.0)
34
+ rspec-mocks (~> 3.5.0)
35
+ rspec-core (3.5.2)
36
+ rspec-support (~> 3.5.0)
37
+ rspec-expectations (3.5.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.5.0)
40
+ rspec-mocks (3.5.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.5.0)
43
+ rspec-support (3.5.0)
44
+ simplecov (0.12.0)
45
+ docile (~> 1.1.0)
46
+ json (>= 1.8, < 3)
47
+ simplecov-html (~> 0.10.0)
48
+ simplecov-html (0.10.0)
49
+ slop (3.6.0)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ awesome_print (~> 1.6)
56
+ bundler
57
+ facterdb (~> 0.3)
58
+ json_pure (<= 2.0.1)
59
+ pry
60
+ puppet (~> 4.3)
61
+ rake
62
+ rdoc (~> 3.12)
63
+ rspec
64
+ simplecov
65
+
66
+ BUNDLED WITH
67
+ 1.13.6
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Corey Osman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,276 @@
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
+
5
+ - [puppet-debugger](#puppet-debugger)
6
+ - [Compatibility](#compatibility)
7
+ - [Production usage](#production-usage)
8
+ - [Installation](#installation)
9
+ - [Load path](#load-path)
10
+ - [Interactive demo](#interactive-demo)
11
+ - [Web demo](#web-demo)
12
+ - [Usage](#usage)
13
+ - [Using Variables](#using-variables)
14
+ - [Listing variables](#listing-variables)
15
+ - [Listing functions](#listing-functions)
16
+ - [Using functions](#using-functions)
17
+ - [Duplicate resource error](#duplicate-resource-error)
18
+ - [Setting the puppet log level](#setting-the-puppet-log-level)
19
+ - [Remote nodes](#remote-nodes)
20
+ - [Setup](#setup)
21
+ - [Usage](#usage-1)
22
+ - [Command line:](#command-line)
23
+ - [From repl session:](#from-repl-session)
24
+ - [Auto Complete](#auto-complete)
25
+ - [Playback support](#playback-support)
26
+ - [Troubleshooting](#troubleshooting)
27
+ - [Copyright](#copyright)
28
+
29
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
30
+ ![Build Status](https://gitlab.com/nwops/puppet-debugger/badges/master/build.svg)
31
+ [![Gem Version](https://badge.fury.io/rb/puppet-debugger.svg)](https://badge.fury.io/rb/puppet-debugger)
32
+ # puppet-debugger
33
+
34
+ A interactive command line tool for evaluating and debugging the puppet language.
35
+
36
+ ## Compatibility
37
+ Requires Puppet 3.8+ and only uses the future parser.
38
+
39
+ ## Production usage
40
+ The puppet repl is a developer tool that should only be used when writing puppet code. Although it might seem useful
41
+ 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
+
43
+ ## Installation
44
+ `gem install puppet-debugger`
45
+
46
+ ## Load path
47
+ puppet-debugger will load all functions from your basemodulepath and environmentpath.
48
+
49
+ This means if you run `puppet module install puppetlabs-stdlib` and they will be available
50
+ in the repl.
51
+
52
+ ## Interactive demo
53
+ I have put together a repo with a few setup instructions that will assist you in setting up a "mock" environment
54
+ for usage with the puppet-debugger. This was originally intended when giving a demo of the repl, but also seems
55
+ useful for other people.
56
+
57
+ https://github.com/nwops/puppet-debugger-demo
58
+
59
+ ## Web demo
60
+ 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 repl.
62
+
63
+ ## Usage
64
+ puppet-debugger will only parse and evaulate your code. It will not build a catalog
65
+ and try to enforce the catalog. This has a few side affects.
66
+
67
+ 1. Type and provider code will not get run.
68
+ 2. Nothing is created or destroyed on your system.
69
+
70
+ `pdb`
71
+
72
+ Example Usage
73
+ ```
74
+ MacBook-Pro-2/tmp % pdb
75
+ Ruby Version: 2.0.0
76
+ Puppet Version: 3.8.5
77
+ Puppet Debugger Version: 0.0.7
78
+ Created by: NWOps <corey@nwops.io>
79
+ Type "exit", "functions", "vars", "krt", "facts", "reset", "help" for more information.
80
+
81
+ >> ['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }
82
+ => [
83
+ [0] "/tmp/test3",
84
+ [1] "/tmp/test4"
85
+ ]
86
+ >>
87
+
88
+ ```
89
+
90
+ ## Using Variables
91
+
92
+ ```
93
+ MacBook-Pro-2/tmp % pdb
94
+ Ruby Version: 2.0.0
95
+ Puppet Version: 3.8.5
96
+ Puppet Debugger Version: 0.0.7
97
+ Created by: NWOps <corey@nwops.io>
98
+ Type "exit", "functions", "vars", "krt", "facts", "reset", "help" for more information.
99
+
100
+ >>
101
+
102
+ >> $config_file = '/etc/httpd/httpd.conf'
103
+ => "/etc/httpd/httpd.conf"
104
+ >> file{$config_file: ensure => present, content => 'hello'}
105
+ => Puppet::Type::File {
106
+ path => "/etc/httpd/httpd.conf",
107
+ provider => posix,
108
+ ensure => present,
109
+ content => "{md5}5d41402abc4b2a76b9719d911017c592",
110
+ checksum => nil,
111
+ backup => "puppet",
112
+ replace => true,
113
+ links => manage,
114
+ purge => false,
115
+ sourceselect => first,
116
+ show_diff => true,
117
+ validate_replacement => "%",
118
+ source_permissions => use,
119
+ selinux_ignore_defaults => false,
120
+ loglevel => notice,
121
+ name => "/etc/httpd/httpd.conf",
122
+ title => "/etc/httpd/httpd.conf"
123
+ }
124
+ >>
125
+ ```
126
+ ### Listing variables
127
+ To see the current variables in the scope use the `vars` keyword.
128
+
129
+ ![variables](resources/variables.png)
130
+
131
+ ## Listing functions
132
+ Knowing what functions are available and where they come from is extremely helpful especially in a debugger session. Run the `functions` keyword to get a name spaced list of functions. You can further filter out functions by passing in a filter argument. `functions stdlib`
133
+
134
+ ![functions](resources/functions.png)
135
+
136
+ ## Using functions
137
+ Functions will run and produce the desired output. If you type the word `functions`
138
+ a list of available functions will be displayed on the screen along with a namespace to help you identify where they came from.
139
+
140
+ ```
141
+ >> split('hello/there/one/two/three','/')
142
+ => ["hello", "there", "one", "two", "three"]
143
+
144
+ ```
145
+
146
+ So you can imagine how much fun this can be trying out different types of functions.
147
+
148
+ ## Duplicate resource error
149
+ Just like normal puppet code you cannot create duplicate resources.
150
+
151
+ ```
152
+ >> file{'/tmp/failure2.txt': ensure => present}
153
+ => Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: File[/tmp/failure2.txt] is already declared in file :1; cannot redeclare at line 1 at line 1:1
154
+
155
+ ```
156
+ You can reset the parser by running `reset` within the debugger without having to exit.
157
+
158
+ ## Setting the puppet log level
159
+ If you want to see what puppet is doing behind the scenes you can set the log level
160
+ via `:set loglevel debug`. Valid log levels are `debug`, `info`, `warning` and other
161
+ levels defined in puppet [config reference](https://docs.puppetlabs.com/puppet/4.4/reference/configuration.html#loglevel) .
162
+
163
+ ![hiera](resources/hiera.png)
164
+
165
+ ## Remote nodes
166
+ This is new for 0.2.0. The puppet-debugger now has the ability to pull in remote node information. Instead of mocking facts you can pull in real information! Get real facts and real node classification from the puppet master and then play with the info in the debugger session. This is made possible by using the puppet node indirector interface.
167
+
168
+ ie. `puppet node find hostname --terminus rest --render-as yaml`
169
+
170
+ In order to use this feature you will need to setup a few things.
171
+
172
+ ### Setup
173
+ 1. Allow node rest calls to your workstation on the puppet master(s)
174
+ See https://github.com/nwops/puppet-debugger/issues/17 for more info on allowing this rule.
175
+
176
+ 2. Ensure you have the same code that your puppet master does. Since this pulls in classification you will need to have all the puppet modules defined in your
177
+ environmentpath or basemodulepath. The simple thing to do is to point your basemodulepath to your fixtures directory if using rspec-puppet or some other high level modules directory. For PE users you will want to ensure you have all the
178
+ pe specific modules in your development environment. Not doing this step will result in class not found errors.
179
+
180
+ 3. Set the server config in your local puppet.conf. (on your development machine)
181
+
182
+ a. Find your puppet config file `puppet config print config`
183
+
184
+ b. edit the config file with an editor
185
+
186
+ c. add `server = <hostname>` to your main block
187
+
188
+ 4. If using hiera you also need to set the path to your hiera config file since
189
+ the puppet-debugger will be compiling puppet code which could in turn call hiera
190
+ functions. Additionally, make sure your hiera config points to the correct
191
+ data location.
192
+
193
+ ```
194
+ [main]
195
+ server = pe-puppet.localdomain
196
+ basemodulepath = /Users/cosman/github/puppet-debugger-demo/modules:/Users/cosman/Downloads/pe_modules
197
+ hiera_config = /Users/cosman/github/puppet-debugger-demo/hieradata/hiera.yaml
198
+
199
+
200
+ ```
201
+
202
+ ### Usage
203
+ There are two ways of using the remote node feature. You can either
204
+ pass in the node name from the command line or set the node name from the debugger session.
205
+
206
+ #### Command line:
207
+ `pdb -n node_name`
208
+
209
+ ![command line](resources/command_line_node.png)
210
+
211
+ #### From debugger session:
212
+ `:set node node_name`
213
+
214
+ ![command line](resources/set_node.png)
215
+
216
+
217
+ This is also extremely useful to check classification rules and variables by your ENC. So instead of running your ENC script manually we get the puppet master to run this indirectly and return the results to you.
218
+
219
+ ## Auto Complete
220
+ The puppet-debugger uses readline internally. So any variable or function is also available for auto completion.
221
+ Press the tab key to engage the auto complete functionality.
222
+
223
+ Currently native functions are not available in auto complete. See #24
224
+
225
+ ## FacterDB and using different fact sets
226
+ The puppet-debugger internally leverages the [facterdb](https://github.com/camptocamp/facterdb/) gem to load pre-cached facts into the debugger session. At some point you
227
+ may need to override the debugger's default fact set with something of your own choosing. You can do this by setting one of the environment variables below.
228
+
229
+ * `REPL_FACTERDB_FILTER` Sets the entire filter
230
+ * `REPL_FACTER_OS_VERSION` Sets the OS version (only works with RHEL clones and Fedora)
231
+ * `REPL_FACTER_OS_NAME` Sets the OS name (only works with RHEL clones and Fedora)
232
+ * `REPL_FACTER_VERSION` Sets the facter version to use in the debugger session (uses facter 3.1 for puppet 4.4+ and facter 2.4 for 3.8-4.4)
233
+
234
+ By default it looks something like `operatingsystem=Fedora and operatingsystemrelease=23 and architecture=x86_64 and facterversion=/^3\\.1/`
235
+ depending on the puppet version currently running.
236
+
237
+ You can display the current facterdb filter by running `facterdb_filter` from the debugger session.
238
+
239
+ Why do facter versions matter? While facter and puppet work independently just fine, newer forge modules utilize certain data structures found only in newer versions of facter. So its really up to the puppet code you use. With facter 3, almost every fact is now a data structure. So if you are having issues with facts not existing in the debugger you may need to change the facter version `REPL_FACTER_VERSION` to something different.
240
+
241
+ ## Playback support
242
+ puppet-debugger now supports playing back files or urls and loading the content into the debugger session. This means if you want to start a debugger session from an existing file or url you can play the content back in the debugger.
243
+ You can also playback a file that contains puppet code and debugger commands.
244
+
245
+ `play https://gist.githubusercontent.com/logicminds/f9b1ac65a3a440d562b0/raw`
246
+
247
+ or
248
+
249
+ `pdb -p https://gist.githubusercontent.com/logicminds/f9b1ac65a3a440d562b0/raw`
250
+
251
+ or just use STDIN `pdb <some_file>` or `echo "abs(-3)" | pdb`
252
+
253
+ ### Web based playback support
254
+ If using the [web based debugger](https://www.puppet-debugger.com) you can playback a shared url
255
+ which would start a debugger session and then load the content from the url or parameter.
256
+
257
+ Example:
258
+ https://puppet-debugger.com/play?url=https://gist.github.com/logicminds/64f0fe9f64339f18f097a9f42acd6276
259
+
260
+ or for single commands
261
+
262
+ https://www.puppet-debugger.com/play?content=vars
263
+
264
+ Please note the web based debugger only contains a minimal amount of puppet modules. So its likely
265
+ that your code may not work if using third party modules. This may change in the future though.
266
+
267
+ ## Troubleshooting
268
+ Please file an issue so we can track bugs.
269
+
270
+
271
+ Pull requests welcomed.
272
+
273
+ ## Copyright
274
+
275
+ Copyright (c) 2016 Corey Osman. See LICENSE.txt for
276
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ require "bundler/gem_tasks"
6
+ require "rake/testtask"
7
+
8
+ begin
9
+ Bundler.setup(:default, :development, :test)
10
+ rescue Bundler::BundlerError => e
11
+ $stderr.puts e.message
12
+ $stderr.puts "Run `bundle install` to install missing gems"
13
+ exit e.status_code
14
+ end
15
+ require 'rake'
16
+
17
+ require 'rspec/core'
18
+ require 'rspec/core/rake_task'
19
+ RSpec::Core::RakeTask.new(:spec) do |spec|
20
+ spec.pattern = FileList['spec/**/*_spec.rb']
21
+ end
22
+
23
+ task :default => :spec
24
+
25
+ require 'rdoc/task'
26
+ Rake::RDocTask.new do |rdoc|
27
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = "puppet-debugger #{version}"
30
+ rdoc.rdoc_files.include('README*')
31
+ rdoc.rdoc_files.include('lib/**/*.rb')
32
+ end
data/bin/pdb ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/puppet-debugger'
3
+
4
+ PuppetDebugger::Cli.start