kitchen-verifier-serverspec 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -15
- data/kitchen-verifier-serverspec.gemspec +2 -0
- data/lib/kitchen/verifier/serverspec.rb +20 -11
- data/lib/kitchen/verifier/serverspec_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04ea622e5e64149fe8915e40acffec028e15c7b
|
4
|
+
data.tar.gz: 5a8d0743a3d7b45b3bfa2e467bbf079485aa64fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 950ede95612d63939b3f08fd528fcd3d52efcb22af0ed2c3bf79313bc8956b5f0d1f553ef331ff71197f033a73998035fe0c517a20f734a5620c1c6726802d64
|
7
|
+
data.tar.gz: b2c96eedfd9bcbf2741747bb238986433249414a02c28edd59dc095cce0495bda2ffac3fea7351be70970662e8332a27552251967c180c500cbcc074049579f1
|
data/README.md
CHANGED
@@ -40,29 +40,38 @@ this allows extra dependencies to be specified and the version of serverspec spe
|
|
40
40
|
|
41
41
|
key | default value | Notes
|
42
42
|
----|---------------|--------
|
43
|
-
|
44
|
-
remote_exec | true | specify false to run serverspec on workstation
|
45
|
-
custom_serverspec_command | nil | custom command to run serverspec. Can be multiline. See examples below.
|
43
|
+
additional_install_commmand | nil | Additional shell command to be used at install stage. Can be multiline. See examples below.
|
46
44
|
additional_serverspec_command | nil | additional command to run serverspec. Can be multiline. See examples below.
|
47
|
-
|
45
|
+
bundler_path | | override path for bundler command
|
48
46
|
color | true | enable color in the output
|
49
|
-
default_path | '/tmp/kitchen' | Set the default path where serverspec looks for patterns
|
50
|
-
patterns | [] | array of patterns for spec test files
|
51
|
-
gemfile | nil | custom gemfile to use to install serverspec
|
52
47
|
custom_install_commmand | nil | Custom shell command to be used at install stage. Can be multiline. See examples below.
|
53
|
-
|
54
|
-
|
48
|
+
custom_serverspec_command | nil | custom command to run serverspec. Can be multiline. See examples below.
|
49
|
+
default_path | '/tmp/kitchen' | Set the default path where serverspec looks for patterns
|
50
|
+
default_pattern | false | use default dir behaviour of busser i.e. test/integration/SUIT_NAME/serverspec/*_spec.rb
|
51
|
+
env_vars | {} | environment variable to set for rspec and can be used in the spec_helper. It will automatically pickup any environment variables set with a KITCHEN_ prefix.
|
55
52
|
extra_flags | nil | extra flags to add to ther serverspec command
|
56
|
-
|
53
|
+
format | 'documentation' | format of serverspec output
|
54
|
+
gemfile | nil | custom gemfile to use to install serverspec
|
57
55
|
http_proxy | nil | use http proxy when installing ruby, serverspec and running serverspec
|
58
56
|
https_proxy | nil | use https proxy when installing puppet, ruby, serverspec and running serverspec
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
patterns | [] | array of patterns for spec test files
|
58
|
+
remote_exec | true | specify false to run serverspec on workstation
|
59
|
+
remove_default_path | false | remove the default_path after successful serverspec run
|
60
|
+
require_runner | false | run the custom runner instead of rspec directly
|
63
61
|
rspec_path | | override path for rspec command
|
64
62
|
runner_url | https://raw.githubusercontent.com /neillturner/serverspec-runners/ master/ansiblespec_runner.rb | url for custom runner
|
65
|
-
|
63
|
+
sleep | 0 |
|
64
|
+
sudo | nil | use sudo to run commands
|
65
|
+
sudo_command | 'sudo -E -H' | sudo command to run when sudo set to true
|
66
|
+
test_serverspec_installed | true | only run install_command if serverspec not installed
|
67
|
+
|
68
|
+
## Tips
|
69
|
+
|
70
|
+
If you get errors like 'Bundler installed as root, can't be found' then you will need to set the paths. Its hard to get the default paths correct when ruby maybe installed in a different user.
|
71
|
+
```
|
72
|
+
bundler_path: '/usr/local/bin'
|
73
|
+
rspec_path: '/usr/local/bin'
|
74
|
+
```
|
66
75
|
|
67
76
|
## Usage
|
68
77
|
|
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
if RUBY_VERSION >= '2.0'
|
21
21
|
s.add_dependency 'net-ssh', '~> 3'
|
22
22
|
else
|
23
|
+
s.add_dependency 'json', '~> 1.8'
|
23
24
|
s.add_dependency 'net-ssh', '~> 2.9'
|
25
|
+
s.add_dependency 'rubocop', '~> 0.41.2'
|
24
26
|
end
|
25
27
|
s.description = <<-EOF
|
26
28
|
Serverspec verifier for Test-Kitchen without having to transit the Busser layer.
|
@@ -35,6 +35,7 @@ module Kitchen
|
|
35
35
|
default_config :color, true
|
36
36
|
default_config :default_path, '/tmp/kitchen'
|
37
37
|
default_config :patterns, []
|
38
|
+
default_config :default_pattern, false
|
38
39
|
default_config :gemfile, nil
|
39
40
|
default_config :custom_install_command, nil
|
40
41
|
default_config :additional_install_command, nil
|
@@ -164,17 +165,13 @@ module Kitchen
|
|
164
165
|
end
|
165
166
|
|
166
167
|
def install_runner
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
else
|
175
|
-
raise ActionFailed, 'Serverspec Runners only for remote execution'
|
176
|
-
end
|
177
|
-
end
|
168
|
+
return unless config[:require_runner]
|
169
|
+
raise ActionFailed, 'Serverspec Runners only for remote execution' unless config[:remote_exec]
|
170
|
+
<<-INSTALL
|
171
|
+
if [ ! -f #{config[:default_path]}/#{runner_filename} ]; then
|
172
|
+
#{sudo_env('curl')} -o #{config[:default_path]}/#{runner_filename} #{config[:runner_url]}
|
173
|
+
fi
|
174
|
+
INSTALL
|
178
175
|
end
|
179
176
|
|
180
177
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -253,6 +250,10 @@ module Kitchen
|
|
253
250
|
|
254
251
|
def rspec_commands
|
255
252
|
info('Running Serverspec')
|
253
|
+
if config[:default_pattern]
|
254
|
+
info("Using default pattern #{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb")
|
255
|
+
config[:patterns] = ["#{config[:test_base_path]}/#{config[:suite_name]}/serverspec/*_spec.rb"]
|
256
|
+
end
|
256
257
|
if config[:require_runner]
|
257
258
|
"#{env_vars} #{sudo_env(rspec_cmd)} #{color} -f #{config[:format]} --default-path #{config[:default_path]} #{rspec_path_option} #{config[:extra_flags]}"
|
258
259
|
elsif config[:remote_exec]
|
@@ -348,6 +349,7 @@ module Kitchen
|
|
348
349
|
end
|
349
350
|
|
350
351
|
def shellout(command)
|
352
|
+
command = command.strip
|
351
353
|
info("Running command: #{command}")
|
352
354
|
cmd = Mixlib::ShellOut.new(command, config[:shellout_opts])
|
353
355
|
cmd.live_stream = config[:live_stream]
|
@@ -369,6 +371,13 @@ module Kitchen
|
|
369
371
|
ENV['KITCHEN_' + key.to_s.upcase] = value.to_s
|
370
372
|
info("Environment variable #{'KITCHEN_' + key.to_s.upcase} value #{value}")
|
371
373
|
end
|
374
|
+
# if using a driver that uses transport expose those too
|
375
|
+
%w(username password ssh_key port).each do |key|
|
376
|
+
next if instance.transport[key.to_sym].nil?
|
377
|
+
value = instance.transport[key.to_sym].to_s
|
378
|
+
ENV['KITCHEN_' + key.to_s.upcase] = value
|
379
|
+
info("Transport Environment variable #{'KITCHEN_' + key.to_s.upcase} value #{value}")
|
380
|
+
end
|
372
381
|
config[:shellout_opts].merge!(env_state)
|
373
382
|
end
|
374
383
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-verifier-serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neill Turner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|