bourdain 1.2.13

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/Gemfile +11 -0
  4. data/Rakefile +19 -0
  5. data/Readme.md +1 -0
  6. data/TODO.md +41 -0
  7. data/VERSION +1 -0
  8. data/bin/tony +54 -0
  9. data/bin/tony-bump +3 -0
  10. data/bin/tony-check +3 -0
  11. data/bin/tony-generate +3 -0
  12. data/bourdain.gemspec +25 -0
  13. data/install-or-upgrade.sh +4 -0
  14. data/lib/bourdain/helpers/config.rb +12 -0
  15. data/lib/bourdain/helpers/locals.rb +17 -0
  16. data/lib/bourdain/helpers/logger.rb +41 -0
  17. data/lib/bourdain/helpers/parser.rb +76 -0
  18. data/lib/bourdain/helpers/registry.rb +53 -0
  19. data/lib/bourdain/helpers.rb +32 -0
  20. data/lib/bourdain/metadata.rb +19 -0
  21. data/lib/bourdain/resources/checks/bourdain.rb +71 -0
  22. data/lib/bourdain/resources/checks/chef.rb +35 -0
  23. data/lib/bourdain/resources/checks/cookbooks.rb +97 -0
  24. data/lib/bourdain/resources/checks/hooks.rb +67 -0
  25. data/lib/bourdain/resources/checks/ssh_config.rb +61 -0
  26. data/lib/bourdain/resources/checks.rb +36 -0
  27. data/lib/bourdain/resources/commands/bump.rb +74 -0
  28. data/lib/bourdain/resources/commands/check.rb +103 -0
  29. data/lib/bourdain/resources/commands/generate.rb +33 -0
  30. data/lib/bourdain/resources/commands.rb +10 -0
  31. data/lib/bourdain/resources/generators/attribute.rb +43 -0
  32. data/lib/bourdain/resources/generators/cookbook.rb +125 -0
  33. data/lib/bourdain/resources/generators/recipe.rb +54 -0
  34. data/lib/bourdain/resources/generators.rb +22 -0
  35. data/lib/bourdain/resources.rb +104 -0
  36. data/lib/bourdain.rb +3 -0
  37. data/templates/chef/environment.json +8 -0
  38. data/templates/chef/role.json +9 -0
  39. data/templates/cookbook/Berksfile +3 -0
  40. data/templates/cookbook/Readme.md +1 -0
  41. data/templates/cookbook/VERSION +1 -0
  42. data/templates/cookbook/Vagrantfile +19 -0
  43. data/templates/cookbook/attributes/example.rb +24 -0
  44. data/templates/cookbook/busser_minitest.rb +7 -0
  45. data/templates/cookbook/gitignore +26 -0
  46. data/templates/cookbook/kitchen.yml +23 -0
  47. data/templates/cookbook/metadata.rb +10 -0
  48. data/templates/cookbook/pre-commit +80 -0
  49. data/templates/cookbook/recipes/example.rb +38 -0
  50. data/test.sh +12 -0
  51. metadata +165 -0
@@ -0,0 +1,104 @@
1
+ require 'trollop'
2
+
3
+
4
+ module Bourdain
5
+ class Resource
6
+ attr_reader :status, :spec, :opts, :raw_usage, :resource_name
7
+
8
+ def self.log= log ; @@log = log end
9
+
10
+ def self.resource_name ; raise 'not implemented' end
11
+
12
+ def self.raw_usage ; raise 'not implemented' end
13
+
14
+ def self.usage type, raw_usage
15
+ type = type.to_s
16
+
17
+ metaclass = class << self ; self ; end
18
+
19
+ metaclass.send(:define_method, 'raw_usage') do
20
+ raw_usage.gsub(/^ +/, '')
21
+ end
22
+
23
+ metaclass.send(:define_method, 'resource_name') do
24
+ raw_usage.lines.to_a[1].split(' ').first
25
+ end
26
+
27
+ metaclass.send(:define_method, 'resource_type') do
28
+ type
29
+ end
30
+
31
+ metaclass.send(:define_method, 'spec') do
32
+ self.spec ||= Bourdain::Helpers::UsageParser.parse(self.class.raw_usage)
33
+ end
34
+
35
+ Bourdain::Registry.register(type, self)
36
+ end
37
+
38
+ def initialize argv
39
+ @status = 0
40
+ @spec = Bourdain::Helpers::UsageParser.parse(self.class.raw_usage)
41
+ @opts = trollop_with_spec(self.class.resource_type, argv, @spec)
42
+ end
43
+
44
+
45
+ protected
46
+ def log ; @@log ||= Bourdain::Logger.new end
47
+
48
+ def error! ; @status = 1 end
49
+
50
+ def require_versionfile!
51
+ return true if File::exists?('VERSION')
52
+ log.fatal "I don't see any VERSION file around here..."
53
+ @status = 1
54
+ false
55
+ end
56
+
57
+ def require_cookbook!
58
+ return true if File::exists?('metadata.rb')
59
+ log.fatal "I don't see any metadata around here, is this a cookbook?"
60
+ @status = 1
61
+ false
62
+ end
63
+
64
+ def require_chef!
65
+ return true if File::exists?('Howto.md')
66
+ log.fatal "I don't see any Chef stuff around here, is this the Chef repo?"
67
+ @status = 1
68
+ false
69
+ end
70
+
71
+ def trollop_with_spec subcommand, argv, spec
72
+ subcommand = " #{subcommand}" unless subcommand.nil?
73
+ Trollop::options(argv) do
74
+ banner Bourdain::ART + "\n\n" + <<-EOS.gsub(/^ /, '')
75
+ #{spec[:desc]}
76
+
77
+ Usage: tony#{subcommand} #{spec[:usage]}
78
+ #{format_resources spec[:resources]}
79
+ Options:
80
+ EOS
81
+ spec[:opts].each do |opt|
82
+ send(:opt, opt[:long], opt[:desc], opt[:opts])
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+
90
+
91
+ module Trollop
92
+ class Parser
93
+ def format_resources rs
94
+ rs.map do |r|
95
+ "\n#{r.capitalize}s:\n" +
96
+ Bourdain::Registry.details(r) * "\n" + "\n"
97
+ end.join("\n")
98
+ end
99
+ end
100
+ end
101
+
102
+ require_relative 'resources/checks'
103
+ require_relative 'resources/commands'
104
+ require_relative 'resources/generators'
data/lib/bourdain.rb ADDED
@@ -0,0 +1,3 @@
1
+ require_relative 'bourdain/metadata'
2
+ require_relative 'bourdain/helpers'
3
+ require_relative 'bourdain/resources'
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "description": "<%= description %>",
4
+ "default_attributes": {},
5
+ "override_attributes": {},
6
+ "chef_type": "environment",
7
+ "json_class": "Chef::Environment"
8
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "description": "<%= description %>",
4
+ "default_attributes": {},
5
+ "override_attributes": {},
6
+ "run_list": [ "recipe[<%= name %>]" ],
7
+ "json_class": "Chef::Role",
8
+ "chef_type": "role"
9
+ }
@@ -0,0 +1,3 @@
1
+ source 'https://api.berkshelf.com'
2
+ metadata
3
+ cookbook 'apt'
@@ -0,0 +1 @@
1
+ # <%= name %>
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+ Vagrant.configure('2') do |config|
5
+ config.omnibus.chef_version = :latest
6
+ config.berkshelf.enabled = true
7
+ config.vm.define 'vagrant' do |node|
8
+ node.vm.box = 'chef/ubuntu-14.04'
9
+ node.vm.hostname = 'vagrant'
10
+ node.vm.provision :chef_solo do |chef|
11
+ chef.log_level = :debug
12
+ chef.json = {}
13
+ chef.run_list = %w(
14
+ recipe[apt]
15
+ recipe[<%= name %>]
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ <% if name == 'default' %>
2
+ # User for <%= cookbook_name %> directories, files, and services
3
+ default['<%= cookbook_name %>']['user'] = '<%= cookbook_name %>'
4
+
5
+ # Directory to install the <%= cookbook_name %> source
6
+ default['<%= cookbook_name %>']['home'] = '/opt/<%= cookbook_name %>'
7
+
8
+ # Directory to store the <%= cookbook_name %> logs
9
+ default['<%= cookbook_name %>']['logs'] = '/var/log/<%= cookbook_name %>'
10
+
11
+ # Directory to store the <%= cookbook_name %> data
12
+ default['<%= cookbook_name %>']['data'] = '/var/data/<%= cookbook_name %>'
13
+
14
+ # Version of <%= cookbook_name %> to install
15
+ default['<%= cookbook_name %>']['version'] = '1.0.0'
16
+
17
+ # Full URL (%pattern-sensitive) for <%= cookbook_name %> releases
18
+ default['<%= cookbook_name %>']['url'] = \
19
+ 'http://example.com/<%= cookbook_name %>%{version}.tar.gz'
20
+
21
+ # SHA-256 checksum for the bundled release
22
+ default['<%= cookbook_name %>']['checksum'] = \
23
+ '...'
24
+ <% end %>
@@ -0,0 +1,7 @@
1
+ require 'minitest/autorun'
2
+
3
+ describe '<%= cookbook_name %>::<%= recipe_name %>' do
4
+ it 'has done the thing' do
5
+ assert false
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ .vagrant
2
+ Berksfile.lock
3
+ *~
4
+ *#
5
+ .#*
6
+ \#*#
7
+ .*.sw[a-z]
8
+ *.un~
9
+ /cookbooks
10
+
11
+ # Bundler
12
+ Gemfile.lock
13
+ bin/*
14
+ .bundle/*
15
+
16
+ .kitchen/
17
+ .kitchen.local.yml
18
+
19
+ .DS_Store
20
+ *.tmp
21
+ *.out
22
+ *.pid
23
+ *.log
24
+ tmp
25
+
26
+ .chef/cookbooks
@@ -0,0 +1,23 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+ driver_config:
4
+ require_chef_omnibus: true
5
+
6
+ provisioner:
7
+ name: chef_solo
8
+ cookbook_files_glob: "**/*"
9
+
10
+ platforms:
11
+ - name: ubuntu-12.04
12
+ driver_config:
13
+ box: chef/ubuntu-12.04
14
+ - name: ubuntu-14.04
15
+ driver_config:
16
+ box: chef/ubuntu-14.04
17
+
18
+ suites:
19
+ - name: default
20
+ run_list:
21
+ - recipe[apt]
22
+ - recipe[<%= name %>]
23
+ attributes: {}
@@ -0,0 +1,10 @@
1
+ name '<%= name %>'
2
+ version File.read(File.join(File.dirname(__FILE__), 'VERSION')).strip
3
+ description 'Install and configure <%= name %>'
4
+ long_description 'Install and configure <%= name %>'
5
+ maintainer 'FIRSTNAME LASTNAME / Blue Jeans Network'
6
+ maintainer_email 'USERNAME@bluejeans.com'
7
+
8
+ # depends 'ark'
9
+
10
+ # suggests 'bjn_ruby'
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Pre-commit hook for checking cookbook standards and bumping versions
4
+ #
5
+ # set -x
6
+ set -e
7
+
8
+ function normalize {
9
+ arg="$1"
10
+ [ -z "$arg" ] && arg="yes"
11
+ echo "$arg" | tr '[:upper:]' '[:lower:]'
12
+ }
13
+
14
+
15
+ ROOT="$(git rev-parse --show-toplevel)"
16
+ NAME="$(basename $ROOT)"
17
+
18
+ cd $ROOT
19
+ echo "Checking cookbook..."
20
+ echo
21
+
22
+ find . -name .DS_Store -exec rm {} \; # INF-4970
23
+
24
+ bundle exec knife cookbook test $NAME -o ".."
25
+ bundle exec foodcritic .
26
+
27
+ exec < /dev/tty # Enable reading from STDIN in commit hook
28
+
29
+
30
+ if [ -f .kitchen.yml ] ; then
31
+ read -p "Now, you ran test kitchen, right? (yes|no) " plea
32
+ plea="$(normalize $plea)"
33
+ while [ "yes" != "$plea" -a "no" != "$plea" ] ; do
34
+ echo "Hey man, 'yes' or 'no' please."
35
+ read -p "But really, you ran test kitchen? (yes|no) " plea
36
+ plea="$(normalize $plea)"
37
+ done
38
+ if [ "no" == "$plea" ] ; then
39
+ echo "Thanks for your honesty. Bailing!"
40
+ exit 1
41
+ fi
42
+ echo "All right then..."
43
+ fi
44
+
45
+ if [ -f VERSION ] ; then
46
+ echo
47
+ read -p "Should I bump the cookbook version? (yes|no|major|minor) " plea
48
+ plea="$(normalize $plea)"
49
+ while [ -n "$plea" -a "yes" != "$plea" -a "no" != "$plea" -a "major" != "$plea" -a "minor" != "$plea" ] ; do
50
+ echo "I only understand 'yes', 'no', major', and 'minor'"
51
+ read -p "So should I bump it? (yes|no|major|minor) " plea
52
+ plea="$(normalize $plea)"
53
+ done
54
+
55
+
56
+ if [ "$plea" == "no" ] ; then
57
+ echo "No version bump for you, then!"
58
+ echo "Current version $(cat VERSION)."
59
+ fi
60
+
61
+ if [ "$plea" == "major" ] ; then
62
+ echo "Bumping the major version..."
63
+ bundle exec tony bump major
64
+ fi
65
+
66
+ if [ "$plea" == "minor" ] ; then
67
+ echo "Bumping the minor version..."
68
+ bundle exec tony bump minor
69
+ fi
70
+
71
+ if [ "$plea" == "yes" ] ; then
72
+ echo "Bumping the patch version..."
73
+ bundle exec tony bump
74
+ fi
75
+
76
+ git add VERSION
77
+ fi
78
+
79
+ echo
80
+ echo "Finished."
@@ -0,0 +1,38 @@
1
+ #
2
+ # Cookbook Name:: <%= cookbook_name %>
3
+ # Recipe:: <%= name %>
4
+ #
5
+ # Copyright (C) <%= Time.now.year %> Blue Jeans Network
6
+ #
7
+ <% if name == 'default' %>
8
+ # group node['<%= cookbook_name %>']['user'] do
9
+ # system true
10
+ # end
11
+
12
+ # user node['<%= cookbook_name %>']['user'] do
13
+ # gid node['<%= cookbook_name %>']['user']
14
+ # shell '/bin/false'
15
+ # system true
16
+ # end
17
+
18
+ # directory node['<%= cookbook_name %>']['logs'] do
19
+ # owner node['<%= cookbook_name %>']['user']
20
+ # group node['<%= cookbook_name %>']['user']
21
+ # recursive true
22
+ # end
23
+
24
+ # directory node['<%= cookbook_name %>']['data'] do
25
+ # owner node['<%= cookbook_name %>']['user']
26
+ # group node['<%= cookbook_name %>']['user']
27
+ # recursive true
28
+ # end
29
+
30
+ # ark '<%= cookbook_name %>' do
31
+ # url node['<%= cookbook_name %>']['url']
32
+ # checksum node['<%= cookbook_name %>']['checksum']
33
+ # version node['<%= cookbook_name %>']['version']
34
+ # home_dir node['<%= cookbook_name %>']['home']
35
+ # owner node['<%= cookbook_name %>']['user']
36
+ # group node['<%= cookbook_name %>']['user']
37
+ # end
38
+ <% end %>
data/test.sh ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ plea=no
3
+ read -p "You ran test kitch, right? (yes/no) " plea
4
+ while [ "yes" != "$plea" -a "no" != "$plea" ] ; do
5
+ echo "Hey, man, 'yes' or 'no' please."
6
+ read -p "But, really you ran test kitchen? (yes/no) " plea
7
+ done
8
+ if [ "no" == "$plea" ] ; then
9
+ echo "Thanks for your honesty. Bailing!"
10
+ exit 1
11
+ fi
12
+ echo "All right then..."
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bourdain
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.13
5
+ platform: ruby
6
+ authors:
7
+ - Sean Clemmer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pmap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gitlab
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: trollop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Tools for badass chefs.
84
+ email: sclemmer@bluejeans.com
85
+ executables:
86
+ - tony
87
+ - tony-bump
88
+ - tony-check
89
+ - tony-generate
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - Gemfile
95
+ - Rakefile
96
+ - Readme.md
97
+ - TODO.md
98
+ - VERSION
99
+ - bin/tony
100
+ - bin/tony-bump
101
+ - bin/tony-check
102
+ - bin/tony-generate
103
+ - bourdain.gemspec
104
+ - install-or-upgrade.sh
105
+ - lib/bourdain.rb
106
+ - lib/bourdain/helpers.rb
107
+ - lib/bourdain/helpers/config.rb
108
+ - lib/bourdain/helpers/locals.rb
109
+ - lib/bourdain/helpers/logger.rb
110
+ - lib/bourdain/helpers/parser.rb
111
+ - lib/bourdain/helpers/registry.rb
112
+ - lib/bourdain/metadata.rb
113
+ - lib/bourdain/resources.rb
114
+ - lib/bourdain/resources/checks.rb
115
+ - lib/bourdain/resources/checks/bourdain.rb
116
+ - lib/bourdain/resources/checks/chef.rb
117
+ - lib/bourdain/resources/checks/cookbooks.rb
118
+ - lib/bourdain/resources/checks/hooks.rb
119
+ - lib/bourdain/resources/checks/ssh_config.rb
120
+ - lib/bourdain/resources/commands.rb
121
+ - lib/bourdain/resources/commands/bump.rb
122
+ - lib/bourdain/resources/commands/check.rb
123
+ - lib/bourdain/resources/commands/generate.rb
124
+ - lib/bourdain/resources/generators.rb
125
+ - lib/bourdain/resources/generators/attribute.rb
126
+ - lib/bourdain/resources/generators/cookbook.rb
127
+ - lib/bourdain/resources/generators/recipe.rb
128
+ - templates/chef/environment.json
129
+ - templates/chef/role.json
130
+ - templates/cookbook/Berksfile
131
+ - templates/cookbook/Readme.md
132
+ - templates/cookbook/VERSION
133
+ - templates/cookbook/Vagrantfile
134
+ - templates/cookbook/attributes/example.rb
135
+ - templates/cookbook/busser_minitest.rb
136
+ - templates/cookbook/gitignore
137
+ - templates/cookbook/kitchen.yml
138
+ - templates/cookbook/metadata.rb
139
+ - templates/cookbook/pre-commit
140
+ - templates/cookbook/recipes/example.rb
141
+ - test.sh
142
+ homepage: http://wiki.bluejeansnet.com/operations/bourdain
143
+ licenses: []
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.2.2
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Tools for badass chefs
165
+ test_files: []