chef-skel 0.1.0

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,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,215 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chef-skel (0.1.0)
5
+ berkshelf
6
+ chef
7
+ chefspec
8
+ foodcritic
9
+ rake
10
+ serverspec
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activesupport (3.2.13)
16
+ i18n (= 0.6.1)
17
+ multi_json (~> 1.0)
18
+ addressable (2.3.4)
19
+ akami (1.2.0)
20
+ gyoku (>= 0.4.0)
21
+ nokogiri (>= 1.4.0)
22
+ berkshelf (2.0.5)
23
+ activesupport (>= 3.2.0)
24
+ addressable (~> 2.3.4)
25
+ buff-shell_out (~> 0.1)
26
+ celluloid (>= 0.14.0)
27
+ chozo (>= 0.6.1)
28
+ faraday (>= 0.8.5)
29
+ hashie (>= 2.0.2)
30
+ minitar (~> 0.5.4)
31
+ rbzip2 (~> 0.2.0)
32
+ retryable (~> 1.3.3)
33
+ ridley (~> 1.2.1)
34
+ solve (>= 0.5.0)
35
+ thor (~> 0.18.0)
36
+ buff-extensions (0.5.0)
37
+ buff-ruby_engine (0.1.0)
38
+ buff-shell_out (0.1.0)
39
+ buff-ruby_engine (~> 0.1.0)
40
+ builder (3.2.2)
41
+ celluloid (0.14.1)
42
+ timers (>= 1.0.0)
43
+ celluloid-io (0.14.1)
44
+ celluloid (>= 0.14.1)
45
+ nio4r (>= 0.4.5)
46
+ chef (11.4.4)
47
+ erubis
48
+ highline (>= 1.6.9)
49
+ json (>= 1.4.4, <= 1.7.7)
50
+ mixlib-authentication (>= 1.3.0)
51
+ mixlib-cli (~> 1.3.0)
52
+ mixlib-config (>= 1.1.2)
53
+ mixlib-log (>= 1.3.0)
54
+ mixlib-shellout
55
+ net-ssh (~> 2.6)
56
+ net-ssh-multi (~> 1.1.0)
57
+ ohai (>= 0.6.0)
58
+ rest-client (>= 1.0.4, < 1.7.0)
59
+ yajl-ruby (~> 1.1)
60
+ chefspec (1.3.1)
61
+ chef (>= 10.0)
62
+ erubis
63
+ fauxhai (>= 0.1.1, < 2.0)
64
+ minitest-chef-handler (>= 0.6.0)
65
+ rspec (~> 2.0)
66
+ chozo (0.6.1)
67
+ activesupport (>= 3.2.0)
68
+ hashie (>= 2.0.2)
69
+ multi_json (>= 1.3.0)
70
+ ci_reporter (1.8.4)
71
+ builder (>= 2.1.2)
72
+ diff-lcs (1.2.4)
73
+ erubis (2.7.0)
74
+ faraday (0.8.7)
75
+ multipart-post (~> 1.1)
76
+ fauxhai (1.1.1)
77
+ httparty
78
+ net-ssh
79
+ ohai
80
+ ffi (1.9.0)
81
+ foodcritic (2.1.0)
82
+ erubis
83
+ gherkin (~> 2.11.7)
84
+ nokogiri (~> 1.5.4)
85
+ rak (~> 1.4)
86
+ treetop (~> 1.4.10)
87
+ yajl-ruby (~> 1.1.0)
88
+ gherkin (2.11.8)
89
+ multi_json (~> 1.3)
90
+ gssapi (1.0.3)
91
+ ffi (>= 1.0.1)
92
+ gyoku (1.0.0)
93
+ builder (>= 2.1.2)
94
+ hashie (2.0.5)
95
+ highline (1.6.19)
96
+ httparty (0.11.0)
97
+ multi_json (~> 1.0)
98
+ multi_xml (>= 0.5.2)
99
+ httpclient (2.2.0.2)
100
+ httpi (0.9.7)
101
+ rack
102
+ i18n (0.6.1)
103
+ ipaddress (0.8.0)
104
+ json (1.7.7)
105
+ little-plugger (1.1.3)
106
+ logging (1.6.2)
107
+ little-plugger (>= 1.1.3)
108
+ mime-types (1.23)
109
+ minitar (0.5.4)
110
+ minitest (4.7.5)
111
+ minitest-chef-handler (1.0.1)
112
+ chef
113
+ ci_reporter
114
+ minitest (~> 4.7.3)
115
+ mixlib-authentication (1.3.0)
116
+ mixlib-log
117
+ mixlib-cli (1.3.0)
118
+ mixlib-config (1.1.2)
119
+ mixlib-log (1.6.0)
120
+ mixlib-shellout (1.1.0)
121
+ multi_json (1.7.7)
122
+ multi_xml (0.5.4)
123
+ multipart-post (1.2.0)
124
+ net-http-persistent (2.8)
125
+ net-ssh (2.6.7)
126
+ net-ssh-gateway (1.2.0)
127
+ net-ssh (>= 2.6.5)
128
+ net-ssh-multi (1.1)
129
+ net-ssh (>= 2.1.4)
130
+ net-ssh-gateway (>= 0.99.0)
131
+ nio4r (0.4.6)
132
+ nokogiri (1.5.10)
133
+ nori (1.1.5)
134
+ ohai (6.16.0)
135
+ ipaddress
136
+ mixlib-cli
137
+ mixlib-config
138
+ mixlib-log
139
+ mixlib-shellout
140
+ systemu
141
+ yajl-ruby
142
+ polyglot (0.3.3)
143
+ rack (1.5.2)
144
+ rak (1.4)
145
+ rake (10.1.0)
146
+ rbzip2 (0.2.0)
147
+ rest-client (1.6.7)
148
+ mime-types (>= 1.16)
149
+ retryable (1.3.3)
150
+ ridley (1.2.3)
151
+ addressable
152
+ buff-extensions (~> 0.3)
153
+ buff-shell_out (~> 0.1)
154
+ celluloid (~> 0.14.0)
155
+ celluloid-io (~> 0.14.0)
156
+ erubis
157
+ faraday (>= 0.8.4)
158
+ hashie (>= 2.0.2)
159
+ json (>= 1.7.7)
160
+ mixlib-authentication (>= 1.3.0)
161
+ net-http-persistent (>= 2.8)
162
+ net-ssh
163
+ retryable
164
+ solve (>= 0.4.4)
165
+ varia_model (~> 0.1)
166
+ winrm (~> 1.1.0)
167
+ rspec (2.13.0)
168
+ rspec-core (~> 2.13.0)
169
+ rspec-expectations (~> 2.13.0)
170
+ rspec-mocks (~> 2.13.0)
171
+ rspec-core (2.13.1)
172
+ rspec-expectations (2.13.0)
173
+ diff-lcs (>= 1.1.3, < 2.0)
174
+ rspec-mocks (2.13.1)
175
+ rubyntlm (0.1.1)
176
+ savon (0.9.5)
177
+ akami (~> 1.0)
178
+ builder (>= 2.1.2)
179
+ gyoku (>= 0.4.0)
180
+ httpi (~> 0.9)
181
+ nokogiri (>= 1.4.0)
182
+ nori (~> 1.0)
183
+ wasabi (~> 1.0)
184
+ serverspec (0.6.7)
185
+ highline
186
+ net-ssh
187
+ rspec (~> 2.13.0)
188
+ solve (0.5.0)
189
+ systemu (2.5.2)
190
+ thor (0.18.1)
191
+ timers (1.1.0)
192
+ treetop (1.4.14)
193
+ polyglot
194
+ polyglot (>= 0.3.1)
195
+ uuidtools (2.1.4)
196
+ varia_model (0.1.0)
197
+ buff-extensions (~> 0.1)
198
+ hashie (>= 2.0.2)
199
+ wasabi (1.0.0)
200
+ nokogiri (>= 1.4.0)
201
+ winrm (1.1.2)
202
+ gssapi (~> 1.0.0)
203
+ httpclient (~> 2.2.0.2)
204
+ logging (~> 1.6.1)
205
+ nokogiri (~> 1.5.0)
206
+ rubyntlm (~> 0.1.1)
207
+ savon (= 0.9.5)
208
+ uuidtools (~> 2.1.2)
209
+ yajl-ruby (1.1.0)
210
+
211
+ PLATFORMS
212
+ ruby
213
+
214
+ DEPENDENCIES
215
+ chef-skel!
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/clean'
3
+
4
+ task :default => :build
5
+
6
+ CLEAN.include 'pkg'
data/chef-skel.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/chef_skel/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.authors = ['Mathias Lafeldt']
6
+ s.email = ['mathias.lafeldt@gmail.com']
7
+ s.description = %q{Chef skeleton}
8
+ s.summary = s.description
9
+ s.homepage = 'http://mlafeldt.github.com/chef-skel'
10
+ s.license = 'MIT'
11
+
12
+ s.files = `git ls-files`.split($\)
13
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+ s.name = 'chef-skel'
16
+ s.require_paths = ['lib']
17
+ s.version = ChefSkel::VERSION
18
+
19
+ s.add_dependency 'berkshelf'
20
+ s.add_dependency 'chef'
21
+ s.add_dependency 'chefspec'
22
+ s.add_dependency 'foodcritic'
23
+ s.add_dependency 'rake'
24
+ s.add_dependency 'serverspec'
25
+ end
@@ -0,0 +1,45 @@
1
+ require 'serverspec'
2
+ require 'pathname'
3
+ require 'net/ssh'
4
+
5
+ include Serverspec::Helper::Ssh
6
+ include Serverspec::Helper::DetectOS
7
+
8
+ SERVERSPEC_CONFIG_ROOT = ENV.fetch('SERVERSPEC_CONFIG_ROOT', '.vagrant/machines')
9
+
10
+ # Ask Vagrant for SSH config of host
11
+ def ssh_config_for_host(host)
12
+ config_file = File.join(SERVERSPEC_CONFIG_ROOT, host, 'ssh_config')
13
+ # TODO: find a way to cache results
14
+ ssh_config = `vagrant ssh-config #{host} --host #{host}`
15
+ File.open(config_file, 'w') { |file| file.write(ssh_config) }
16
+ config_file
17
+ end
18
+
19
+ RSpec.configure do |c|
20
+ if ENV['ASK_SUDO_PASSWORD']
21
+ require 'highline/import'
22
+ c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
23
+ else
24
+ c.sudo_password = ENV['SUDO_PASSWORD']
25
+ end
26
+ c.before :all do
27
+ block = self.class.metadata[:example_group_block]
28
+ if RUBY_VERSION.start_with?('1.8')
29
+ file = block.to_s.match(/.*@(.*):[0-9]+>/)[1]
30
+ else
31
+ file = block.source_location.first
32
+ end
33
+ dirname = Pathname.new(file).dirname
34
+ host = File.basename(dirname)
35
+ if c.host != host
36
+ c.ssh.close if c.ssh
37
+ c.host = host
38
+ config_file = ssh_config_for_host(host)
39
+ options = Net::SSH::Config.for(c.host, files=[config_file])
40
+ user = options[:user] || Etc.getlogin
41
+ c.ssh = Net::SSH.start(c.host, user, options)
42
+ c.os = backend(Serverspec::Commands::Base).check_os
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,148 @@
1
+ #
2
+ # Rake tasks to test your cookbook
3
+ #
4
+ # Copyright (C) 2012-2013 Mathias Lafeldt <mathias.lafeldt@gmail.com>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'rake'
20
+ require 'rake/clean'
21
+ require 'rspec/core/rake_task'
22
+ require 'chef/cookbook/metadata'
23
+
24
+ def cookbook_metadata
25
+ metadata = Chef::Cookbook::Metadata.new
26
+ metadata.from_file 'metadata.rb'
27
+ metadata
28
+ end
29
+
30
+ def cookbook_name
31
+ name = cookbook_metadata.name
32
+ if name.nil? || name.empty?
33
+ File.basename(File.dirname(__FILE__))
34
+ else
35
+ name
36
+ end
37
+ end
38
+
39
+ COOKBOOK_NAME = ENV.fetch('COOKBOOK_NAME', cookbook_name)
40
+ COOKBOOK_PATH = ENV.fetch('COOKBOOK_PATH', 'vendor/cookbooks')
41
+
42
+ CLOBBER.include COOKBOOK_PATH, 'Berksfile.lock', '.kitchen', '.vagrant'
43
+
44
+ desc 'Display information about the environment'
45
+ task :env do
46
+ {
47
+ :ruby => 'ruby --version',
48
+ :rubygems => 'gem --version',
49
+ :bundler => 'bundle --version',
50
+ :vagrant => 'vagrant --version',
51
+ :vagrant_berkshelf => 'vagrant plugin list 2>/dev/null | grep berkshelf',
52
+ :virtualbox => 'VBoxManage --version'
53
+ }.each do |key, cmd|
54
+ begin
55
+ result = `#{cmd}`.chomp
56
+ rescue Errno::ENOENT
57
+ result = 'not found'
58
+ end
59
+ puts " * #{key}: #{result}"
60
+ end
61
+ end
62
+
63
+ namespace :test do
64
+ task :prepare do
65
+ ENV['COOKBOOK_PATH'] = COOKBOOK_PATH
66
+ sh 'berks', 'install', '--path', COOKBOOK_PATH
67
+ # Run cleanup at exit unless an exception was raised.
68
+ at_exit { Rake::Task['test:cleanup'].invoke if $!.nil? }
69
+ end
70
+
71
+ task :cleanup do
72
+ rm_rf COOKBOOK_PATH
73
+ end
74
+
75
+ desc 'Run Knife syntax checks'
76
+ task :syntax => :prepare do
77
+ sh 'knife', 'cookbook', 'test', COOKBOOK_NAME, '--config', '.knife.rb',
78
+ '--cookbook-path', COOKBOOK_PATH
79
+ end
80
+
81
+ desc 'Run Foodcritic lint checks'
82
+ task :lint => :prepare do
83
+ # TODO: FoodCritic::Rake::LintTask is still experimental
84
+ sh 'foodcritic', '--epic-fail', 'any',
85
+ File.join(COOKBOOK_PATH, COOKBOOK_NAME)
86
+ end
87
+
88
+ desc 'Run ChefSpec examples'
89
+ RSpec::Core::RakeTask.new(:unit) do |t|
90
+ t.pattern = 'spec/unit/*_spec.rb'
91
+ t.rspec_opts = '--color --format documentation'
92
+ end
93
+ task :unit => :prepare
94
+
95
+ desc 'Run serverspec integration tests with Vagrant'
96
+ RSpec::Core::RakeTask.new(:integration) do |t|
97
+ t.pattern = 'spec/integration/**/*_spec.rb'
98
+ t.rspec_opts = '--color --format documentation'
99
+ end
100
+ task :integration => 'vagrant:provision'
101
+
102
+ desc 'Tear down VM used for integration tests'
103
+ task :integration_teardown do
104
+ # Shut VM down unless INTEGRATION_TEARDOWN is set to a different task.
105
+ Rake::Task[ENV.fetch('INTEGRATION_TEARDOWN', 'vagrant:halt')].invoke
106
+ end
107
+
108
+ desc 'Run test:syntax, test:lint, and test:unit'
109
+ task :travis => [:syntax, :lint, :unit]
110
+
111
+ desc 'Run test:syntax, test:lint, test:unit, and test:integration'
112
+ task :all => [:syntax, :lint, :unit, :integration, :integration_teardown]
113
+ end
114
+
115
+ namespace :vagrant do
116
+ desc 'Provision the VM using Chef'
117
+ task :provision do
118
+ # Provision VM depending on its state.
119
+ case `vagrant status`
120
+ when /The VM is running/ then ['provision']
121
+ when /To resume this VM/ then ['up', 'provision']
122
+ else ['up']
123
+ end.each { |cmd| sh 'vagrant', cmd }
124
+ end
125
+
126
+ desc 'SSH into the VM'
127
+ task :ssh do
128
+ sh 'vagrant', 'ssh'
129
+ end
130
+
131
+ desc 'Shutdown the VM'
132
+ task :halt do
133
+ sh 'vagrant', 'halt', '--force'
134
+ end
135
+
136
+ desc 'Destroy the VM'
137
+ task :destroy do
138
+ sh 'vagrant', 'destroy', '--force'
139
+ Rake::Task['test:cleanup'].invoke
140
+ end
141
+ end
142
+
143
+ # Aliases for backwards compatibility and convenience
144
+ task :lint => 'test:lint'
145
+ task :spec => 'test:unit'
146
+ task :test => 'test:all'
147
+
148
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ require 'chefspec'
2
+
3
+ COOKBOOK_PATH = ENV.fetch('COOKBOOK_PATH', 'vendor/cookbooks')
@@ -0,0 +1,3 @@
1
+ module ChefSkel
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-skel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mathias Lafeldt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: berkshelf
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: chef
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: chefspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: foodcritic
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: serverspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Chef skeleton
111
+ email:
112
+ - mathias.lafeldt@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - Gemfile.lock
120
+ - Rakefile
121
+ - chef-skel.gemspec
122
+ - lib/chef_skel/integration_spec_helper.rb
123
+ - lib/chef_skel/rake_tasks.rb
124
+ - lib/chef_skel/unit_spec_helper.rb
125
+ - lib/chef_skel/version.rb
126
+ homepage: http://mlafeldt.github.com/chef-skel
127
+ licenses:
128
+ - MIT
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ segments:
140
+ - 0
141
+ hash: -3464971780163873864
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ segments:
149
+ - 0
150
+ hash: -3464971780163873864
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 1.8.25
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: Chef skeleton
157
+ test_files: []