kitchen-ansible 0.49.0 → 0.49.1

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
- SHA256:
3
- metadata.gz: 8a3a081e05d3e114eee73aabc00ba27a7a23d5811ae2a7fec5795dd9caeaeff4
4
- data.tar.gz: 7de303e363b104022de49f799bf289d9c834df47843430e15c48fc2dfac02e45
2
+ SHA1:
3
+ metadata.gz: 9026d3e0ba4cf8598fe03a11139e375de048cadc
4
+ data.tar.gz: 28d53d48ad51159e185d5801dbb1b0d8b9f10405
5
5
  SHA512:
6
- metadata.gz: fbba53a30ad0afbde098f019544777e94a0a323bfa04a33612671a623f26cd137c180c7bbe6b4acd929ee3cb4c7d1daa15b866f1bc87a2bbdad92172e8954155
7
- data.tar.gz: f764da95bd4668f28ef81d57e240ad60181cf9c14ca0006af737d5b90f35deb77ee7dfd0ad4cb6b7dcf1584cf74dfe36eb1b79dfce6936cd6a1c6b2b4f769a38
6
+ metadata.gz: 6e0076c0baf4dd3f91deb5b4155efad182f65fc76c4f1e0e5b2c43a9aff8ef2651d19e9ae287c9f3b9ba7b7b17e2c41a134d1ac5e8b18c9be432af9ca0006eda
7
+ data.tar.gz: 4418c12afd4d2107a22effb7a0592016f7bf45c2db382c17b4597aff4a65c1b84db6e61bad8de54978aed37988ff632c1754f08d7180c63a5319c4c70f91b0b9
data/README.md CHANGED
@@ -1,270 +1,270 @@
1
- # kitchen-ansible
2
-
3
- [![Gem Version](https://badge.fury.io/rb/kitchen-ansible.svg)](http://badge.fury.io/rb/kitchen-ansible)
4
- [![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/kitchen-ansible?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-ansible)
5
- [![Build Status](https://travis-ci.org/neillturner/kitchen-ansible.png)](https://travis-ci.org/neillturner/kitchen-ansible)
6
-
7
- A Test Kitchen Provisioner for Ansible.
8
-
9
- The provisioner works by passing the Ansible repository based on attributes in `.kitchen.yml` & calling `ansible-playbook`.
10
-
11
- It installs Ansible on the server and runs `ansible-playbook` using host localhost.
12
-
13
- It has been tested against the Ubuntu 12.04/14.04/16.04, Centos 6/7 and Debian 6/7/8 boxes running in vagrant/virtualbox.
14
-
15
- ## Requirements
16
- - [Test Kitchen](https://github.com/test-kitchen/test-kitchen).
17
- - a driver box without a Chef installation so Ansible can be installed.
18
-
19
- ## Installation & Setup
20
-
21
- 1. install the latest Ruby on your workstation (for windows see https://rubyinstaller.org/downloads/)
22
-
23
- 2. If using Ruby version less than 2.3 first install earlier version of test-kitchen
24
- ```
25
- gem install test-kitchen -v 1.16.0
26
- ```
27
- 3. Install the `kitchen-ansible` gem in your system, along with [kitchen-vagrant](https://github.com/test-kitchen/kitchen-vagrant) or [kitchen-docker](https://github.com/test-kitchen/kitchen-docker) or any other suitable driver or the exec driver to run from your workstation:
28
-
29
- ```
30
- gem install kitchen-ansible
31
- gem install kitchen-vagrant
32
- ```
33
-
34
-
35
-
36
- ## Resources
37
- * https://blog.superk.org/home/ansible-role-development
38
- * https://alexharv074.github.io/2016/05/25/testing-an-ansible-role-using-test-kitchen.html
39
- * https://alexharv074.github.io/2016/06/13/integration-testing-using-ansible-and-test-kitchen.html
40
- * https://github.com/MattHodge/ansible-testkitchen-windows
41
- * https://readme.fr/continuous-integration-for-ansible/
42
- * https://dantehranian.wordpress.com/2015/06/18/testing-ansible-roles-with-test-kitchen
43
- * http://www.slideshare.net/MartinEtmajer/testing-ansible-roles-with-test-kitchen-serverspec-and-rspec-48185017
44
- * http://blog.el-chavez.me/2016/02/16/ansible-galaxy-test-kitchen
45
- * https://werner-dijkerman.nl/2015/08/20/using-test-kitchen-with-docker-and-serverspec-to-test-ansible-roles
46
- * https://books.google.co.uk/books?id=D-wmDQAAQBAJ&pg=PA129&lpg
47
-
48
- ## Example .kitchen.yml file
49
-
50
- Based on the [Tomcat Standalone](https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone) example:
51
-
52
- ```yaml
53
- ---
54
- driver:
55
- name: vagrant
56
-
57
- provisioner:
58
- name: ansible_playbook
59
- roles_path: roles
60
- hosts: tomcat-servers
61
- require_ansible_repo: true
62
- ansible_verbose: true
63
- ansible_version: latest
64
- require_chef_for_busser: false
65
- additional_ssh_private_keys:
66
- - /mykey/id_rsa
67
-
68
- platforms:
69
- - name: nocm_centos-6.5
70
- driver_plugin: vagrant
71
- driver_config:
72
- box: nocm_centos-6.5
73
- box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
74
- network:
75
- - ['forwarded_port', {guest: 8080, host: 8080}]
76
- - ['private_network', {ip: '192.168.33.11'}]
77
- ```
78
-
79
- See example [https://github.com/neillturner/ansible_repo](https://github.com/neillturner/ansible_repo)
80
-
81
- ## Windows Support
82
-
83
- Windows is supported by creating a linux server to run Ansible with software required to support winrm. Then the winrm connection is used to configure the windows server.
84
-
85
- In `.kitchen.yml` set:
86
-
87
- ```yaml
88
- ansible_connection: winrm
89
- require_windows_support: true
90
- require_chef_for_busser: false
91
- ```
92
-
93
- See the [Ansible Windows repo](https://github.com/neillturner/ansible_windows_repo) example.
94
-
95
- ## Test Kitchen Exec Driver
96
-
97
- By using the test-kitchen exec driver ansible can be driven from your workstation. This provides similar functionality to [kitchen-ansiblepush](https://github.com/ahelal/kitchen-ansiblepush). Remote servers, as specified in the ansible inventory, can be built with ansible automatically installed and run from your workstation.
98
-
99
- See example [https://github.com/neillturner/ansible_exec_repo](https://github.com/neillturner/ansible_exec_repo)
100
-
101
- ## Ansible AWX
102
-
103
- Kitchen ansible supports installing and using the open source version of Ansible Tower [Ansible AWX](https://github.com/ansible/awx) on a Centos 7. In future it will support the tower-cli for testing.
104
-
105
- See example [https://github.com/neillturner/ansible_awx_repo](https://github.com/neillturner/ansible_awx_repo)
106
-
107
- ## Using Roles from Ansible Galaxy
108
-
109
- Roles can be used from the Ansible Galaxy using two methods:
110
-
111
- 1. Specify a `requirements.yml` file in your Ansible repository. For more details see [here](http://docs.ansible.com/ansible/galaxy.html).
112
-
113
- 2. Use `librarian-ansible` by creating an `Ansiblefile` in the top level of the repository and `kitchen-ansible` will automatically call `librarian-ansible` during convergence. For a description of setting up an `Ansiblefile` see [here](https://werner-dijkerman.nl/2015/08/15/using-librarian-ansible-to-install-ansible-roles-from-gitlab/).
114
-
115
- ## Tips
116
-
117
- To use a single ~/.kitchen/config.yml file with multiple reposities by setting the WORKSPACE environment variable:
118
-
119
- ```yaml
120
- role_path: <%= ENV['WORKSPACE'] %>/roles
121
- ```
122
-
123
- You can easily skip previous instructions and jump directly to the broken statement you just fixed by passing an environment variable. Add the following to your `.kitchen.yml`:
124
-
125
- ```yaml
126
- provisioner:
127
- name: ansible_playbook
128
- ansible_extra_flags: <%= ENV['ANSIBLE_EXTRA_FLAGS'] %>
129
- ```
130
-
131
- Then run:
132
-
133
- ```
134
- $ ANSIBLE_EXTRA_FLAGS='--start-at-task="myrole | name of last working instruction"' kitchen converge
135
- ```
136
-
137
- You save a lot of time not running working instructions.
138
-
139
-
140
- ## Ruby install to run Serverspec verify
141
-
142
- By default test-kitchen installs Chef to get a Ruby version suitable to run Serverspec in the `verify` step.
143
- kitchen-verifier-serverspec installs its own ruby version so chef or ruby is not required to verify with serverspec :
144
-
145
- ```yaml
146
- require_chef_for_busser: false
147
- ```
148
- And set the verifier section:
149
- ```yaml
150
- verifier:
151
- name: serverspec
152
- sudo_path: true
153
-
154
- suites:
155
- - name: ansible
156
- driver_config:
157
- hostname: '54.229.34.169'
158
- verifier:
159
- patterns:
160
- - roles/tomcat/spec/tomcat_spec.rb
161
- bundler_path: '/usr/local/bin'
162
- rspec_path: '/usr/local/bin'
163
- env_vars:
164
- TARGET_HOST: 54.229.104.40
165
- LOGIN_USER: centos
166
- SUDO: true
167
- SSH_KEY: spec/test.pem
168
- ```
169
-
170
- Please see the [Provisioner Options](https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md) for a complete listing.
171
-
172
- ## Test-Kitchen Ansiblespec
173
-
174
- By using kitchen-verifier-serverspec and the Runner ansiblespec_runner tests can be run against multiple servers with multiple roles in the ansiblespec format.
175
-
176
- Serverspec uses ssh to communicate with the server to be tested and reads the Ansible playbook and inventory files to determine the hosts to test and the roles for each host.
177
-
178
- See example [https://github.com/neillturner/ansible_ansiblespec_repo](https://github.com/neillturner/ansible_ansiblespec_repo)
179
-
180
- ### Example usage to create Tomcat servers:
181
-
182
- ![test-kitchen, Ansible and ansiblespec](https://github.com/neillturner/ansible_repo/blob/master/kitchen-ansible.png "test-kitchen, ansible and ansiblespec")
183
-
184
- See [ansible-sample-tdd](https://github.com/volanja/ansible-sample-tdd).
185
-
186
- ### Usage
187
-
188
- #### Directory
189
-
190
- In the Ansible repository specify:
191
-
192
- * spec files with the roles.
193
- * spec_helper in the spec folder (with code as below).
194
-
195
- ```
196
- .
197
- +-- roles
198
- ¦   +-- mariadb
199
- ¦   ¦   +-- spec
200
- ¦   ¦   ¦   +-- mariadb_spec.rb
201
- ¦   ¦   +-- tasks
202
- ¦   ¦   ¦   +-- main.yml
203
- ¦   ¦   +-- templates
204
- ¦   ¦   +-- mariadb.repo
205
- ¦   +-- nginx
206
- ¦   +-- handlers
207
- ¦   ¦   +-- main.yml
208
- ¦   +-- spec
209
- ¦   ¦   +-- nginx_spec.rb
210
- ¦   +-- tasks
211
- ¦   ¦   +-- main.yml
212
- ¦   +-- templates
213
- ¦   ¦   +-- nginx.repo
214
- ¦   +-- vars
215
- ¦   +-- main.yml
216
- +-- spec
217
- +-- spec_helper.rb
218
- +-- my_private_key.pem
219
- ```
220
-
221
-
222
- #### spec_helper
223
-
224
- ```ruby
225
- require 'rubygems'
226
- require 'bundler/setup'
227
-
228
- require 'serverspec'
229
- require 'pathname'
230
- require 'net/ssh'
231
-
232
- RSpec.configure do |config|
233
- set :host, ENV['TARGET_HOST']
234
- # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
235
- # ssh via password
236
- set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
237
- # ssh via ssh key
238
- set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
239
- set :backend, :ssh
240
- set :request_pty, true
241
- end
242
- ```
243
-
244
- See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec).
245
-
246
- ## Alternative Virtualization/Cloud providers for Vagrant
247
- This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
248
- ```yaml
249
- platforms:
250
- - name: ubuntu-12.04
251
- driver_config:
252
- provider: aws
253
- box: my_base_box
254
- # username is based on what is configured in your box/ami
255
- username: ubuntu
256
- customize:
257
- access_key_id: 'AKKJHG659868LHGLH'
258
- secret_access_key: 'G8t7o+6HLG876JGF/58'
259
- ami: ami-7865ab765d
260
- instance_type: t2.micro
261
- # more customisation can go here, based on what the vagrant provider supports
262
- #security-groups: []
263
- ```
264
-
265
- ## Notes
266
-
267
- * The `default` in all of the above is the name of the test suite defined in the `suites` section of your `.kitchen.yml`, so if you have more than one suite of tests or change the name, you'll need to adapt the example accordingly.
268
- * Serverspec test files *must* be named `_spec.rb`
269
- * Since I'm using Vagrant, my `box` definitions refer to Vagrant boxes, either standard, published boxes available from [Atlas](http://atlas.hashicorp.com/boxes) or custom-created boxes (perhaps using [Packer](http://packer.io) and [bento](https://github.com/chef/bento), in which case you'll need to provide the URL in `box_url`.
270
-
1
+ # kitchen-ansible
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/kitchen-ansible.svg)](http://badge.fury.io/rb/kitchen-ansible)
4
+ [![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/kitchen-ansible?type=total&color=brightgreen)](https://rubygems.org/gems/kitchen-ansible)
5
+ [![Build Status](https://travis-ci.org/neillturner/kitchen-ansible.png)](https://travis-ci.org/neillturner/kitchen-ansible)
6
+
7
+ A Test Kitchen Provisioner for Ansible.
8
+
9
+ The provisioner works by passing the Ansible repository based on attributes in `.kitchen.yml` & calling `ansible-playbook`.
10
+
11
+ It installs Ansible on the server and runs `ansible-playbook` using host localhost.
12
+
13
+ It has been tested against the Ubuntu 12.04/14.04/16.04, Centos 6/7 and Debian 6/7/8 boxes running in vagrant/virtualbox.
14
+
15
+ ## Requirements
16
+ - [Test Kitchen](https://github.com/test-kitchen/test-kitchen).
17
+ - a driver box without a Chef installation so Ansible can be installed.
18
+
19
+ ## Installation & Setup
20
+
21
+ 1. install the latest Ruby on your workstation (for windows see https://rubyinstaller.org/downloads/)
22
+
23
+ 2. If using Ruby version less than 2.3 first install earlier version of test-kitchen
24
+ ```
25
+ gem install test-kitchen -v 1.16.0
26
+ ```
27
+ 3. Install the `kitchen-ansible` gem in your system, along with [kitchen-vagrant](https://github.com/test-kitchen/kitchen-vagrant) or [kitchen-docker](https://github.com/test-kitchen/kitchen-docker) or any other suitable driver or the exec driver to run from your workstation:
28
+
29
+ ```
30
+ gem install kitchen-ansible
31
+ gem install kitchen-vagrant
32
+ ```
33
+
34
+
35
+
36
+ ## Resources
37
+ * https://blog.superk.org/home/ansible-role-development
38
+ * https://alexharv074.github.io/2016/05/25/testing-an-ansible-role-using-test-kitchen.html
39
+ * https://alexharv074.github.io/2016/06/13/integration-testing-using-ansible-and-test-kitchen.html
40
+ * https://github.com/MattHodge/ansible-testkitchen-windows
41
+ * https://readme.fr/continuous-integration-for-ansible/
42
+ * https://dantehranian.wordpress.com/2015/06/18/testing-ansible-roles-with-test-kitchen
43
+ * http://www.slideshare.net/MartinEtmajer/testing-ansible-roles-with-test-kitchen-serverspec-and-rspec-48185017
44
+ * http://blog.el-chavez.me/2016/02/16/ansible-galaxy-test-kitchen
45
+ * https://werner-dijkerman.nl/2015/08/20/using-test-kitchen-with-docker-and-serverspec-to-test-ansible-roles
46
+ * https://books.google.co.uk/books?id=D-wmDQAAQBAJ&pg=PA129&lpg
47
+
48
+ ## Example .kitchen.yml file
49
+
50
+ Based on the [Tomcat Standalone](https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone) example:
51
+
52
+ ```yaml
53
+ ---
54
+ driver:
55
+ name: vagrant
56
+
57
+ provisioner:
58
+ name: ansible_playbook
59
+ roles_path: roles
60
+ hosts: tomcat-servers
61
+ require_ansible_repo: true
62
+ ansible_verbose: true
63
+ ansible_version: latest
64
+ require_chef_for_busser: false
65
+ additional_ssh_private_keys:
66
+ - /mykey/id_rsa
67
+
68
+ platforms:
69
+ - name: nocm_centos-6.5
70
+ driver_plugin: vagrant
71
+ driver_config:
72
+ box: nocm_centos-6.5
73
+ box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
74
+ network:
75
+ - ['forwarded_port', {guest: 8080, host: 8080}]
76
+ - ['private_network', {ip: '192.168.33.11'}]
77
+ ```
78
+
79
+ See example [https://github.com/neillturner/ansible_repo](https://github.com/neillturner/ansible_repo)
80
+
81
+ ## Windows Support
82
+
83
+ Windows is supported by creating a linux server to run Ansible with software required to support winrm. Then the winrm connection is used to configure the windows server.
84
+
85
+ In `.kitchen.yml` set:
86
+
87
+ ```yaml
88
+ ansible_connection: winrm
89
+ require_windows_support: true
90
+ require_chef_for_busser: false
91
+ ```
92
+
93
+ See the [Ansible Windows repo](https://github.com/neillturner/ansible_windows_repo) example.
94
+
95
+ ## Test Kitchen Exec Driver
96
+
97
+ By using the test-kitchen exec driver ansible can be driven from your workstation. This provides similar functionality to [kitchen-ansiblepush](https://github.com/ahelal/kitchen-ansiblepush). Remote servers, as specified in the ansible inventory, can be built with ansible automatically installed and run from your workstation.
98
+
99
+ See example [https://github.com/neillturner/ansible_exec_repo](https://github.com/neillturner/ansible_exec_repo)
100
+
101
+ ## Ansible AWX
102
+
103
+ Kitchen ansible supports installing and using the open source version of Ansible Tower [Ansible AWX](https://github.com/ansible/awx) on a Centos 7. In future it will support the tower-cli for testing.
104
+
105
+ See example [https://github.com/neillturner/ansible_awx_repo](https://github.com/neillturner/ansible_awx_repo)
106
+
107
+ ## Using Roles from Ansible Galaxy
108
+
109
+ Roles can be used from the Ansible Galaxy using two methods:
110
+
111
+ 1. Specify a `requirements.yml` file in your Ansible repository. For more details see [here](http://docs.ansible.com/ansible/galaxy.html).
112
+
113
+ 2. Use `librarian-ansible` by creating an `Ansiblefile` in the top level of the repository and `kitchen-ansible` will automatically call `librarian-ansible` during convergence. For a description of setting up an `Ansiblefile` see [here](https://werner-dijkerman.nl/2015/08/15/using-librarian-ansible-to-install-ansible-roles-from-gitlab/).
114
+
115
+ ## Tips
116
+
117
+ To use a single ~/.kitchen/config.yml file with multiple reposities by setting the WORKSPACE environment variable:
118
+
119
+ ```yaml
120
+ role_path: <%= ENV['WORKSPACE'] %>/roles
121
+ ```
122
+
123
+ You can easily skip previous instructions and jump directly to the broken statement you just fixed by passing an environment variable. Add the following to your `.kitchen.yml`:
124
+
125
+ ```yaml
126
+ provisioner:
127
+ name: ansible_playbook
128
+ ansible_extra_flags: <%= ENV['ANSIBLE_EXTRA_FLAGS'] %>
129
+ ```
130
+
131
+ Then run:
132
+
133
+ ```
134
+ $ ANSIBLE_EXTRA_FLAGS='--start-at-task="myrole | name of last working instruction"' kitchen converge
135
+ ```
136
+
137
+ You save a lot of time not running working instructions.
138
+
139
+
140
+ ## Ruby install to run Serverspec verify
141
+
142
+ By default test-kitchen installs Chef to get a Ruby version suitable to run Serverspec in the `verify` step.
143
+ kitchen-verifier-serverspec installs its own ruby version so chef or ruby is not required to verify with serverspec :
144
+
145
+ ```yaml
146
+ require_chef_for_busser: false
147
+ ```
148
+ And set the verifier section:
149
+ ```yaml
150
+ verifier:
151
+ name: serverspec
152
+ sudo_path: true
153
+
154
+ suites:
155
+ - name: ansible
156
+ driver_config:
157
+ hostname: '54.229.34.169'
158
+ verifier:
159
+ patterns:
160
+ - roles/tomcat/spec/tomcat_spec.rb
161
+ bundler_path: '/usr/local/bin'
162
+ rspec_path: '/usr/local/bin'
163
+ env_vars:
164
+ TARGET_HOST: 54.229.104.40
165
+ LOGIN_USER: centos
166
+ SUDO: true
167
+ SSH_KEY: spec/test.pem
168
+ ```
169
+
170
+ Please see the [Provisioner Options](https://github.com/neillturner/kitchen-ansible/blob/master/provisioner_options.md) for a complete listing.
171
+
172
+ ## Test-Kitchen Ansiblespec
173
+
174
+ By using kitchen-verifier-serverspec and the Runner ansiblespec_runner tests can be run against multiple servers with multiple roles in the ansiblespec format.
175
+
176
+ Serverspec uses ssh to communicate with the server to be tested and reads the Ansible playbook and inventory files to determine the hosts to test and the roles for each host.
177
+
178
+ See example [https://github.com/neillturner/ansible_ansiblespec_repo](https://github.com/neillturner/ansible_ansiblespec_repo)
179
+
180
+ ### Example usage to create Tomcat servers:
181
+
182
+ ![test-kitchen, Ansible and ansiblespec](https://github.com/neillturner/ansible_repo/blob/master/kitchen-ansible.png "test-kitchen, ansible and ansiblespec")
183
+
184
+ See [ansible-sample-tdd](https://github.com/volanja/ansible-sample-tdd).
185
+
186
+ ### Usage
187
+
188
+ #### Directory
189
+
190
+ In the Ansible repository specify:
191
+
192
+ * spec files with the roles.
193
+ * spec_helper in the spec folder (with code as below).
194
+
195
+ ```
196
+ .
197
+ +-- roles
198
+ ¦   +-- mariadb
199
+ ¦   ¦   +-- spec
200
+ ¦   ¦   ¦   +-- mariadb_spec.rb
201
+ ¦   ¦   +-- tasks
202
+ ¦   ¦   ¦   +-- main.yml
203
+ ¦   ¦   +-- templates
204
+ ¦   ¦   +-- mariadb.repo
205
+ ¦   +-- nginx
206
+ ¦   +-- handlers
207
+ ¦   ¦   +-- main.yml
208
+ ¦   +-- spec
209
+ ¦   ¦   +-- nginx_spec.rb
210
+ ¦   +-- tasks
211
+ ¦   ¦   +-- main.yml
212
+ ¦   +-- templates
213
+ ¦   ¦   +-- nginx.repo
214
+ ¦   +-- vars
215
+ ¦   +-- main.yml
216
+ +-- spec
217
+ +-- spec_helper.rb
218
+ +-- my_private_key.pem
219
+ ```
220
+
221
+
222
+ #### spec_helper
223
+
224
+ ```ruby
225
+ require 'rubygems'
226
+ require 'bundler/setup'
227
+
228
+ require 'serverspec'
229
+ require 'pathname'
230
+ require 'net/ssh'
231
+
232
+ RSpec.configure do |config|
233
+ set :host, ENV['TARGET_HOST']
234
+ # ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
235
+ # ssh via password
236
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :password => ENV['LOGIN_PASSWORD'] if ENV['LOGIN_PASSWORD']
237
+ # ssh via ssh key
238
+ set :ssh_options, :user => ENV['LOGIN_USER'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['SSH_KEY'] ] if ENV['SSH_KEY']
239
+ set :backend, :ssh
240
+ set :request_pty, true
241
+ end
242
+ ```
243
+
244
+ See [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec).
245
+
246
+ ## Alternative Virtualization/Cloud providers for Vagrant
247
+ This could be adapted to use alternative virtualization/cloud providers such as Openstack/AWS/VMware Fusion according to whatever is supported by Vagrant.
248
+ ```yaml
249
+ platforms:
250
+ - name: ubuntu-12.04
251
+ driver_config:
252
+ provider: aws
253
+ box: my_base_box
254
+ # username is based on what is configured in your box/ami
255
+ username: ubuntu
256
+ customize:
257
+ access_key_id: 'AKKJHG659868LHGLH'
258
+ secret_access_key: 'G8t7o+6HLG876JGF/58'
259
+ ami: ami-7865ab765d
260
+ instance_type: t2.micro
261
+ # more customisation can go here, based on what the vagrant provider supports
262
+ #security-groups: []
263
+ ```
264
+
265
+ ## Notes
266
+
267
+ * The `default` in all of the above is the name of the test suite defined in the `suites` section of your `.kitchen.yml`, so if you have more than one suite of tests or change the name, you'll need to adapt the example accordingly.
268
+ * Serverspec test files *must* be named `_spec.rb`
269
+ * Since I'm using Vagrant, my `box` definitions refer to Vagrant boxes, either standard, published boxes available from [Atlas](http://atlas.hashicorp.com/boxes) or custom-created boxes (perhaps using [Packer](http://packer.io) and [bento](https://github.com/chef/bento), in which case you'll need to provide the URL in `box_url`.
270
+