vagrant-serverspec 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 +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +56 -0
- data/LICENSE +21 -0
- data/README.md +65 -0
- data/Rakefile +5 -0
- data/lib/vagrant-serverspec.rb +13 -0
- data/lib/vagrant-serverspec/config.rb +35 -0
- data/lib/vagrant-serverspec/plugin.rb +20 -0
- data/lib/vagrant-serverspec/provisioner.rb +37 -0
- data/lib/vagrant-serverspec/version.rb +5 -0
- data/locales/en.yml +9 -0
- data/test/Vagrantfile +15 -0
- data/test/example_spec.rb +14 -0
- data/test/spec_helper.rb +6 -0
- data/vagrant-serverspec.gemspec +22 -0
- metadata +113 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.vagrant
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/mitchellh/vagrant
|
3
|
+
revision: e9184ed6f9b89d68fc4d253b6913d68a05c677ef
|
4
|
+
specs:
|
5
|
+
vagrant (1.4.0.dev)
|
6
|
+
childprocess (~> 0.3.7)
|
7
|
+
erubis (~> 2.7.0)
|
8
|
+
i18n (~> 0.6.0)
|
9
|
+
log4r (~> 1.1.9)
|
10
|
+
net-scp (~> 1.1.0)
|
11
|
+
net-ssh (~> 2.6.6)
|
12
|
+
|
13
|
+
PATH
|
14
|
+
remote: .
|
15
|
+
specs:
|
16
|
+
vagrant-serverspec (0.0.1)
|
17
|
+
serverspec (~> 0.12.0)
|
18
|
+
|
19
|
+
GEM
|
20
|
+
remote: https://rubygems.org/
|
21
|
+
specs:
|
22
|
+
childprocess (0.3.9)
|
23
|
+
ffi (~> 1.0, >= 1.0.11)
|
24
|
+
diff-lcs (1.2.5)
|
25
|
+
erubis (2.7.0)
|
26
|
+
ffi (1.9.3)
|
27
|
+
highline (1.6.20)
|
28
|
+
i18n (0.6.5)
|
29
|
+
log4r (1.1.10)
|
30
|
+
net-scp (1.1.2)
|
31
|
+
net-ssh (>= 2.6.5)
|
32
|
+
net-ssh (2.6.8)
|
33
|
+
rake (10.1.0)
|
34
|
+
rspec (2.14.1)
|
35
|
+
rspec-core (~> 2.14.0)
|
36
|
+
rspec-expectations (~> 2.14.0)
|
37
|
+
rspec-mocks (~> 2.14.0)
|
38
|
+
rspec-core (2.14.7)
|
39
|
+
rspec-expectations (2.14.4)
|
40
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
41
|
+
rspec-mocks (2.14.4)
|
42
|
+
serverspec (0.12.0)
|
43
|
+
highline
|
44
|
+
net-ssh
|
45
|
+
rspec (>= 2.13.0)
|
46
|
+
specinfra (>= 0.0.2)
|
47
|
+
specinfra (0.0.4)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 1.3)
|
54
|
+
rake
|
55
|
+
vagrant!
|
56
|
+
vagrant-serverspec!
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Jeremy Voorhis
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# vagrant-serverspec
|
2
|
+
|
3
|
+
vagrant-serverspec is a [vagrant](http://vagrantup.com) plugin that implements
|
4
|
+
[serverspec](http://serverspec.org) as a provisioner.
|
5
|
+
|
6
|
+
Issues and pull requests are welcome.
|
7
|
+
|
8
|
+
## Example Usage
|
9
|
+
|
10
|
+
First, you'll need to load the plugin and configure the provisioner.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
Vagrant.require_plugin('vagrant-serverspec')
|
14
|
+
|
15
|
+
Vagrant.configure('2') do |config|
|
16
|
+
config.vm.box = 'precise64'
|
17
|
+
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'
|
18
|
+
|
19
|
+
config.vm.provision :shell, inline: <<-EOF
|
20
|
+
sudo ufw allow 22
|
21
|
+
yes | sudo ufw enable
|
22
|
+
EOF
|
23
|
+
|
24
|
+
config.vm.provision :serverspec do |spec|
|
25
|
+
spec.pattern = '*_spec.rb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
You'll want to place some boilerplate into a file named `spec_helper.rb`
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'serverspec'
|
34
|
+
require 'pathname'
|
35
|
+
require 'net/ssh'
|
36
|
+
|
37
|
+
include SpecInfra::Helper::Ssh
|
38
|
+
include SpecInfra::Helper::DetectOS
|
39
|
+
```
|
40
|
+
|
41
|
+
Then you're ready to write your specs.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require_relative 'spec_helper'
|
45
|
+
|
46
|
+
describe package('ufw') do
|
47
|
+
it { should be_installed }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe service('ufw') do
|
51
|
+
it { should be_enabled }
|
52
|
+
it { should be_running }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe port(22) do
|
56
|
+
it { should be_listening }
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## TODO
|
61
|
+
|
62
|
+
- Gem release
|
63
|
+
- Documentation
|
64
|
+
- Fork a child process to sandbox RSpec execution
|
65
|
+
- Integrate RSpec's error reporting with Vagrant's UI api
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vagrant-serverspec/plugin'
|
2
|
+
require 'vagrant-serverspec/version'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ServerSpec
|
6
|
+
def self.source_root
|
7
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
8
|
+
end
|
9
|
+
|
10
|
+
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
11
|
+
I18n.reload!
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ServerSpec
|
3
|
+
class Config < Vagrant.plugin('2', :config)
|
4
|
+
attr_accessor :spec_files
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@spec_files = UNSET_VALUE
|
9
|
+
end
|
10
|
+
|
11
|
+
def pattern=(pat)
|
12
|
+
@spec_files = Dir.glob(pat)
|
13
|
+
end
|
14
|
+
|
15
|
+
def finalize!
|
16
|
+
@spec_files = [] if @spec_files == UNSET_VALUE
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate(machine)
|
20
|
+
errors = _detected_errors
|
21
|
+
|
22
|
+
if @spec_files.nil? || @spec_files.empty?
|
23
|
+
errors << I18n.t('vagrant.config.serverspec.no_spec_files')
|
24
|
+
end
|
25
|
+
|
26
|
+
missing_files = @spec_files.select { |path| !File.file?(path) }
|
27
|
+
unless missing_files.empty?
|
28
|
+
errors << I18n.t('vagrant.config.serverspec.missing_spec_files', files: missing_files.join(', '))
|
29
|
+
end
|
30
|
+
|
31
|
+
{ 'serverspec provisioner' => errors }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ServerSpec
|
3
|
+
class Plugin < Vagrant.plugin('2')
|
4
|
+
name 'serverspec'
|
5
|
+
description <<-DESC
|
6
|
+
This plugin executes a serverspec suite against a running Vagrant instance.
|
7
|
+
DESC
|
8
|
+
|
9
|
+
config(:serverspec, :provisioner) do
|
10
|
+
require_relative 'config'
|
11
|
+
Config
|
12
|
+
end
|
13
|
+
|
14
|
+
provisioner(:serverspec) do
|
15
|
+
require_relative 'provisioner'
|
16
|
+
Provisioner
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'serverspec'
|
2
|
+
|
3
|
+
# This implementation executes rspec in-process. Because rspec effectively
|
4
|
+
# takes ownership of the global scope, executing rspec within a child process
|
5
|
+
# may be preferred.
|
6
|
+
module VagrantPlugins
|
7
|
+
module ServerSpec
|
8
|
+
class Provisioner < Vagrant.plugin('2', :provisioner)
|
9
|
+
def initialize(machine, config)
|
10
|
+
super(machine, config)
|
11
|
+
|
12
|
+
@spec_files = config.spec_files
|
13
|
+
|
14
|
+
RSpec.configure do |spec|
|
15
|
+
spec.before :all do
|
16
|
+
ssh_host = machine.ssh_info[:host]
|
17
|
+
ssh_username = machine.ssh_info[:username]
|
18
|
+
ssh_opts = Net::SSH::Config.for(machine.ssh_info[:host])
|
19
|
+
ssh_opts[:port] = machine.ssh_info[:port]
|
20
|
+
ssh_opts[:forward_agent] = machine.ssh_info[:forward_agent]
|
21
|
+
ssh_opts[:keys] = machine.ssh_info[:private_key_path]
|
22
|
+
|
23
|
+
spec.ssh = Net::SSH.start(ssh_host, ssh_username, ssh_opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.after :all do
|
27
|
+
spec.ssh.close if spec.ssh && !spec.ssh.closed?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def provision
|
33
|
+
RSpec::Core::Runner.run(@spec_files)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/locales/en.yml
ADDED
data/test/Vagrantfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Vagrant.require_plugin('vagrant-serverspec')
|
2
|
+
|
3
|
+
Vagrant.configure('2') do |config|
|
4
|
+
config.vm.box = 'precise64'
|
5
|
+
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'
|
6
|
+
|
7
|
+
config.vm.provision :shell, inline: <<-EOF
|
8
|
+
sudo ufw allow 22
|
9
|
+
yes | sudo ufw enable
|
10
|
+
EOF
|
11
|
+
|
12
|
+
config.vm.provision :serverspec do |spec|
|
13
|
+
spec.pattern = '*_spec.rb'
|
14
|
+
end
|
15
|
+
end
|
data/test/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'vagrant-serverspec/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'vagrant-serverspec'
|
7
|
+
gem.version = VagrantPlugins::ServerSpec::VERSION
|
8
|
+
gem.authors = ['Jeremy Voorhis']
|
9
|
+
gem.email = ['jvoorhis@gmail.com']
|
10
|
+
gem.description = %q{A Vagrant provisioner that executes serverspec}
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.license = 'MIT'
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_dependency 'serverspec', '~> 0.12.0'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-serverspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeremy Voorhis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: serverspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.12.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.12.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
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: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '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: '0'
|
62
|
+
description: A Vagrant provisioner that executes serverspec
|
63
|
+
email:
|
64
|
+
- jvoorhis@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/vagrant-serverspec.rb
|
76
|
+
- lib/vagrant-serverspec/config.rb
|
77
|
+
- lib/vagrant-serverspec/plugin.rb
|
78
|
+
- lib/vagrant-serverspec/provisioner.rb
|
79
|
+
- lib/vagrant-serverspec/version.rb
|
80
|
+
- locales/en.yml
|
81
|
+
- test/Vagrantfile
|
82
|
+
- test/example_spec.rb
|
83
|
+
- test/spec_helper.rb
|
84
|
+
- vagrant-serverspec.gemspec
|
85
|
+
homepage:
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.23
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: A Vagrant provisioner that executes serverspec
|
110
|
+
test_files:
|
111
|
+
- test/Vagrantfile
|
112
|
+
- test/example_spec.rb
|
113
|
+
- test/spec_helper.rb
|