puppet-debugger-playbooks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c493684815ff75d76810bc91521bb1709e5af3cb
4
+ data.tar.gz: 4fff175e6e1970595446b6ac4f93e81224475d59
5
+ SHA512:
6
+ metadata.gz: 555f66c9d5ae9377a03cb797ac2369e6c67d35f2af58c2d8b28cbca727b5cbf7e64bfd284a372a3a1b225d51a47988f851482f610408632293c7cd75e68a0d13
7
+ data.tar.gz: 6718b584f4b53ce8ccf3c6dc3855d16454d6cc6ee7b3cc775ff4fdc414df68bdf92fd7e71c470eb693ed6cc7cbae1700032fd2fb8ff558c74975527069703a92
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ *.patch
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
@@ -0,0 +1,145 @@
1
+ stages:
2
+ - validate
3
+ - test
4
+ - 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 rake spec
13
+ tags:
14
+ - ruby
15
+
16
+ # rubocop_ruby:
17
+ # stage: validate
18
+ # allow_failure: true
19
+ # only:
20
+ # - branches
21
+ # tags:
22
+ # - ruby
23
+ # script:
24
+ # - bundle install
25
+ # - bundle exec rubocop -D
26
+
27
+ .ruby_193: &ruby193
28
+ image: ruby:1.9.3
29
+
30
+ .ruby_20: &ruby20
31
+ image: ruby:2.0
32
+
33
+ .ruby_21: &ruby21
34
+ image: ruby:2.1
35
+
36
+ .ruby_22: &ruby22
37
+ image: ruby:2.2
38
+
39
+ .ruby_23: &ruby23
40
+ image: ruby:2.3
41
+
42
+ .ruby_24: &ruby24
43
+ image: ruby:2.4
44
+
45
+ gem_production:
46
+ image: ruby:2.1
47
+ tags:
48
+ - ruby
49
+ before_script:
50
+ - gem install dpl
51
+ stage: deploy
52
+ script:
53
+ - dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
54
+ only:
55
+ - tags
56
+
57
+ puppet_38_ruby193:
58
+ variables:
59
+ PUPPET_GEM_VERSION: "~> 3.8.0"
60
+ <<: *puppet_job_def
61
+ <<: *ruby193
62
+
63
+ puppet_38_ruby20:
64
+ variables:
65
+ PUPPET_GEM_VERSION: "~> 3.8.0"
66
+ <<: *puppet_job_def
67
+ <<: *ruby20
68
+
69
+ puppet_38_ruby21:
70
+ variables:
71
+ PUPPET_GEM_VERSION: "~> 3.8.0"
72
+ <<: *puppet_job_def
73
+ <<: *ruby21
74
+
75
+ puppet_43_ruby20:
76
+ variables:
77
+ PUPPET_GEM_VERSION: "~> 4.3.0"
78
+ <<: *puppet_job_def
79
+ <<: *ruby20
80
+
81
+ puppet_43_ruby21:
82
+ variables:
83
+ PUPPET_GEM_VERSION: "~> 4.3.0"
84
+ <<: *puppet_job_def
85
+ <<: *ruby21
86
+
87
+ puppet_43_ruby22:
88
+ variables:
89
+ PUPPET_GEM_VERSION: "~> 4.3.0"
90
+ <<: *puppet_job_def
91
+ <<: *ruby22
92
+
93
+ puppet_44_ruby21:
94
+ variables:
95
+ PUPPET_GEM_VERSION: "~> 4.4.0"
96
+ <<: *puppet_job_def
97
+ <<: *ruby21
98
+
99
+ puppet_44_ruby22:
100
+ variables:
101
+ PUPPET_GEM_VERSION: "~> 4.4.0"
102
+ <<: *puppet_job_def
103
+ <<: *ruby22
104
+
105
+ puppet_45_ruby21:
106
+ variables:
107
+ PUPPET_GEM_VERSION: "~> 4.5.0"
108
+ <<: *puppet_job_def
109
+ <<: *ruby21
110
+
111
+ puppet_46_ruby22:
112
+ variables:
113
+ PUPPET_GEM_VERSION: "~> 4.6.0"
114
+ <<: *puppet_job_def
115
+ <<: *ruby22
116
+
117
+ puppet_47_ruby22:
118
+ variables:
119
+ PUPPET_GEM_VERSION: "~> 4.7.0"
120
+ <<: *puppet_job_def
121
+ <<: *ruby22
122
+
123
+ puppet_48_ruby22:
124
+ variables:
125
+ PUPPET_GEM_VERSION: "~> 4.8.0"
126
+ <<: *puppet_job_def
127
+ <<: *ruby22
128
+
129
+ puppet_49_ruby23:
130
+ variables:
131
+ PUPPET_GEM_VERSION: "~> 4.9.0"
132
+ <<: *puppet_job_def
133
+ <<: *ruby23
134
+
135
+ puppet_410_ruby24:
136
+ variables:
137
+ PUPPET_GEM_VERSION: "~> 4.10.0"
138
+ <<: *puppet_job_def
139
+ <<: *ruby24
140
+
141
+ puppet_5_ruby24:
142
+ variables:
143
+ PUPPET_GEM_VERSION: "~> 5.0"
144
+ <<: *puppet_job_def
145
+ <<: *ruby24
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at corey@nwops.io. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :test do
4
+ gem 'puppet-debugger', github: 'nwops/puppet-debugger'
5
+ gem 'CFPropertyList'
6
+ gem 'rake'
7
+ gem 'rspec', '>= 3.6'
8
+ # loads itself so you don't have to update RUBYLIB path
9
+ gem 'puppet-debugger-playbooks', path: './'
10
+ end
11
+
12
+ group :development do
13
+ gem 'pry'
14
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Corey Osman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Playbooks Plugin
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/puppet/debugger/playbooks`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'puppet-debugger-playbooks'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install puppet-debugger-playbooks
22
+
23
+ ## Usage
24
+
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Testing
33
+ You can simulate playbooks by setting the `PLAYBOOKS_DIR` environment variable before running the playbooks command from the debugger.
34
+
35
+ `PLAYBOOKS_DIR=spec/fixtures bundle exec pdb`
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/logicminds/puppet-debugger-playbooks. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
43
+
44
+ ## Code of Conduct
45
+
46
+ Everyone interacting in the Puppet::Debugger::Playbooks project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/logicminds/puppet-debugger-playbooks/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "puppet/debugger/playbooks"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,104 @@
1
+ require 'puppet-debugger/input_responder_plugin'
2
+ module PuppetDebugger
3
+ module InputResponders
4
+ class Playbooks < InputResponderPlugin
5
+ COMMAND_WORDS = %w(playbooks)
6
+ SUMMARY = 'Show a list of available playbooks.'
7
+ COMMAND_GROUP = :editing
8
+
9
+ def self.command_completion(buffer_words)
10
+ directories.map do |d|
11
+ path = File.join(d, *buffer_words)
12
+ glob_path = File.directory?(path) ? File.join(path, '*') : path + '*'
13
+ files = Dir.glob(glob_path)
14
+ dirs = files.grep(path).map { |f| File.basename(f, File.extname(f)) }
15
+ files.find_all {|d| d.match(path) }.map { |f| File.basename(f, File.extname(f)) } - dirs
16
+ end.flatten.sort
17
+ end
18
+
19
+ def self.directories
20
+ (internal_directories + external_directory).uniq
21
+ end
22
+
23
+ # @return [String] - the path to the playbooks directory
24
+ def self.internal_directories
25
+ playbooks_dir_list
26
+ end
27
+
28
+ # @return [Array[String]] dir of external playbooks dir
29
+ # empty array is returned if no external directory
30
+ def self.external_directory
31
+ [ENV['PLAYBOOKS_DIR']].compact
32
+ end
33
+
34
+ # @return [Array[String]] - a list of puppet debugger playbook directories
35
+ def self.playbooks_dir_list
36
+ @playbooks_dir_list ||= begin
37
+ gemspecs.collect do |spec|
38
+ lib_path = File.join(spec.full_gem_path,'lib','puppet-debugger','playbooks')
39
+ lib_path if Dir.exist?(lib_path)
40
+ end.compact
41
+ end
42
+ end
43
+
44
+ # Returns an Array of Gem::Specification objects.
45
+ def self.gemspecs
46
+ @gemspecs ||= Gem::Specification.respond_to?(:latest_specs) ?
47
+ Gem::Specification.latest_specs : Gem.searcher.init_gemspecs
48
+ end
49
+
50
+ def playbook_file(words)
51
+ path = File.join(*words)
52
+ file = nil
53
+ self.class.directories.find do |dir|
54
+ search_path = File.join(dir, path) + '*'
55
+ file = Dir.glob(search_path).find {|f| File.file?(f)}
56
+ end
57
+ file
58
+ end
59
+
60
+ def run(args = [])
61
+ if args.count > 0
62
+ file = playbook_file(args)
63
+ return debugger.handle_input("play #{file}") if file && File.exist?(file)
64
+ self.class.directories.each do |dir|
65
+ walk(dir) do |path|
66
+ if args.first == File.basename(path)
67
+ return create_tree([path])
68
+ end
69
+ end
70
+ end
71
+ else
72
+ create_tree(self.class.directories)
73
+ end
74
+ end
75
+
76
+ # @param dirs [Array[String]]
77
+ def create_tree(dirs = [])
78
+ tree = []
79
+ dirs.each do |dir|
80
+ walk(dir) do |path, depth|
81
+ tree << sprintf("%s%s\n", (' ' * depth), File.basename(path, File.extname(path)) )
82
+ end
83
+ end
84
+ tree.join()
85
+ end
86
+
87
+ private
88
+
89
+ # @param dir [String] - directory path
90
+ # @param depth [Integer] - where you are in the directory tree
91
+ # @param block [block] - passes path and depth to block
92
+ # @return [nil]
93
+ def walk(dir, depth = 0, &block)
94
+ Dir.foreach(dir).sort.each do |name|
95
+ next if name == '.' || name == '..'
96
+ path = File.join(dir, name)
97
+ block.call(path, depth)
98
+ walk(path, depth + 1, &block) if File.directory?(path)
99
+ end
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "puppet-debugger-playbooks"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Corey Osman"]
9
+ spec.email = ["corey@nwops.io"]
10
+
11
+ spec.summary = %q{A puppet debugger plugin that allows one to play back predfined puppet scripts.}
12
+ spec.description = %q{A puppet debugger plugin that allows one to play back predfined puppet scripts.}
13
+ spec.homepage = "https://gitlab.com/puppet-debugger/puppet-debugger-playbooks"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-debugger-playbooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Corey Osman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A puppet debugger plugin that allows one to play back predfined puppet
14
+ scripts.
15
+ email:
16
+ - corey@nwops.io
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".gitlab-ci.yml"
23
+ - ".rspec"
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/plugins/puppet-debugger/input_responders/playbooks.rb
32
+ - puppet-debugger-playbooks.gemspec
33
+ homepage: https://gitlab.com/puppet-debugger/puppet-debugger-playbooks
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 2.6.11
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: A puppet debugger plugin that allows one to play back predfined puppet scripts.
57
+ test_files: []