chef-recipe 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chef-recipe.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Bryan Berry
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # chef-recipe
2
+
3
+ This gem installs chef-recipe, a command-line to help you start
4
+ learning Chef as quickly as possible. This is an education tool meant
5
+ to new Chef users started as quickly as possible.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'chef-recipe'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install chef-recipe
20
+
21
+ ## Usage
22
+
23
+ `chef-recipe RECIPE_FILE`
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
32
+
33
+ ## Authorship
34
+
35
+ This gem is based on a [gist](https://gist.github.com/2920702) written by Daniel DeLeo
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/chef-recipe ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # ./chef-recipe - Run a single chef recipe, for educational purposes
4
+ #
5
+ # Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
6
+ # Copyright:: Copyright (c) 2012 Bryan W. Berry
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+
21
+ require 'rubygems'
22
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
23
+ require 'chef/application/recipe'
24
+
25
+ Chef::Application::Recipe.new.run
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/chef-recipe/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Bryan Berry"]
6
+ gem.email = ["bryan.berry@gmail.com"]
7
+ gem.description = %q{command to execute a single chef recipe}
8
+ gem.summary = %q{This gem installs a command that can be used to execute a single chef recipe}
9
+ gem.homepage = "https://github.com/bryanwb/chef-recipe"
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.add_dependency "chef"
14
+ %w(rspec-core rspec-expectations rspec-mocks).each { |g| gem.add_development_dependency g, "~> 2.8.0" }
15
+ gem.bindir = "bin"
16
+ gem.executables = %w( chef-recipe )
17
+ gem.name = "chef-recipe"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = Chef::Recipe::VERSION
20
+ end
@@ -0,0 +1,126 @@
1
+ #
2
+ # Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
3
+ # Author:: Daniel DeLeo (<dan@kallistec.com>)
4
+ # Copyright:: Copyright (c) 2012 Bryan W. Berry
5
+ # Copyright:: Copyright (c) 2012 Daniel DeLeo
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require 'chef'
21
+ require 'chef/application'
22
+ require 'chef/client'
23
+ require 'chef/config'
24
+ require 'chef/log'
25
+ require 'fileutils'
26
+ require 'chef/providers'
27
+ require 'chef/resources'
28
+
29
+ class Chef::Application::Recipe < Chef::Application
30
+
31
+ banner "Usage: chef-recipe RECIPE_FILE"
32
+
33
+
34
+ option :log_level,
35
+ :short => "-l LEVEL",
36
+ :long => "--log_level LEVEL",
37
+ :description => "Set the log level (debug, info, warn, error, fatal)",
38
+ :proc => lambda { |l| l.to_sym }
39
+
40
+ option :help,
41
+ :short => "-h",
42
+ :long => "--help",
43
+ :description => "Show this message",
44
+ :on => :tail,
45
+ :boolean => true,
46
+ :show_options => true,
47
+ :exit => 0
48
+
49
+ option :version,
50
+ :short => "-v",
51
+ :long => "--version",
52
+ :description => "Show chef version",
53
+ :boolean => true,
54
+ :proc => lambda {|v| puts "Chef: #{::Chef::VERSION}"},
55
+ :exit => 0
56
+
57
+ option :why_run,
58
+ :short => '-W',
59
+ :long => '--why-run',
60
+ :description => 'Enable whyrun mode',
61
+ :boolean => true
62
+
63
+ def initialize
64
+ super
65
+ end
66
+
67
+ def reconfigure
68
+ configure_logging
69
+ end
70
+
71
+
72
+ class Chef::Client
73
+ attr_reader :events
74
+ end
75
+
76
+ def find_recipe(recipe_path)
77
+ if recipe_path.nil?
78
+ STDERR.puts banner
79
+ exit 1
80
+ elsif !::File.exist?(recipe_path)
81
+ STDERR.puts "No file at #{recipe_path}"
82
+ STDERR.puts banner
83
+ exit 1
84
+ end
85
+ recipe_path = File.expand_path(recipe_path)
86
+ end
87
+
88
+ def run_chef_recipe
89
+ recipe_path = ARGV[0]
90
+ recipe_path = find_recipe recipe_path
91
+ Chef::Config[:solo] = true
92
+ client = Chef::Client.new
93
+ client.run_ohai
94
+ client.build_node
95
+ run_context = if client.events.nil?
96
+ Chef::RunContext.new(client.node, {})
97
+ else
98
+ Chef::RunContext.new(client.node, {}, client.events)
99
+ end
100
+
101
+ recipe = Chef::Recipe.new("(chef-recipe cookbook)", "(chef-recipe recipe)", run_context)
102
+ recipe.from_file(recipe_path)
103
+
104
+ runner = Chef::Runner.new(run_context)
105
+ runner.converge
106
+ end
107
+
108
+ def run_application
109
+ begin
110
+ run_chef_recipe
111
+ Chef::Application.exit! "Exiting", 0
112
+ rescue SystemExit => e
113
+ raise
114
+ rescue Exception => e
115
+ Chef::Application.debug_stacktrace(e)
116
+ Chef::Application.fatal!("#{e.class}: #{e.message}", 1)
117
+ end
118
+ end
119
+
120
+ # Get this party started
121
+ def run
122
+ reconfigure
123
+ run_application
124
+ end
125
+
126
+ end
@@ -0,0 +1,5 @@
1
+ module Chef
2
+ module Recipe
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "chef-recipe/version"
2
+
3
+ module Chef
4
+ module Recipe
5
+ # Your code goes here...
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-recipe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bryan Berry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chef
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec-core
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.8.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.8.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-expectations
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.8.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-mocks
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.8.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
78
+ description: command to execute a single chef recipe
79
+ email:
80
+ - bryan.berry@gmail.com
81
+ executables:
82
+ - chef-recipe
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE
89
+ - README.md
90
+ - Rakefile
91
+ - bin/chef-recipe
92
+ - chef-recipe.gemspec
93
+ - lib/chef-recipe.rb
94
+ - lib/chef-recipe/version.rb
95
+ - lib/chef/application/recipe.rb
96
+ homepage: https://github.com/bryanwb/chef-recipe
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.23
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: This gem installs a command that can be used to execute a single chef recipe
120
+ test_files: []
121
+ has_rdoc: