vagrant-serverspec 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20db8d889601aa2e8831c7b0906b5c4ba6c0b2b1
4
- data.tar.gz: ff944529738e271a2c26bffd25e5b8a7560ce9db
3
+ metadata.gz: cb21e4c3f8c575336e5a48089c8ae23c43a0a74e
4
+ data.tar.gz: 3ab6fba636d1eb568979f3d0d53473c2ec78fb85
5
5
  SHA512:
6
- metadata.gz: 0d38d751424384d513f97be5256fce742785bfcfa23b08bb1dc843b521049039ac6c899e254b68cf48e062c59cc82e41e486e39dd6d27719596eac21cdbfa2c5
7
- data.tar.gz: 20975a17b4c6a4666a6f51c95cb3183d9390a78d15f98e829843047020923897659a306cb56ca560fcaec3a7ebb54a232c2b8b9865a6d20946c9a08340dda38d
6
+ metadata.gz: 4f2c79da25ec1774147767dbf801921bf634923e26b9d77a6112beb9fdd6a63a722882729e302ace87daa0c7d80e21d83d5f34d525504acb89a53eeb13fe1a78
7
+ data.tar.gz: edc4913c9eafd7ef054d695551496e707dd3b756b2a89216f23f193750c34fb0207339b72cd2a32d04694124090962dd7f19ae981e0a284aab49f0e6961f331e
data/README.md CHANGED
@@ -77,9 +77,12 @@ describe port(22) do
77
77
  end
78
78
  ```
79
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
+
80
83
  ## Versioning
81
84
 
82
- Test Kitchen aims to adhere to [Semantic Versioning 2.0.0][semver].
85
+ vagrant-serverspec aims to adhere to [Semantic Versioning 2.0.0][semver].
83
86
 
84
87
  ## Development
85
88
 
@@ -3,7 +3,8 @@ require 'serverspec'
3
3
  require 'pathname'
4
4
  require 'winrm'
5
5
  require 'net/ssh'
6
-
6
+ require 'net/ssh/proxy/command'
7
+ require 'os'
7
8
  module VagrantPlugins
8
9
  module ServerSpec
9
10
  class Plugin < Vagrant.plugin('2')
@@ -8,7 +8,7 @@ module VagrantPlugins
8
8
  super
9
9
  @spec_files = config.spec_files
10
10
  end
11
-
11
+
12
12
  def provision
13
13
  if machine.config.vm.communicator == :winrm
14
14
  username = machine.config.winrm.username
@@ -24,7 +24,7 @@ module VagrantPlugins
24
24
  Specinfra.configuration.winrm = winrm
25
25
  else
26
26
  set :backend, :ssh
27
-
27
+
28
28
  if ENV['ASK_SUDO_PASSWORD']
29
29
  begin
30
30
  require 'highline/import'
@@ -35,15 +35,15 @@ module VagrantPlugins
35
35
  else
36
36
  set :sudo_password, ENV['SUDO_PASSWORD']
37
37
  end
38
-
38
+
39
39
  host = machine.ssh_info[:host]
40
-
41
40
  options = Net::SSH::Config.for(host)
42
-
43
- options[:user] = machine.ssh_info[:username]
44
- options[:port] = machine.ssh_info[:port]
45
- options[:keys] = machine.ssh_info[:private_key_path]
46
- options[:password] = machine.ssh_info[:password]
41
+
42
+ options[:proxy] = setup_provider_proxy if use_jump_provider?
43
+ options[:user] = machine.ssh_info[:username]
44
+ options[:port] = machine.ssh_info[:port]
45
+ options[:keys] = machine.ssh_info[:private_key_path]
46
+ options[:password] = machine.ssh_info[:password]
47
47
  options[:forward_agent] = machine.ssh_info[:private_key_path]
48
48
 
49
49
  set :host, options[:host_name] || host
@@ -54,6 +54,37 @@ module VagrantPlugins
54
54
 
55
55
  raise Vagrant::Errors::ServerSpecFailed if status != 0
56
56
  end
57
+
58
+ private
59
+
60
+ def setup_provider_proxy
61
+ ssh_info = machine.provider.host_vm.ssh_info
62
+ host = ssh_info[:host]
63
+ port = ssh_info[:port]
64
+ username = ssh_info[:username]
65
+ key_path = ssh_info[:private_key_path][0]
66
+
67
+ proxy_options='-A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
68
+ Net::SSH::Proxy::Command.new("ssh #{proxy_options} -i #{key_path} -p #{port} #{username}@#{host} nc %h %p")
69
+ end
70
+
71
+ def use_jump_provider?
72
+ jump_providers = [
73
+ {
74
+ name: "DockerProvider",
75
+ platforms: ["mac"]
76
+ }
77
+ ]
78
+ current_provider_class = machine.provider.class.name.to_s
79
+
80
+ jump_providers.any? do |jump_provider|
81
+ if current_provider_class.include? jump_provider[:name]
82
+ jump_provider[:platforms].any? do |platform|
83
+ OS.send("#{platform}?")
84
+ end
85
+ end
86
+ end
87
+ end
57
88
  end
58
89
  end
59
90
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ServerSpec
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -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,9 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe package('vim') do
4
+ it { should be_installed }
5
+ end
6
+
7
+ describe file('/tmp/testfile') do
8
+ it { should be_file }
9
+ 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'
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_runtime_dependency 'serverspec', '~> 2.7', '>= 2.7.0'
20
20
  gem.add_runtime_dependency 'winrm', '~> 1.1', '>= 1.1.0'
21
+ gem.add_runtime_dependency 'os', '~> 0.9.6'
21
22
  #gem.add_runtime_dependency 'highline', '~> 1.6', '>= 1.6.20'
22
23
 
23
24
  gem.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Voorhis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: serverspec
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
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
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: bundler
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +125,11 @@ files:
111
125
  - lib/vagrant-serverspec/provisioner.rb
112
126
  - lib/vagrant-serverspec/version.rb
113
127
  - locales/en.yml
128
+ - test/Docker/.rspec
129
+ - test/Docker/Docker_Vagrantfile
130
+ - test/Docker/Vagrantfile
131
+ - test/Docker/sample_spec.rb
132
+ - test/Docker/spec_helper.rb
114
133
  - test/ubuntu/.rspec
115
134
  - test/ubuntu/Vagrantfile
116
135
  - test/ubuntu/sample_spec.rb
@@ -145,6 +164,11 @@ signing_key:
145
164
  specification_version: 4
146
165
  summary: A Vagrant plugin that executes serverspec
147
166
  test_files:
167
+ - test/Docker/.rspec
168
+ - test/Docker/Docker_Vagrantfile
169
+ - test/Docker/Vagrantfile
170
+ - test/Docker/sample_spec.rb
171
+ - test/Docker/spec_helper.rb
148
172
  - test/ubuntu/.rspec
149
173
  - test/ubuntu/Vagrantfile
150
174
  - test/ubuntu/sample_spec.rb