vagrant-serverspechtmlreport 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +143 -0
- data/Rakefile +5 -0
- data/WINDOWS_README.md +109 -0
- data/lib/vagrant-serverspechtmlreport.rb +14 -0
- data/lib/vagrant-serverspechtmlreport/config.rb +35 -0
- data/lib/vagrant-serverspechtmlreport/error.rb +7 -0
- data/lib/vagrant-serverspechtmlreport/plugin.rb +27 -0
- data/lib/vagrant-serverspechtmlreport/provisioner.rb +110 -0
- data/lib/vagrant-serverspechtmlreport/version.rb +5 -0
- data/locales/en.yml +13 -0
- data/test/Docker/.rspec +2 -0
- data/test/Docker/Docker_Vagrantfile +13 -0
- data/test/Docker/Vagrantfile +17 -0
- data/test/Docker/sample_spec.rb +9 -0
- data/test/Docker/spec_helper.rb +13 -0
- data/test/ubuntu/.rspec +2 -0
- data/test/ubuntu/Vagrantfile +14 -0
- data/test/ubuntu/sample_spec.rb +14 -0
- data/test/ubuntu/spec_helper.rb +13 -0
- data/test/windows/.rspec +2 -0
- data/test/windows/sample_spec.rb +36 -0
- data/test/windows/spec_helper.rb +13 -0
- data/test/windows/vagrantfile +58 -0
- data/vagrant-serverspechtmlreport.gemspec +26 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a735bd595a7e3801d86b16335ac286d21a1881eb
|
4
|
+
data.tar.gz: accca6922d9a11463aee6e323cfee7e3a5d68c40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4726820549008403af6c9069b5f35671eca5aef0584382a2908ffdaa30474c8b77b4497212980ef3153cd23012bb23364e5df63983ce0f4a1f77fbf2aabf336e
|
7
|
+
data.tar.gz: ec5abb3792e0c730b08708ef6df291573d2f546b5476b2612b35474c7309450895f14e757a9b96f9a295f759b9d8f97cab7f1fe5c3b6e4b6285c03a9940a07ca
|
data/Gemfile
ADDED
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,143 @@
|
|
1
|
+
# vagrant-serverspec
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/vagrant-serverspec.svg)](http://badge.fury.io/rb/vagrant-serverspec)
|
3
|
+
|
4
|
+
> **vagrant-serverspec is a [vagrant][vagrant] plugin that implements
|
5
|
+
> [serverspec][serverspec] as a provisioner.**
|
6
|
+
|
7
|
+
## Installing
|
8
|
+
### Standard way
|
9
|
+
First, install the plugin.
|
10
|
+
|
11
|
+
```shell
|
12
|
+
$ vagrant plugin install vagrant-serverspec
|
13
|
+
```
|
14
|
+
### In case of fork usage
|
15
|
+
in case of fork usage you need to build it first
|
16
|
+
```shell
|
17
|
+
gem build vagrant-serverspec.gemspec
|
18
|
+
```
|
19
|
+
(on windows you may use embedded vagrant ruby for that)
|
20
|
+
```shell
|
21
|
+
C:\HashiCorp\Vagrant\embedded\bin\gem.bat build vagrant-serverspec.gemspec
|
22
|
+
```
|
23
|
+
after that install plugin from filesystem
|
24
|
+
```shell
|
25
|
+
vagrant plugin install ./vagrant-serverspec-0.5.0.gem
|
26
|
+
```
|
27
|
+
|
28
|
+
## Example Usage
|
29
|
+
|
30
|
+
Next, configure the provisioner in your `Vagrantfile`.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Vagrant.configure('2') do |config|
|
34
|
+
config.vm.box = 'precise64'
|
35
|
+
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'
|
36
|
+
|
37
|
+
config.vm.provision :shell, inline: <<-EOF
|
38
|
+
sudo ufw allow 22
|
39
|
+
yes | sudo ufw enable
|
40
|
+
EOF
|
41
|
+
|
42
|
+
config.vm.provision :serverspec do |spec|
|
43
|
+
spec.pattern = '*_spec.rb'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
You may want to override standard settings; a file named `spec_helper.rb` is usually used for that. Here are some examples of possible overrides.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
# Disable sudo
|
52
|
+
# set :disable_sudo, true
|
53
|
+
|
54
|
+
# Set environment variables
|
55
|
+
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
|
56
|
+
|
57
|
+
# Set PATH
|
58
|
+
# set :path, '/sbin:/usr/local/sbin:$PATH'
|
59
|
+
```
|
60
|
+
|
61
|
+
Then you're ready to write your specs.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require_relative 'spec_helper'
|
65
|
+
|
66
|
+
describe package('ufw') do
|
67
|
+
it { should be_installed }
|
68
|
+
end
|
69
|
+
|
70
|
+
describe service('ufw') do
|
71
|
+
it { should be_enabled }
|
72
|
+
it { should be_running }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe port(22) do
|
76
|
+
it { should be_listening }
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
##Testing Docker Containers on OSX
|
81
|
+
On OSX the Vagrant docker provider runs a Boot2Docker VM, then launches your docker container on that VM. Vagrant does SSH Proxying to send the commands through that VM and have them reach the Docker Container. Vagrant serverspec handles this the same way by getting the container host VM infromation and proxying the commands to the machine through an SSH Proxy. This functionality was introduced in this [PR](https://github.com/jvoorhis/vagrant-serverspec/pull/17)
|
82
|
+
|
83
|
+
## Additional informations
|
84
|
+
|
85
|
+
### SSH connections
|
86
|
+
|
87
|
+
SSH connection is closed before each provision run.
|
88
|
+
This is mandatory if the provision is applied to multiple vms in the same run,
|
89
|
+
else all runs will be applied to the first vm (See #22) due to an SSH
|
90
|
+
connection which already exists.
|
91
|
+
This functionality was introduced in this [PR](https://github.com/jvoorhis/vagrant-serverspec/pull/23)
|
92
|
+
|
93
|
+
### Server spec examples
|
94
|
+
|
95
|
+
RSpec examples are clear before each provision run.
|
96
|
+
This is mandatory if the provision is applied to multiple vms in the same run,
|
97
|
+
else each run replay examples of previous calls also.
|
98
|
+
This functionality was introduced in this [PR](https://github.com/jvoorhis/vagrant-serverspec/pull/23)
|
99
|
+
|
100
|
+
### In case of shared examples
|
101
|
+
|
102
|
+
If you use shared examples into your test suite, you need to use 'load' instead
|
103
|
+
of 'require', else errors can occurs (See #23 comments).
|
104
|
+
|
105
|
+
## Versioning
|
106
|
+
|
107
|
+
vagrant-serverspec aims to adhere to [Semantic Versioning 2.0.0][semver].
|
108
|
+
|
109
|
+
## Development
|
110
|
+
|
111
|
+
* Source hosted at [GitHub][repo]
|
112
|
+
* Report issues/questions/feature requests on [GitHub Issues][issues]
|
113
|
+
|
114
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
115
|
+
Ideally create a topic branch for every separate change you make. For
|
116
|
+
example:
|
117
|
+
|
118
|
+
1. Fork the repo
|
119
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
120
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
121
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
122
|
+
5. Create new Pull Request
|
123
|
+
|
124
|
+
## Authors
|
125
|
+
|
126
|
+
Created and maintained by [Jeremy Voorhis][jvoorhis] (<jvoorhis@gmail.com>) and
|
127
|
+
a growing community of [contributors][contributors].
|
128
|
+
|
129
|
+
## License
|
130
|
+
|
131
|
+
MIT license (see [LICENSE][license])
|
132
|
+
|
133
|
+
[vagrant]: http://vagrantup.com
|
134
|
+
[serverspec]: http://serverspec.org
|
135
|
+
[semver]: http://semver.org/
|
136
|
+
|
137
|
+
[repo]: https://github.com/jvoorhis/vagrant-serverspec
|
138
|
+
[issues]: https://github.com/jvoorhis/vagrant-serverspec/issues
|
139
|
+
|
140
|
+
[jvoorhis]: https://github.com/jvoorhis
|
141
|
+
[contributors]: https://github.com/jvoorhis/vagrant-serverspec/graphs/contributors
|
142
|
+
|
143
|
+
[license]: https://github.com/jvoorhis/vagrant-serverspec/blob/master/LICENSE
|
data/Rakefile
ADDED
data/WINDOWS_README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# vagrant-serverspec Windows readme
|
2
|
+
|
3
|
+
vagrant-serverspec is a [vagrant](http://vagrantup.com) plugin that implements
|
4
|
+
[serverspec](http://serverspec.org) as a provisioner.
|
5
|
+
|
6
|
+
It now supports Windows guests through WinRM.
|
7
|
+
|
8
|
+
## Installing
|
9
|
+
|
10
|
+
First, you'll need to install the plugin as described in README.md
|
11
|
+
|
12
|
+
## Example Usage
|
13
|
+
|
14
|
+
Next, configure the provisioner in your `Vagrantfile`.
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
Vagrant.require_version ">= 1.6.2"
|
18
|
+
|
19
|
+
Vagrant.configure("2") do |config|
|
20
|
+
config.vm.define "windows"
|
21
|
+
config.vm.box = "windows"
|
22
|
+
config.vm.communicator = "winrm"
|
23
|
+
|
24
|
+
# Admin user name and password
|
25
|
+
config.winrm.username = "vagrant"
|
26
|
+
config.winrm.password = "vagrant"
|
27
|
+
|
28
|
+
config.vm.guest = :windows
|
29
|
+
config.vm.communicator = "winrm"
|
30
|
+
config.windows.halt_timeout = 15
|
31
|
+
|
32
|
+
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
|
33
|
+
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
|
34
|
+
|
35
|
+
config.vm.provision :serverspec do |spec|
|
36
|
+
spec.pattern = '*_spec.rb'
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
You may want to override standart settings, file named `spec_helper.rb` usually used for that.
|
43
|
+
For now possible examples is commented in this file.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
#require 'serverspec'
|
47
|
+
#require 'pathname'
|
48
|
+
#require 'winrm'
|
49
|
+
#set :backend, :winrm
|
50
|
+
#set :os, :family => 'windows'
|
51
|
+
|
52
|
+
#user = 'vagrant'
|
53
|
+
#pass = 'vagrant'
|
54
|
+
#endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
|
55
|
+
#winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
|
56
|
+
#winrm.set_timeout 300 # 5 minutes max timeout for any operation
|
57
|
+
#Specinfra.configuration.winrm = winrm
|
58
|
+
```
|
59
|
+
|
60
|
+
Then you're ready to write your specs (some examples below).
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
require_relative 'spec_helper'
|
64
|
+
|
65
|
+
describe command('Get-ExecutionPolicy') do
|
66
|
+
its(:stdout) { should match /RemoteSigned/ }
|
67
|
+
#its(:stderr) { should match /stderr/ }
|
68
|
+
its(:exit_status) { should eq 0 }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe user('vagrant') do
|
72
|
+
it { should exist }
|
73
|
+
it { should belong_to_group('Administrators')}
|
74
|
+
end
|
75
|
+
|
76
|
+
describe port(5985) do
|
77
|
+
it { should be_listening }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe file('c:/windows') do
|
81
|
+
it { should be_directory }
|
82
|
+
it { should_not be_writable.by('Everyone') }
|
83
|
+
end
|
84
|
+
|
85
|
+
#describe windows_feature('Web-Server') do
|
86
|
+
# it{ should be_installed.by("powershell") }
|
87
|
+
#end
|
88
|
+
|
89
|
+
#describe port(80) do
|
90
|
+
# it { should be_listening }
|
91
|
+
#end
|
92
|
+
|
93
|
+
#describe iis_website('Default Website') do
|
94
|
+
# it{ should have_site_bindings(80) }
|
95
|
+
#end
|
96
|
+
|
97
|
+
#describe windows_registry_key(
|
98
|
+
# 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\advanced') do
|
99
|
+
# it { should have_property_value('Hidden', :type_dword,'1') }
|
100
|
+
#end
|
101
|
+
|
102
|
+
#describe windows_feature('TelnetClient') do
|
103
|
+
# it{ should be_installed.by("powershell") }
|
104
|
+
#end
|
105
|
+
|
106
|
+
#describe file('C:\Windows\system32\telnet.exe') do
|
107
|
+
# it { should be_file }
|
108
|
+
#end
|
109
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'vagrant-serverspechtmlreport/plugin'
|
2
|
+
require 'vagrant-serverspechtmlreport/version'
|
3
|
+
require 'vagrant-serverspechtmlreport/error'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module ServerSpec
|
7
|
+
def self.source_root
|
8
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
9
|
+
end
|
10
|
+
|
11
|
+
I18n.load_path << File.expand_path('locales/en.yml', source_root)
|
12
|
+
I18n.reload!
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ServerSpecHtmlReport
|
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
|
+
{ 'serverspechtml provisioner' => errors }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'serverspec'
|
3
|
+
require 'pathname'
|
4
|
+
require 'winrm'
|
5
|
+
require 'net/ssh'
|
6
|
+
require 'net/ssh/proxy/command'
|
7
|
+
require 'os'
|
8
|
+
module VagrantPlugins
|
9
|
+
module ServerSpecvHtmlReport
|
10
|
+
class Plugin < Vagrant.plugin('2')
|
11
|
+
name 'serverspechtmlreport'
|
12
|
+
description <<-DESC
|
13
|
+
This plugin executes a serverspec suite against a running Vagrant instance.
|
14
|
+
DESC
|
15
|
+
|
16
|
+
config(:serverspechtmlreport, :provisioner) do
|
17
|
+
require_relative 'config'
|
18
|
+
Config
|
19
|
+
end
|
20
|
+
|
21
|
+
provisioner(:serverspechtmlreport) do
|
22
|
+
require_relative 'provisioner'
|
23
|
+
Provisioner
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# This implementation executes rspec in-process. Because rspec effectively
|
2
|
+
# takes ownership of the global scope, executing rspec within a child process
|
3
|
+
# may be preferred.
|
4
|
+
module VagrantPlugins
|
5
|
+
module ServerSpecHtmlReport
|
6
|
+
|
7
|
+
class Provisioner < Vagrant.plugin('2', :provisioner)
|
8
|
+
def initialize(machine, config)
|
9
|
+
super
|
10
|
+
@spec_files = config.spec_files
|
11
|
+
end
|
12
|
+
|
13
|
+
def provision
|
14
|
+
if machine.config.vm.communicator == :winrm
|
15
|
+
username = machine.config.winrm.username
|
16
|
+
winrm_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(@machine)
|
17
|
+
set :backend, :winrm
|
18
|
+
set :os, :family => 'windows'
|
19
|
+
user = machine.config.winrm.username
|
20
|
+
pass = machine.config.winrm.password
|
21
|
+
endpoint = "http://#{winrm_info[:host]}:#{winrm_info[:port]}/wsman"
|
22
|
+
|
23
|
+
winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
|
24
|
+
winrm.set_timeout machine.config.winrm.timeout
|
25
|
+
Specinfra.configuration.winrm = winrm
|
26
|
+
else
|
27
|
+
set :backend, :ssh
|
28
|
+
|
29
|
+
if ENV['ASK_SUDO_PASSWORD']
|
30
|
+
begin
|
31
|
+
require 'highline/import'
|
32
|
+
rescue LoadError
|
33
|
+
fail "highline is not available. Try installing it."
|
34
|
+
end
|
35
|
+
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
|
36
|
+
else
|
37
|
+
set :sudo_password, ENV['SUDO_PASSWORD']
|
38
|
+
end
|
39
|
+
|
40
|
+
host = machine.ssh_info[:host]
|
41
|
+
options = Net::SSH::Config.for(host)
|
42
|
+
|
43
|
+
options[:proxy] = setup_provider_proxy if use_jump_provider?
|
44
|
+
options[:user] = machine.ssh_info[:username]
|
45
|
+
options[:port] = machine.ssh_info[:port]
|
46
|
+
options[:keys] = machine.ssh_info[:private_key_path]
|
47
|
+
options[:password] = machine.ssh_info[:password]
|
48
|
+
options[:forward_agent] = machine.ssh_info[:private_key_path]
|
49
|
+
|
50
|
+
set :host, options[:host_name] || host
|
51
|
+
set :ssh_options, options
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'rspec'
|
55
|
+
require 'rspec_html_formatter'
|
56
|
+
config = RSpec.configuration
|
57
|
+
|
58
|
+
formatter = RspecHtmlFormatter.new(config.output_stream)
|
59
|
+
|
60
|
+
# create reporter with RspecHtmlFormatter
|
61
|
+
reporter = RSpec::Core::Reporter.new(config)
|
62
|
+
config.instance_variable_set(:@reporter, reporter)
|
63
|
+
|
64
|
+
# internal hack
|
65
|
+
# api may not be stable, make sure lock down Rspec version
|
66
|
+
loader = config.send(:formatter_loader)
|
67
|
+
notifications = loader.send(:notifications_for, RspecHtmlFormatter)
|
68
|
+
|
69
|
+
|
70
|
+
reporter.register_listener(formatter, *notifications)
|
71
|
+
|
72
|
+
RSpec::Core::Runner.run(@spec_files)
|
73
|
+
|
74
|
+
p formatter.output_hash
|
75
|
+
#raise Vagrant::Errors::ServerSpecFailed if status != 0
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def setup_provider_proxy
|
81
|
+
ssh_info = machine.provider.host_vm.ssh_info
|
82
|
+
host = ssh_info[:host]
|
83
|
+
port = ssh_info[:port]
|
84
|
+
username = ssh_info[:username]
|
85
|
+
key_path = ssh_info[:private_key_path][0]
|
86
|
+
|
87
|
+
proxy_options='-A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
88
|
+
Net::SSH::Proxy::Command.new("ssh #{proxy_options} -i #{key_path} -p #{port} #{username}@#{host} nc %h %p")
|
89
|
+
end
|
90
|
+
|
91
|
+
def use_jump_provider?
|
92
|
+
jump_providers = [
|
93
|
+
{
|
94
|
+
name: "DockerProvider",
|
95
|
+
platforms: ["mac"]
|
96
|
+
}
|
97
|
+
]
|
98
|
+
current_provider_class = machine.provider.class.name.to_s
|
99
|
+
|
100
|
+
jump_providers.any? do |jump_provider|
|
101
|
+
if current_provider_class.include? jump_provider[:name]
|
102
|
+
jump_provider[:platforms].any? do |platform|
|
103
|
+
OS.send("#{platform}?")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
vagrant:
|
4
|
+
config:
|
5
|
+
serverspec:
|
6
|
+
no_spec_files: |-
|
7
|
+
You must list at least one spec file
|
8
|
+
missing_spec_files: |-
|
9
|
+
These files were specified, but could not be found: %{files}
|
10
|
+
errors:
|
11
|
+
serverspec_failed: |-
|
12
|
+
ServerSpec failed to complete successfully. Any error output should be
|
13
|
+
visible above. Please fix these errors and try again.
|
data/test/Docker/.rspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Vagrant.configure("2") do |config|
|
2
|
+
config.vm.box = "mitchellh/boot2docker"
|
3
|
+
|
4
|
+
config.vm.provider "virtualbox" do |v|
|
5
|
+
# On VirtualBox, we don't have guest additions or a functional vboxsf
|
6
|
+
# in TinyCore Linux, so tell Vagrant that so it can be smarter.
|
7
|
+
v.check_guest_additions = false
|
8
|
+
v.functional_vboxsf = false
|
9
|
+
v.customize ["modifyvm", :id, "--memory", "1024"]
|
10
|
+
end
|
11
|
+
|
12
|
+
config.nfs.functional = false
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Vagrant.configure('2') do |config|
|
2
|
+
config.vm.provider "docker" do |d|
|
3
|
+
d.vagrant_vagrantfile = "./Docker_Vagrantfile"
|
4
|
+
d.image = "jjhughes57/docker-vagrant-ubuntu"
|
5
|
+
d.has_ssh = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.vm.provision :shell, inline: <<-EOF
|
9
|
+
sudo apt-get install -y vim
|
10
|
+
touch /tmp/testfile
|
11
|
+
EOF
|
12
|
+
|
13
|
+
config.vm.provision :serverspec do |spec|
|
14
|
+
spec.pattern = '*_spec.rb'
|
15
|
+
#Specinfra.configuration.sudo_password = 'vagrant'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#require 'serverspec'
|
2
|
+
#require 'net/ssh'
|
3
|
+
|
4
|
+
#set :backend, :ssh
|
5
|
+
|
6
|
+
# Disable sudo
|
7
|
+
# set :disable_sudo, true
|
8
|
+
|
9
|
+
# Set environment variables
|
10
|
+
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
|
11
|
+
|
12
|
+
# Set PATH
|
13
|
+
# set :path, '/sbin:/usr/local/sbin:$PATH'
|
data/test/ubuntu/.rspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Vagrant.configure('2') do |config|
|
2
|
+
config.vm.box = 'precise64'
|
3
|
+
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'
|
4
|
+
|
5
|
+
config.vm.provision :shell, inline: <<-EOF
|
6
|
+
sudo ufw allow 22
|
7
|
+
yes | sudo ufw enable
|
8
|
+
EOF
|
9
|
+
|
10
|
+
config.vm.provision :serverspec do |spec|
|
11
|
+
spec.pattern = '*_spec.rb'
|
12
|
+
#Specinfra.configuration.sudo_password = 'vagrant'
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#require 'serverspec'
|
2
|
+
#require 'net/ssh'
|
3
|
+
|
4
|
+
#set :backend, :ssh
|
5
|
+
|
6
|
+
# Disable sudo
|
7
|
+
# set :disable_sudo, true
|
8
|
+
|
9
|
+
# Set environment variables
|
10
|
+
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
|
11
|
+
|
12
|
+
# Set PATH
|
13
|
+
# set :path, '/sbin:/usr/local/sbin:$PATH'
|
data/test/windows/.rspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
#describe file('C:\\programdata\\chocolatey\\bin\\console.exe') do
|
4
|
+
# it { should be_file }
|
5
|
+
#end
|
6
|
+
|
7
|
+
describe windows_feature('Web-Server') do
|
8
|
+
it{ should be_installed.by("powershell") }
|
9
|
+
end
|
10
|
+
|
11
|
+
#describe windows_registry_key(
|
12
|
+
# 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\advanced') do
|
13
|
+
# it { should have_property_value('Hidden', :type_dword,'1') }
|
14
|
+
#end
|
15
|
+
|
16
|
+
describe command('Get-ExecutionPolicy') do
|
17
|
+
its(:stdout) { should match /RemoteSigned/ }
|
18
|
+
#its(:stderr) { should match /stderr/ }
|
19
|
+
its(:exit_status) { should eq 0 }
|
20
|
+
end
|
21
|
+
|
22
|
+
#describe iis_website('Default Website') do
|
23
|
+
# it{ should have_site_bindings(80) }
|
24
|
+
#end
|
25
|
+
|
26
|
+
describe port(80) do
|
27
|
+
it { should be_listening }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe file('C:\Windows\system32\telnet.exe') do
|
31
|
+
it { should be_file }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe windows_feature('TelnetClient') do
|
35
|
+
it{ should be_installed.by("powershell") }
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#require 'serverspec'
|
2
|
+
#require 'pathname'
|
3
|
+
#require 'winrm'
|
4
|
+
#set :backend, :winrm
|
5
|
+
#set :os, :family => 'windows'
|
6
|
+
|
7
|
+
#user = 'vagrant'
|
8
|
+
#pass = 'vagrant'
|
9
|
+
##endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
|
10
|
+
#endpoint = "http://10.128.139.116:5985/wsman"
|
11
|
+
#winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
|
12
|
+
#winrm.set_timeout 300 # 5 minutes max timeout for any operation
|
13
|
+
#Specinfra.configuration.winrm = winrm
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.require_version ">= 1.6.2"
|
5
|
+
|
6
|
+
Vagrant.configure("2") do |config|
|
7
|
+
config.vm.define "windows"
|
8
|
+
config.vm.box = "windows"
|
9
|
+
config.vm.communicator = "winrm"
|
10
|
+
|
11
|
+
# Admin user name and password
|
12
|
+
config.winrm.username = "vagrant"
|
13
|
+
config.winrm.password = "vagrant"
|
14
|
+
|
15
|
+
config.vm.guest = :windows
|
16
|
+
config.vm.communicator = "winrm"
|
17
|
+
config.windows.halt_timeout = 15
|
18
|
+
|
19
|
+
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
|
20
|
+
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
|
21
|
+
|
22
|
+
config.vm.provider "hyperv" do |v, override|
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
config.vm.provider :virtualbox do |v, override|
|
27
|
+
#v.gui = true
|
28
|
+
v.customize ["modifyvm", :id, "--memory", 2048]
|
29
|
+
v.customize ["modifyvm", :id, "--cpus", 2]
|
30
|
+
v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
|
31
|
+
end
|
32
|
+
|
33
|
+
config.vm.provider :vmware_fusion do |v, override|
|
34
|
+
#v.gui = true
|
35
|
+
v.vmx["memsize"] = "2048"
|
36
|
+
v.vmx["numvcpus"] = "2"
|
37
|
+
v.vmx["ethernet0.virtualDev"] = "vmxnet3"
|
38
|
+
v.vmx["RemoteDisplay.vnc.enabled"] = "false"
|
39
|
+
v.vmx["RemoteDisplay.vnc.port"] = "5900"
|
40
|
+
v.vmx["scsi0.virtualDev"] = "lsisas1068"
|
41
|
+
end
|
42
|
+
|
43
|
+
config.vm.provider :vmware_workstation do |v, override|
|
44
|
+
#v.gui = true
|
45
|
+
v.vmx["memsize"] = "2048"
|
46
|
+
v.vmx["numvcpus"] = "2"
|
47
|
+
v.vmx["ethernet0.virtualDev"] = "vmxnet3"
|
48
|
+
v.vmx["RemoteDisplay.vnc.enabled"] = "false"
|
49
|
+
v.vmx["RemoteDisplay.vnc.port"] = "5900"
|
50
|
+
v.vmx["scsi0.virtualDev"] = "lsisas1068"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
config.vm.provision :serverspec do |spec|
|
55
|
+
spec.pattern = '*_spec.rb'
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'vagrant-serverspechtmlreport/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'vagrant-serverspechtmlreport'
|
7
|
+
gem.homepage = 'https://github.com/support-capensis/vagrant-serverspec'
|
8
|
+
gem.version = VagrantPlugins::ServerSpec::VERSION
|
9
|
+
gem.authors = ['Support Capensis']
|
10
|
+
gem.email = ['support@capensis.fr']
|
11
|
+
gem.summary = %q{A Vagrant plugin that executes serverspec}
|
12
|
+
gem.description = "vagrant-serverspec is a Vagrant plugin that integrates serverspec into your workflow."
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'serverspec', '~> 2.7', '>= 2.7.0'
|
20
|
+
gem.add_runtime_dependency 'winrm', '~> 1.1', '>= 1.1.0'
|
21
|
+
gem.add_runtime_dependency 'os', '~> 0.9.6'
|
22
|
+
gem.add_runtime_dependency 'rspec_html_formatter', '~> 0.3','>= 0.3.1'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.2'
|
25
|
+
gem.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-serverspechtmlreport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Support Capensis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: serverspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.7.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.7.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: winrm
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.1.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: os
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.9.6
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.9.6
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec_html_formatter
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.3'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.3.1
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.3'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.3.1
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: bundler
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.6'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.6.2
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.6'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.6.2
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: rake
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '10.3'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 10.3.2
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '10.3'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 10.3.2
|
127
|
+
description: vagrant-serverspec is a Vagrant plugin that integrates serverspec into
|
128
|
+
your workflow.
|
129
|
+
email:
|
130
|
+
- support@capensis.fr
|
131
|
+
executables: []
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- WINDOWS_README.md
|
140
|
+
- lib/vagrant-serverspechtmlreport.rb
|
141
|
+
- lib/vagrant-serverspechtmlreport/config.rb
|
142
|
+
- lib/vagrant-serverspechtmlreport/error.rb
|
143
|
+
- lib/vagrant-serverspechtmlreport/plugin.rb
|
144
|
+
- lib/vagrant-serverspechtmlreport/provisioner.rb
|
145
|
+
- lib/vagrant-serverspechtmlreport/version.rb
|
146
|
+
- locales/en.yml
|
147
|
+
- test/Docker/.rspec
|
148
|
+
- test/Docker/Docker_Vagrantfile
|
149
|
+
- test/Docker/Vagrantfile
|
150
|
+
- test/Docker/sample_spec.rb
|
151
|
+
- test/Docker/spec_helper.rb
|
152
|
+
- test/ubuntu/.rspec
|
153
|
+
- test/ubuntu/Vagrantfile
|
154
|
+
- test/ubuntu/sample_spec.rb
|
155
|
+
- test/ubuntu/spec_helper.rb
|
156
|
+
- test/windows/.rspec
|
157
|
+
- test/windows/sample_spec.rb
|
158
|
+
- test/windows/spec_helper.rb
|
159
|
+
- test/windows/vagrantfile
|
160
|
+
- vagrant-serverspechtmlreport.gemspec
|
161
|
+
homepage: https://github.com/support-capensis/vagrant-serverspec
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.5.1
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: A Vagrant plugin that executes serverspec
|
185
|
+
test_files:
|
186
|
+
- test/Docker/.rspec
|
187
|
+
- test/Docker/Docker_Vagrantfile
|
188
|
+
- test/Docker/Vagrantfile
|
189
|
+
- test/Docker/sample_spec.rb
|
190
|
+
- test/Docker/spec_helper.rb
|
191
|
+
- test/ubuntu/.rspec
|
192
|
+
- test/ubuntu/Vagrantfile
|
193
|
+
- test/ubuntu/sample_spec.rb
|
194
|
+
- test/ubuntu/spec_helper.rb
|
195
|
+
- test/windows/.rspec
|
196
|
+
- test/windows/sample_spec.rb
|
197
|
+
- test/windows/spec_helper.rb
|
198
|
+
- test/windows/vagrantfile
|