kitchen-verifier-serverspec 0.3.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +175 -156
- data/kitchen-verifier-serverspec.gemspec +25 -25
- data/lib/kitchen/verifier/serverspec.rb +349 -347
- data/lib/kitchen/verifier/serverspec_version.rb +7 -7
- metadata +10 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c6714cf2d0e9650191e995f574f04e41d82a93f
|
|
4
|
+
data.tar.gz: ff945273b667c74be626404334d7e84ec67b140a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dff14d247fda8eb4f815aef042f94f4403f9b9cfeb6d797184d39f768d8c43f660b996163847a857cc8cdc8c6179e1d9a30536b7ec1cbbd65bd4235632fbba6f
|
|
7
|
+
data.tar.gz: 566bc642fc3b9e9f6fb147f0dab6136162bfe6853c364e310d9860c75b8c7ebb30a20bac74c18af97c8684eb5cbecd82c945481cf57b7b1aea0d8f408058f6b8
|
data/README.md
CHANGED
|
@@ -1,156 +1,175 @@
|
|
|
1
|
-
[](http://badge.fury.io/rb/kitchen-verifier-serverspec)
|
|
2
|
-
[](https://rubygems.org/gems/kitchen-verifier-serverspec)
|
|
3
|
-
[](https://travis-ci.org/neillturner/kitchen-verifier-serverspec)
|
|
4
|
-
|
|
5
|
-
# Kitchen::Verifier::Serverspec
|
|
6
|
-
|
|
7
|
-
A Test Kitchen Serverspec Verifer without having to transit the Busser layer.
|
|
8
|
-
|
|
9
|
-
This supports running
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
On your workstation add this line to your Gemfile:
|
|
16
|
-
|
|
17
|
-
gem 'kitchen-verifier-serverspec'
|
|
18
|
-
|
|
19
|
-
And then execute:
|
|
20
|
-
|
|
21
|
-
$ bundle
|
|
22
|
-
|
|
23
|
-
Or install it yourself as:
|
|
24
|
-
|
|
25
|
-
$ gem install kitchen-verifier-serverspec
|
|
26
|
-
|
|
27
|
-
When it runs it install serverspec on the remote server or the workstation if remote_exec set to false.
|
|
28
|
-
This can be configured by passing a Gemfile like this:
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
source 'https://rubygems.org'
|
|
32
|
-
|
|
33
|
-
gem 'net-ssh','~> 2.9'
|
|
34
|
-
gem 'serverspec'
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
this allows extra dependencies to be specified and the version of serverspec specified.
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
An example of the verifier serverspec options in your `.kitchen.yml` file:
|
|
43
|
-
|
|
44
|
-
```yaml
|
|
45
|
-
verifier:
|
|
46
|
-
name: serverspec
|
|
47
|
-
|
|
48
|
-
suites:
|
|
49
|
-
- name: base
|
|
50
|
-
verifier:
|
|
51
|
-
patterns:
|
|
52
|
-
- modules/mycompany_base/spec/acceptance/base_spec.rb
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
See example [https://github.com/neillturner/puppet_repo](https://github.com/neillturner/puppet_repo)
|
|
56
|
-
|
|
57
|
-
or with environment variables
|
|
58
|
-
|
|
59
|
-
```yaml
|
|
60
|
-
verifier:
|
|
61
|
-
name: serverspec
|
|
62
|
-
|
|
63
|
-
suites:
|
|
64
|
-
- name: base
|
|
65
|
-
verifier:
|
|
66
|
-
patterns:
|
|
67
|
-
- roles/tomcat/spec/tomcat_spec.rb
|
|
68
|
-
bundler_path: '/usr/local/bin'
|
|
69
|
-
rspec_path: '/home/vagrant/bin'
|
|
70
|
-
env_vars:
|
|
71
|
-
TARGET_HOST: 172.28.128.7
|
|
72
|
-
LOGIN_USER: vagrant
|
|
73
|
-
SSH_KEY: 'spec/tomcat_private_key.pem'
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
or run on your workstation
|
|
77
|
-
|
|
78
|
-
```yaml
|
|
79
|
-
verifier:
|
|
80
|
-
name: serverspec
|
|
81
|
-
remote_exec: false
|
|
82
|
-
|
|
83
|
-
suites:
|
|
84
|
-
- name: base
|
|
85
|
-
provisioner:
|
|
86
|
-
custom_facts:
|
|
87
|
-
role_name1: base
|
|
88
|
-
verifier:
|
|
89
|
-
patterns:
|
|
90
|
-
- modules_mycompany/mycompany_base/spec/acceptance/base_local_spec.rb
|
|
91
|
-
env_vars:
|
|
92
|
-
TARGET_HOST: 127.0.0.1
|
|
93
|
-
TARGET_PORT: 2222
|
|
94
|
-
LOGIN_USER: vagrant
|
|
95
|
-
SSH_KEY: 'c:/repository/puppet_repo/private_key.pem'
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
# Custom Runners
|
|
99
|
-
|
|
100
|
-
Custon runners can be defined and run to provide further customization.
|
|
101
|
-
There is a runner that automatically runs the ansiblespec files for all the hosts from the
|
|
102
|
-
ansible provisioner.
|
|
103
|
-
|
|
104
|
-
This can be run by specifying in the kitchen yml file:
|
|
105
|
-
|
|
106
|
-
```yaml
|
|
107
|
-
verifier:
|
|
108
|
-
name: serverspec
|
|
109
|
-
|
|
110
|
-
suites:
|
|
111
|
-
- name: base
|
|
112
|
-
verifier:
|
|
113
|
-
runner_url: https://raw.githubusercontent.com/neillturner/serverspec-runners/master/ansiblespec_runner.rb
|
|
114
|
-
require_runner: true
|
|
115
|
-
bundler_path: '/usr/local/bin'
|
|
116
|
-
rspec_path: '/home/vagrant/bin'
|
|
117
|
-
env_vars:
|
|
118
|
-
TARGET_HOST: 172.28.128.7
|
|
119
|
-
LOGIN_USER: vagrant
|
|
120
|
-
SSH_KEY: 'spec/tomcat_private_key.pem'
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
# Serverspec Verifier Options
|
|
125
|
-
|
|
126
|
-
key | default value | Notes
|
|
127
|
-
----|---------------|--------
|
|
128
|
-
sleep | 0 |
|
|
129
|
-
remote_exec | true | specify false to run serverspec on workstation
|
|
130
|
-
serverspec_command | nil | custom command to run serverspec
|
|
131
|
-
format | 'documentation' | format of serverspec output
|
|
132
|
-
color | true | enable color in the output
|
|
133
|
-
default_path | '/tmp/kitchen' | Set the default path where serverspec looks for patterns
|
|
134
|
-
patterns | [] | array of patterns for spec test files
|
|
135
|
-
gemfile | nil | custom gemfile to use to install serverspec
|
|
136
|
-
|
|
137
|
-
test_serverspec_installed | true | only run install_command if serverspec not installed
|
|
138
|
-
extra_flags | nil | extra flags to add to ther serverspec command
|
|
139
|
-
remove_default_path | false | remove the default_path after successful serverspec run
|
|
140
|
-
http_proxy | nil | use http proxy when installing ruby, serverspec and running serverspec
|
|
141
|
-
https_proxy | nil | use https proxy when installing puppet, ruby, serverspec and running serverspec
|
|
142
|
-
sudo | nil | use sudo to run commands
|
|
143
|
-
env_vars | {} | environment variable to set for rspec
|
|
144
|
-
|
|
145
|
-
rspec_path | nil | path for rspec command
|
|
146
|
-
runner_url | https://raw.githubusercontent.com /neillturner/serverspec-runners/ master/ansiblespec_runner.rb | url for custom runner
|
|
147
|
-
require_runner | false | run the custom runner instead of rspec directly
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
1
|
+
[](http://badge.fury.io/rb/kitchen-verifier-serverspec)
|
|
2
|
+
[](https://rubygems.org/gems/kitchen-verifier-serverspec)
|
|
3
|
+
[](https://travis-ci.org/neillturner/kitchen-verifier-serverspec)
|
|
4
|
+
|
|
5
|
+
# Kitchen::Verifier::Serverspec
|
|
6
|
+
|
|
7
|
+
A Test Kitchen Serverspec Verifer without having to transit the Busser layer.
|
|
8
|
+
|
|
9
|
+
This supports running serverspec both remotely on the server and locally on your workstation.
|
|
10
|
+
Runners are supported to provide logic to run serverspec initially supporting ansiblespec.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
On your workstation add this line to your Gemfile:
|
|
16
|
+
|
|
17
|
+
gem 'kitchen-verifier-serverspec'
|
|
18
|
+
|
|
19
|
+
And then execute:
|
|
20
|
+
|
|
21
|
+
$ bundle
|
|
22
|
+
|
|
23
|
+
Or install it yourself as:
|
|
24
|
+
|
|
25
|
+
$ gem install kitchen-verifier-serverspec
|
|
26
|
+
|
|
27
|
+
When it runs it install serverspec on the remote server or the workstation if remote_exec set to false.
|
|
28
|
+
This can be configured by passing a Gemfile like this:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
source 'https://rubygems.org'
|
|
32
|
+
|
|
33
|
+
gem 'net-ssh','~> 2.9'
|
|
34
|
+
gem 'serverspec'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
this allows extra dependencies to be specified and the version of serverspec specified.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
An example of the verifier serverspec options in your `.kitchen.yml` file:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
verifier:
|
|
46
|
+
name: serverspec
|
|
47
|
+
|
|
48
|
+
suites:
|
|
49
|
+
- name: base
|
|
50
|
+
verifier:
|
|
51
|
+
patterns:
|
|
52
|
+
- modules/mycompany_base/spec/acceptance/base_spec.rb
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See example [https://github.com/neillturner/puppet_repo](https://github.com/neillturner/puppet_repo)
|
|
56
|
+
|
|
57
|
+
or with environment variables
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
verifier:
|
|
61
|
+
name: serverspec
|
|
62
|
+
|
|
63
|
+
suites:
|
|
64
|
+
- name: base
|
|
65
|
+
verifier:
|
|
66
|
+
patterns:
|
|
67
|
+
- roles/tomcat/spec/tomcat_spec.rb
|
|
68
|
+
bundler_path: '/usr/local/bin'
|
|
69
|
+
rspec_path: '/home/vagrant/bin'
|
|
70
|
+
env_vars:
|
|
71
|
+
TARGET_HOST: 172.28.128.7
|
|
72
|
+
LOGIN_USER: vagrant
|
|
73
|
+
SSH_KEY: 'spec/tomcat_private_key.pem'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
or run on your workstation
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
verifier:
|
|
80
|
+
name: serverspec
|
|
81
|
+
remote_exec: false
|
|
82
|
+
|
|
83
|
+
suites:
|
|
84
|
+
- name: base
|
|
85
|
+
provisioner:
|
|
86
|
+
custom_facts:
|
|
87
|
+
role_name1: base
|
|
88
|
+
verifier:
|
|
89
|
+
patterns:
|
|
90
|
+
- modules_mycompany/mycompany_base/spec/acceptance/base_local_spec.rb
|
|
91
|
+
env_vars:
|
|
92
|
+
TARGET_HOST: 127.0.0.1
|
|
93
|
+
TARGET_PORT: 2222
|
|
94
|
+
LOGIN_USER: vagrant
|
|
95
|
+
SSH_KEY: 'c:/repository/puppet_repo/private_key.pem'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
# Custom Runners
|
|
99
|
+
|
|
100
|
+
Custon runners can be defined and run to provide further customization.
|
|
101
|
+
There is a runner that automatically runs the ansiblespec files for all the hosts from the
|
|
102
|
+
ansible provisioner.
|
|
103
|
+
|
|
104
|
+
This can be run by specifying in the kitchen yml file:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
verifier:
|
|
108
|
+
name: serverspec
|
|
109
|
+
|
|
110
|
+
suites:
|
|
111
|
+
- name: base
|
|
112
|
+
verifier:
|
|
113
|
+
runner_url: https://raw.githubusercontent.com/neillturner/serverspec-runners/master/ansiblespec_runner.rb
|
|
114
|
+
require_runner: true
|
|
115
|
+
bundler_path: '/usr/local/bin'
|
|
116
|
+
rspec_path: '/home/vagrant/bin'
|
|
117
|
+
env_vars:
|
|
118
|
+
TARGET_HOST: 172.28.128.7
|
|
119
|
+
LOGIN_USER: vagrant
|
|
120
|
+
SSH_KEY: 'spec/tomcat_private_key.pem'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Serverspec Verifier Options
|
|
125
|
+
|
|
126
|
+
key | default value | Notes
|
|
127
|
+
----|---------------|--------
|
|
128
|
+
sleep | 0 |
|
|
129
|
+
remote_exec | true | specify false to run serverspec on workstation
|
|
130
|
+
serverspec_command | nil | custom command to run serverspec
|
|
131
|
+
format | 'documentation' | format of serverspec output
|
|
132
|
+
color | true | enable color in the output
|
|
133
|
+
default_path | '/tmp/kitchen' | Set the default path where serverspec looks for patterns
|
|
134
|
+
patterns | [] | array of patterns for spec test files
|
|
135
|
+
gemfile | nil | custom gemfile to use to install serverspec
|
|
136
|
+
custom_install_commmand | nil | Custom shell command to be used at install stage. Can be multiline. See examples below.
|
|
137
|
+
test_serverspec_installed | true | only run install_command if serverspec not installed
|
|
138
|
+
extra_flags | nil | extra flags to add to ther serverspec command
|
|
139
|
+
remove_default_path | false | remove the default_path after successful serverspec run
|
|
140
|
+
http_proxy | nil | use http proxy when installing ruby, serverspec and running serverspec
|
|
141
|
+
https_proxy | nil | use https proxy when installing puppet, ruby, serverspec and running serverspec
|
|
142
|
+
sudo | nil | use sudo to run commands
|
|
143
|
+
env_vars | {} | environment variable to set for rspec
|
|
144
|
+
bundler_path | nil | path for bundler command
|
|
145
|
+
rspec_path | nil | path for rspec command
|
|
146
|
+
runner_url | https://raw.githubusercontent.com /neillturner/serverspec-runners/ master/ansiblespec_runner.rb | url for custom runner
|
|
147
|
+
require_runner | false | run the custom runner instead of rspec directly
|
|
148
|
+
|
|
149
|
+
#### custom_install_command example usage
|
|
150
|
+
|
|
151
|
+
* One liner
|
|
152
|
+
```yaml
|
|
153
|
+
custom_install_command: yum install -y git
|
|
154
|
+
```
|
|
155
|
+
* Multiple lines, a.k.a embed shell script
|
|
156
|
+
```yaml
|
|
157
|
+
custom_install_command: |
|
|
158
|
+
command1
|
|
159
|
+
command2
|
|
160
|
+
```
|
|
161
|
+
* Multiple lines join without new line
|
|
162
|
+
```yaml
|
|
163
|
+
custom_install_command: >
|
|
164
|
+
command1 &&
|
|
165
|
+
command2
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
1. Fork it
|
|
171
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
172
|
+
3. Run style checks and RSpec tests (`bundle exec rake`)
|
|
173
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
|
174
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
|
175
|
+
6. Create new Pull Request
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
-
|
|
5
|
-
require 'kitchen/verifier/serverspec_version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |s|
|
|
8
|
-
s.name = 'kitchen-verifier-serverspec'
|
|
9
|
-
s.license = 'Apache-2.0'
|
|
10
|
-
s.version = Kitchen::Verifier::SERVERSPEC_VERSION
|
|
11
|
-
s.authors = ['Neill Turner']
|
|
12
|
-
s.email = ['neillwturner@gmail.com']
|
|
13
|
-
s.homepage = 'https://github.com/neillturner/kitchen-verifier-serverspec'
|
|
14
|
-
s.summary = 'Serverspec verifier for Test-Kitchen without having to transit the Busser layer. '
|
|
15
|
-
candidates = Dir.glob('{lib}/**/*') + ['README.md', 'kitchen-verifier-serverspec.gemspec']
|
|
16
|
-
s.files = candidates.sort
|
|
17
|
-
s.platform = Gem::Platform::RUBY
|
|
18
|
-
s.require_paths = ['lib']
|
|
19
|
-
s.rubyforge_project = '[none]'
|
|
20
|
-
s.add_dependency 'test-kitchen', '~> 1.4'
|
|
21
|
-
s.add_dependency 'net-ssh', '~> 2.0'
|
|
22
|
-
s.description = <<-EOF
|
|
23
|
-
Serverspec verifier for Test-Kitchen without having to transit the Busser layer.
|
|
24
|
-
EOF
|
|
25
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
+
|
|
5
|
+
require 'kitchen/verifier/serverspec_version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = 'kitchen-verifier-serverspec'
|
|
9
|
+
s.license = 'Apache-2.0'
|
|
10
|
+
s.version = Kitchen::Verifier::SERVERSPEC_VERSION
|
|
11
|
+
s.authors = ['Neill Turner']
|
|
12
|
+
s.email = ['neillwturner@gmail.com']
|
|
13
|
+
s.homepage = 'https://github.com/neillturner/kitchen-verifier-serverspec'
|
|
14
|
+
s.summary = 'Serverspec verifier for Test-Kitchen without having to transit the Busser layer. '
|
|
15
|
+
candidates = Dir.glob('{lib}/**/*') + ['README.md', 'kitchen-verifier-serverspec.gemspec']
|
|
16
|
+
s.files = candidates.sort
|
|
17
|
+
s.platform = Gem::Platform::RUBY
|
|
18
|
+
s.require_paths = ['lib']
|
|
19
|
+
s.rubyforge_project = '[none]'
|
|
20
|
+
s.add_dependency 'test-kitchen', '~> 1.4'
|
|
21
|
+
s.add_dependency 'net-ssh', '~> 2.0'
|
|
22
|
+
s.description = <<-EOF
|
|
23
|
+
Serverspec verifier for Test-Kitchen without having to transit the Busser layer.
|
|
24
|
+
EOF
|
|
25
|
+
end
|
|
@@ -1,347 +1,349 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
require 'kitchen/verifier/base'
|
|
16
|
-
|
|
17
|
-
module Kitchen
|
|
18
|
-
module Verifier
|
|
19
|
-
# Serverspec verifier for Kitchen.
|
|
20
|
-
class Serverspec < Kitchen::Verifier::Base
|
|
21
|
-
require 'mixlib/shellout'
|
|
22
|
-
|
|
23
|
-
kitchen_verifier_api_version 1
|
|
24
|
-
|
|
25
|
-
plugin_version Kitchen::VERSION
|
|
26
|
-
|
|
27
|
-
default_config :sleep, 0
|
|
28
|
-
default_config :serverspec_command, nil
|
|
29
|
-
default_config :shellout_opts, {}
|
|
30
|
-
default_config :live_stream, $stdout
|
|
31
|
-
default_config :remote_exec, true
|
|
32
|
-
default_config :format, 'documentation'
|
|
33
|
-
default_config :color, true
|
|
34
|
-
default_config :default_path, '/tmp/kitchen'
|
|
35
|
-
default_config :patterns, []
|
|
36
|
-
default_config :gemfile, nil
|
|
37
|
-
default_config :
|
|
38
|
-
default_config :test_serverspec_installed, true
|
|
39
|
-
default_config :extra_flags, nil
|
|
40
|
-
default_config :remove_default_path, false
|
|
41
|
-
default_config :env_vars, {}
|
|
42
|
-
default_config :
|
|
43
|
-
default_config :rspec_path,
|
|
44
|
-
default_config :require_runner, false
|
|
45
|
-
default_config :runner_url, 'https://raw.githubusercontent.com/neillturner/serverspec-runners/master/ansiblespec_runner.rb'
|
|
46
|
-
|
|
47
|
-
# (see Base#call)
|
|
48
|
-
def call(state)
|
|
49
|
-
info("[#{name}] Verify on instance=#{instance} with state=#{state}")
|
|
50
|
-
sleep_if_set
|
|
51
|
-
merge_state_to_env(state)
|
|
52
|
-
if config[:remote_exec]
|
|
53
|
-
instance.transport.connection(state) do |conn|
|
|
54
|
-
conn.execute(install_command)
|
|
55
|
-
conn.execute(serverspec_commands)
|
|
56
|
-
end
|
|
57
|
-
else
|
|
58
|
-
config[:default_path] = Dir.pwd if config[:default_path] == '/tmp/kitchen'
|
|
59
|
-
install_command
|
|
60
|
-
serverspec_commands
|
|
61
|
-
end
|
|
62
|
-
debug("[#{name}] Verify completed.")
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
## for legacy drivers.
|
|
66
|
-
def run_command
|
|
67
|
-
sleep_if_set
|
|
68
|
-
serverspec_commands
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def setup_cmd
|
|
72
|
-
sleep_if_set
|
|
73
|
-
install_command
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
INSTALL
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
#{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
c
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if config[:remote_exec]
|
|
108
|
-
info('Installing ruby, bundler and serverspec')
|
|
109
|
-
<<-INSTALL
|
|
110
|
-
if [ ! $(which ruby) ]; then
|
|
111
|
-
echo '-----> Installing ruby, will try to determine platform os'
|
|
112
|
-
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
|
|
113
|
-
#{sudo_env('yum')} -y install ruby
|
|
114
|
-
else
|
|
115
|
-
if [ -f /etc/system-release ] || [ grep -q 'Amazon Linux' /etc/system-release ]; then
|
|
116
|
-
#{sudo_env('yum')} -y install ruby
|
|
117
|
-
else
|
|
118
|
-
#{sudo_env('apt-get')} -y install ruby
|
|
119
|
-
fi
|
|
120
|
-
fi
|
|
121
|
-
fi
|
|
122
|
-
#{install_bundler}
|
|
123
|
-
if [ -d #{config[:default_path]} ]; then
|
|
124
|
-
#{install_serverspec}
|
|
125
|
-
#{install_runner}
|
|
126
|
-
else
|
|
127
|
-
echo "ERROR: Default path '#{config[:default_path]}' does not exist"
|
|
128
|
-
exit 1
|
|
129
|
-
fi
|
|
130
|
-
INSTALL
|
|
131
|
-
else
|
|
132
|
-
info('Installing bundler and serverspec')
|
|
133
|
-
install_bundler
|
|
134
|
-
install_serverspec
|
|
135
|
-
install_runner
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
#{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
INSTALL
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
#{sudo('
|
|
214
|
-
#{sudo('echo')} "
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
f
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
#
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
#
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
cmd.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
env_state
|
|
339
|
-
env_state[:environment]['
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require 'kitchen/verifier/base'
|
|
16
|
+
|
|
17
|
+
module Kitchen
|
|
18
|
+
module Verifier
|
|
19
|
+
# Serverspec verifier for Kitchen.
|
|
20
|
+
class Serverspec < Kitchen::Verifier::Base
|
|
21
|
+
require 'mixlib/shellout'
|
|
22
|
+
|
|
23
|
+
kitchen_verifier_api_version 1
|
|
24
|
+
|
|
25
|
+
plugin_version Kitchen::VERSION
|
|
26
|
+
|
|
27
|
+
default_config :sleep, 0
|
|
28
|
+
default_config :serverspec_command, nil
|
|
29
|
+
default_config :shellout_opts, {}
|
|
30
|
+
default_config :live_stream, $stdout
|
|
31
|
+
default_config :remote_exec, true
|
|
32
|
+
default_config :format, 'documentation'
|
|
33
|
+
default_config :color, true
|
|
34
|
+
default_config :default_path, '/tmp/kitchen'
|
|
35
|
+
default_config :patterns, []
|
|
36
|
+
default_config :gemfile, nil
|
|
37
|
+
default_config :custom_install_command, nil
|
|
38
|
+
default_config :test_serverspec_installed, true
|
|
39
|
+
default_config :extra_flags, nil
|
|
40
|
+
default_config :remove_default_path, false
|
|
41
|
+
default_config :env_vars, {}
|
|
42
|
+
default_config :bundler_path, nil
|
|
43
|
+
default_config :rspec_path, nil
|
|
44
|
+
default_config :require_runner, false
|
|
45
|
+
default_config :runner_url, 'https://raw.githubusercontent.com/neillturner/serverspec-runners/master/ansiblespec_runner.rb'
|
|
46
|
+
|
|
47
|
+
# (see Base#call)
|
|
48
|
+
def call(state)
|
|
49
|
+
info("[#{name}] Verify on instance=#{instance} with state=#{state}")
|
|
50
|
+
sleep_if_set
|
|
51
|
+
merge_state_to_env(state)
|
|
52
|
+
if config[:remote_exec]
|
|
53
|
+
instance.transport.connection(state) do |conn|
|
|
54
|
+
conn.execute(install_command)
|
|
55
|
+
conn.execute(serverspec_commands)
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
config[:default_path] = Dir.pwd if config[:default_path] == '/tmp/kitchen'
|
|
59
|
+
install_command
|
|
60
|
+
serverspec_commands
|
|
61
|
+
end
|
|
62
|
+
debug("[#{name}] Verify completed.")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
## for legacy drivers.
|
|
66
|
+
def run_command
|
|
67
|
+
sleep_if_set
|
|
68
|
+
serverspec_commands
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def setup_cmd
|
|
72
|
+
sleep_if_set
|
|
73
|
+
install_command
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def serverspec_commands
|
|
77
|
+
if config[:remote_exec]
|
|
78
|
+
if config[:serverspec_command]
|
|
79
|
+
<<-INSTALL
|
|
80
|
+
#{config[:serverspec_command]}
|
|
81
|
+
INSTALL
|
|
82
|
+
else
|
|
83
|
+
<<-INSTALL
|
|
84
|
+
if [ -d #{config[:default_path]} ]; then
|
|
85
|
+
cd #{config[:default_path]}
|
|
86
|
+
#{rspec_commands}
|
|
87
|
+
#{remove_default_path}
|
|
88
|
+
else
|
|
89
|
+
echo "ERROR: Default path '#{config[:default_path]}' does not exist"
|
|
90
|
+
exit 1
|
|
91
|
+
fi
|
|
92
|
+
INSTALL
|
|
93
|
+
end
|
|
94
|
+
elsif config[:serverspec_command]
|
|
95
|
+
info("Running command: #{config[:serverspec_command]}")
|
|
96
|
+
system config[:serverspec_command]
|
|
97
|
+
else
|
|
98
|
+
c = rspec_commands
|
|
99
|
+
info("Running command: #{c}")
|
|
100
|
+
system c
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def install_command
|
|
105
|
+
info('Installing with custom install command') if config[:custom_install_command]
|
|
106
|
+
return config[:custom_install_command] if config[:custom_install_command]
|
|
107
|
+
if config[:remote_exec]
|
|
108
|
+
info('Installing ruby, bundler and serverspec remotely on server')
|
|
109
|
+
<<-INSTALL
|
|
110
|
+
if [ ! $(which ruby) ]; then
|
|
111
|
+
echo '-----> Installing ruby, will try to determine platform os'
|
|
112
|
+
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then
|
|
113
|
+
#{sudo_env('yum')} -y install ruby
|
|
114
|
+
else
|
|
115
|
+
if [ -f /etc/system-release ] || [ grep -q 'Amazon Linux' /etc/system-release ]; then
|
|
116
|
+
#{sudo_env('yum')} -y install ruby
|
|
117
|
+
else
|
|
118
|
+
#{sudo_env('apt-get')} -y install ruby
|
|
119
|
+
fi
|
|
120
|
+
fi
|
|
121
|
+
fi
|
|
122
|
+
#{install_bundler}
|
|
123
|
+
if [ -d #{config[:default_path]} ]; then
|
|
124
|
+
#{install_serverspec}
|
|
125
|
+
#{install_runner}
|
|
126
|
+
else
|
|
127
|
+
echo "ERROR: Default path '#{config[:default_path]}' does not exist"
|
|
128
|
+
exit 1
|
|
129
|
+
fi
|
|
130
|
+
INSTALL
|
|
131
|
+
else
|
|
132
|
+
info('Installing bundler and serverspec locally on workstation')
|
|
133
|
+
install_bundler
|
|
134
|
+
install_serverspec
|
|
135
|
+
install_runner
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# private
|
|
140
|
+
|
|
141
|
+
def install_bundler
|
|
142
|
+
if config[:remote_exec]
|
|
143
|
+
<<-INSTALL
|
|
144
|
+
if [ $(#{sudo('gem')} list bundler -i) == 'false' ]; then
|
|
145
|
+
#{sudo_env('gem')} install #{gem_proxy_parm} --no-ri --no-rdoc bundler
|
|
146
|
+
fi
|
|
147
|
+
INSTALL
|
|
148
|
+
else
|
|
149
|
+
begin
|
|
150
|
+
require 'bundler'
|
|
151
|
+
rescue LoadError
|
|
152
|
+
system `gem install --no-ri --no-rdoc bundler`
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def install_runner
|
|
158
|
+
if config[:require_runner]
|
|
159
|
+
if config[:remote_exec]
|
|
160
|
+
<<-INSTALL
|
|
161
|
+
if [ ! -f #{config[:default_path]}/#{runner_filename} ]; then
|
|
162
|
+
#{sudo_env('curl')} -o #{config[:default_path]}/#{runner_filename} #{config[:runner_url]}
|
|
163
|
+
fi
|
|
164
|
+
INSTALL
|
|
165
|
+
else
|
|
166
|
+
raise ActionFailed, 'Serverspec Runners only for remote execution'
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
172
|
+
def install_serverspec
|
|
173
|
+
bundler_cmd = "#{bundler_path}bundler"
|
|
174
|
+
if config[:remote_exec]
|
|
175
|
+
<<-INSTALL
|
|
176
|
+
#{test_serverspec_installed}
|
|
177
|
+
#{install_gemfile}
|
|
178
|
+
#{sudo_env(bundler_cmd)} install --gemfile=#{config[:default_path]}/Gemfile
|
|
179
|
+
#{fi_test_serverspec_installed}
|
|
180
|
+
INSTALL
|
|
181
|
+
else
|
|
182
|
+
if config[:test_serverspec_installed]
|
|
183
|
+
begin
|
|
184
|
+
require 'serverspec'
|
|
185
|
+
return
|
|
186
|
+
rescue LoadError
|
|
187
|
+
info('serverspec not installed installing ...')
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
unless config[:gemfile]
|
|
191
|
+
gemfile = "#{config[:default_path]}/Gemfile"
|
|
192
|
+
File.open(gemfile, 'w') do |f|
|
|
193
|
+
f.write("source 'https://rubygems.org'\ngem 'net-ssh','~> 2.9.4'\ngem 'serverspec'")
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
gemfile = config[:gemfile] if config[:gemfile]
|
|
197
|
+
begin
|
|
198
|
+
system "#{bundler_cmd} install --gemfile=#{gemfile}"
|
|
199
|
+
rescue
|
|
200
|
+
raise ActionFailed, 'Serverspec install failed'
|
|
201
|
+
end
|
|
202
|
+
nil
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def install_gemfile
|
|
207
|
+
if config[:gemfile]
|
|
208
|
+
<<-INSTALL
|
|
209
|
+
#{read_gemfile}
|
|
210
|
+
INSTALL
|
|
211
|
+
else
|
|
212
|
+
<<-INSTALL
|
|
213
|
+
#{sudo('rm')} -f #{config[:default_path]}/Gemfile
|
|
214
|
+
#{sudo('echo')} "source 'https://rubygems.org'" >> #{config[:default_path]}/Gemfile
|
|
215
|
+
#{sudo('echo')} "gem 'net-ssh','~> 2.9'" >> #{config[:default_path]}/Gemfile
|
|
216
|
+
#{sudo('echo')} "gem 'serverspec'" >> #{config[:default_path]}/Gemfile
|
|
217
|
+
INSTALL
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def read_gemfile
|
|
222
|
+
data = "#{sudo('rm')} -f #{config[:default_path]}/Gemfile\n"
|
|
223
|
+
f = File.open(config[:gemfile], 'r')
|
|
224
|
+
f.each_line do |line|
|
|
225
|
+
data = "#{data}#{sudo('echo')} \"#{line}\" >> #{config[:default_path]}/Gemfile\n"
|
|
226
|
+
end
|
|
227
|
+
f.close
|
|
228
|
+
data
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def remove_default_path
|
|
232
|
+
info('Removing default path') if config[:remove_default_path]
|
|
233
|
+
config[:remove_default_path] ? "rm -rf #{config[:default_path]}" : nil
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def test_serverspec_installed
|
|
237
|
+
config[:test_serverspec_installed] ? "if [ $(#{sudo('gem')} list serverspec -i) == 'false' ]; then" : nil
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def fi_test_serverspec_installed
|
|
241
|
+
config[:test_serverspec_installed] ? 'fi' : nil
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def rspec_commands
|
|
245
|
+
info('Running Serverspec')
|
|
246
|
+
if config[:require_runner]
|
|
247
|
+
"#{env_vars} #{sudo_env(rspec_cmd)} #{color} -f #{config[:format]} --default-path #{config[:default_path]} #{rspec_path_option} #{config[:extra_flags]}"
|
|
248
|
+
else
|
|
249
|
+
config[:patterns].map { |s| "#{env_vars} #{sudo_env(rspec_cmd)} #{color} -f #{config[:format]} --default-path #{config[:default_path]} #{config[:extra_flags]} -P #{s}" }.join('\n')
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def rspec_cmd
|
|
254
|
+
config[:require_runner] ? "ruby #{config[:default_path]}/#{runner_filename}" : "#{rspec_path}rspec"
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def env_vars
|
|
258
|
+
return nil if config[:env_vars].none?
|
|
259
|
+
cmd = nil
|
|
260
|
+
if !config[:remote_exec]
|
|
261
|
+
config[:env_vars].map do |k, v|
|
|
262
|
+
info("Environment variable #{k} value #{v}")
|
|
263
|
+
ENV[k.to_s] = v.to_s
|
|
264
|
+
end
|
|
265
|
+
else
|
|
266
|
+
cmd = config[:env_vars].map { |k, v| "#{k}=#{v}" }.join(' ')
|
|
267
|
+
debug(cmd)
|
|
268
|
+
end
|
|
269
|
+
cmd
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def sudo_env(pm)
|
|
273
|
+
if config[:remote_exec]
|
|
274
|
+
s = https_proxy ? "https_proxy=#{https_proxy}" : nil
|
|
275
|
+
p = http_proxy ? "http_proxy=#{http_proxy}" : nil
|
|
276
|
+
p || s ? "#{sudo('env')} #{p} #{s} #{pm}" : sudo(pm).to_s
|
|
277
|
+
else
|
|
278
|
+
# TODO: handle proxies
|
|
279
|
+
pm
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def bundler_path
|
|
284
|
+
config[:bundler_path] ? "#{config[:bundler_path]}/" : nil
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def rspec_path
|
|
288
|
+
config[:rspec_path] ? "#{config[:rspec_path]}/" : nil
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def rspec_path_option
|
|
292
|
+
config[:rspec_path] ? "--rspec-path #{config[:rspec_path]}/" : nil
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def runner_filename
|
|
296
|
+
File.basename(config[:runner_url])
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def http_proxy
|
|
300
|
+
config[:http_proxy]
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def https_proxy
|
|
304
|
+
config[:https_proxy]
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def gem_proxy_parm
|
|
308
|
+
http_proxy ? "--http-proxy #{http_proxy}" : nil
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def color
|
|
312
|
+
config[:color] ? '-c' : nil
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# Sleep for a period of time, if a value is set in the config.
|
|
316
|
+
#
|
|
317
|
+
# @api private
|
|
318
|
+
def sleep_if_set
|
|
319
|
+
config[:sleep].to_i.times do
|
|
320
|
+
print '.'
|
|
321
|
+
sleep 1
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def shellout(command)
|
|
326
|
+
info("Running command: #{command}")
|
|
327
|
+
cmd = Mixlib::ShellOut.new(command, config[:shellout_opts])
|
|
328
|
+
cmd.live_stream = config[:live_stream]
|
|
329
|
+
cmd.run_command
|
|
330
|
+
begin
|
|
331
|
+
cmd.error!
|
|
332
|
+
rescue Mixlib::ShellOut::ShellCommandFailed
|
|
333
|
+
raise ActionFailed, "Action #verify failed for #{instance.to_str}."
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def merge_state_to_env(state)
|
|
338
|
+
env_state = { :environment => {} }
|
|
339
|
+
env_state[:environment]['KITCHEN_INSTANCE'] = instance.name
|
|
340
|
+
env_state[:environment]['KITCHEN_PLATFORM'] = instance.platform.name
|
|
341
|
+
env_state[:environment]['KITCHEN_SUITE'] = instance.suite.name
|
|
342
|
+
state.each_pair do |key, value|
|
|
343
|
+
env_state[:environment]['KITCHEN_' + key.to_s.upcase] = value
|
|
344
|
+
end
|
|
345
|
+
config[:shellout_opts].merge!(env_state)
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
module Kitchen
|
|
4
|
-
module Verifier
|
|
5
|
-
SERVERSPEC_VERSION = '0.3.
|
|
6
|
-
end
|
|
7
|
-
end
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Kitchen
|
|
4
|
+
module Verifier
|
|
5
|
+
SERVERSPEC_VERSION = '0.3.1'.freeze
|
|
6
|
+
end
|
|
7
|
+
end
|
metadata
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-verifier-serverspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
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-03-
|
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.4'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.4'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: net-ssh
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '2.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '2.0'
|
|
41
41
|
description: |
|
|
@@ -60,17 +60,17 @@ require_paths:
|
|
|
60
60
|
- lib
|
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
62
|
requirements:
|
|
63
|
-
- -
|
|
63
|
+
- - ">="
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: '0'
|
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
requirements:
|
|
68
|
-
- -
|
|
68
|
+
- - ">="
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
70
|
version: '0'
|
|
71
71
|
requirements: []
|
|
72
|
-
rubyforge_project:
|
|
73
|
-
rubygems_version: 2.
|
|
72
|
+
rubyforge_project: "[none]"
|
|
73
|
+
rubygems_version: 2.2.2
|
|
74
74
|
signing_key:
|
|
75
75
|
specification_version: 4
|
|
76
76
|
summary: Serverspec verifier for Test-Kitchen without having to transit the Busser
|