kitchen-ec2 0.7.0 → 0.8.0
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/.cane +1 -0
- data/.tailor +1 -1
- data/CHANGELOG.md +44 -1
- data/Gemfile +1 -0
- data/README.md +77 -72
- data/kitchen-ec2.gemspec +4 -3
- data/lib/kitchen/driver/ec2.rb +44 -11
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- data/spec/create_spec.rb +106 -0
- metadata +41 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3897a853bbce0fe66db106da6852004cc39e6bc
|
|
4
|
+
data.tar.gz: 804747d7bf806717e31e4b6ac946497ee3aaf935
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eec29c52770a4d005cf1a2769cc131f25cd351591075108ebe745a954b2e6243d30ebdf9cd87848b03321dcca124f80cae0861cec9aa5e193ee36cabf649cdb5
|
|
7
|
+
data.tar.gz: b53ed98bc1d2419f90b65114fe0db08db33f036d1e222e4dbbef9e791e396e6704492b58ddf1b9da406703a47e845e88f2efacde5cab3fdf7b3717388e7709f7
|
data/.cane
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--style-measure 100
|
data/.tailor
CHANGED
|
@@ -90,7 +90,7 @@ Tailor.config do |config|
|
|
|
90
90
|
style.indentation_spaces 2, level: :error
|
|
91
91
|
style.max_code_lines_in_class 300, level: :error
|
|
92
92
|
style.max_code_lines_in_method 30, level: :error
|
|
93
|
-
style.max_line_length
|
|
93
|
+
style.max_line_length 100, level: :error
|
|
94
94
|
style.spaces_after_comma 1, level: :off
|
|
95
95
|
style.spaces_after_lbrace 1, level: :error
|
|
96
96
|
style.spaces_after_lbracket 0, level: :error
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
## 0.8.0 / 2014-02-11
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
* Pull request [#29][], pull request [#28][]: Relax Test Kitchen dependency to allow versions 1.0 and up. ([@coderanger][], [@someara][])
|
|
6
|
+
|
|
7
|
+
## New features
|
|
8
|
+
|
|
9
|
+
* Pull request [#29][]: Add `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` fallback environment variable support. ([@coderanger][])
|
|
10
|
+
* Pull request [#27][], pull request [#31][]: Make EC2 endpoint configurable for services implementing the AWS APIs. ([@bozinsky][], [@spheromak][])
|
|
11
|
+
* Pull request [#34][]: Support AWS session tokens for use with IAM roles. ([@coderanger][])
|
|
12
|
+
* Pull request [#22][]: Add ebs_optimized attribute. ([@tiwilliam][])
|
|
13
|
+
|
|
14
|
+
### Improvements
|
|
15
|
+
|
|
16
|
+
* Pull request [#20][], pull request [#21][], issue [#14][]: Add configurability around whether to use DNS name, public or private IP addresses when connecting to instances. ([@matheeeny][], [@Atalanta][], [@fnichol][])
|
|
17
|
+
* Pull request [#15][]: In VPC groups must be specified by setting :security_group_ids rather than :groups. ([@eherot][])
|
|
18
|
+
* Pull request [#23][]: README updates for badges. ([@sethvargo][], [@arangamani][])
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
## 0.7.0 / 2013-08-29
|
|
2
22
|
|
|
3
23
|
### Bug fixes
|
|
4
24
|
|
|
5
|
-
* Pull request #13: #wait_for_ssh takes 2 arguments. (@dysinger)
|
|
25
|
+
* Pull request [#13][]: #wait_for_ssh takes 2 arguments. ([@dysinger][])
|
|
6
26
|
|
|
7
27
|
### Improvements
|
|
8
28
|
|
|
@@ -46,8 +66,31 @@
|
|
|
46
66
|
[#7]: https://github.com/opscode/kitchen-ec2/issues/7
|
|
47
67
|
[#8]: https://github.com/opscode/kitchen-ec2/issues/8
|
|
48
68
|
[#9]: https://github.com/opscode/kitchen-ec2/issues/9
|
|
69
|
+
[#13]: https://github.com/opscode/kitchen-ec2/issues/13
|
|
70
|
+
[#14]: https://github.com/opscode/kitchen-ec2/issues/14
|
|
71
|
+
[#15]: https://github.com/opscode/kitchen-ec2/issues/15
|
|
72
|
+
[#20]: https://github.com/opscode/kitchen-ec2/issues/20
|
|
73
|
+
[#21]: https://github.com/opscode/kitchen-ec2/issues/21
|
|
74
|
+
[#22]: https://github.com/opscode/kitchen-ec2/issues/22
|
|
75
|
+
[#23]: https://github.com/opscode/kitchen-ec2/issues/23
|
|
76
|
+
[#27]: https://github.com/opscode/kitchen-ec2/issues/27
|
|
77
|
+
[#28]: https://github.com/opscode/kitchen-ec2/issues/28
|
|
78
|
+
[#29]: https://github.com/opscode/kitchen-ec2/issues/29
|
|
79
|
+
[#31]: https://github.com/opscode/kitchen-ec2/issues/31
|
|
80
|
+
[#34]: https://github.com/opscode/kitchen-ec2/issues/34
|
|
81
|
+
[@Atalanta]: https://github.com/Atalanta
|
|
82
|
+
[@arangamani]: https://github.com/arangamani
|
|
83
|
+
[@bozinsky]: https://github.com/bozinsky
|
|
84
|
+
[@coderanger]: https://github.com/coderanger
|
|
49
85
|
[@dissonanz]: https://github.com/dissonanz
|
|
86
|
+
[@dysinger]: https://github.com/dysinger
|
|
87
|
+
[@eherot]: https://github.com/eherot
|
|
50
88
|
[@fnichol]: https://github.com/fnichol
|
|
51
89
|
[@halcyonCorsair]: https://github.com/halcyonCorsair
|
|
52
90
|
[@juliandunn]: https://github.com/juliandunn
|
|
91
|
+
[@matheeeny]: https://github.com/matheeeny
|
|
53
92
|
[@mattray]: https://github.com/mattray
|
|
93
|
+
[@sethvargo]: https://github.com/sethvargo
|
|
94
|
+
[@someara]: https://github.com/someara
|
|
95
|
+
[@spheromak]: https://github.com/spheromak
|
|
96
|
+
[@tiwilliam]: https://github.com/tiwilliam
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# <a name="title"></a> Kitchen::Ec2: A Test Kitchen Driver for Amazon EC2
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/kitchen-ec2)
|
|
4
|
-
[](https://travis-ci.org/test-kitchen/kitchen-ec2)
|
|
5
|
+
[](https://codeclimate.com/github/test-kitchen/kitchen-ec2)
|
|
6
6
|
|
|
7
|
-
A Test Kitchen Driver for Amazon EC2.
|
|
7
|
+
A [Test Kitchen][kitchenci] Driver for Amazon EC2.
|
|
8
8
|
|
|
9
9
|
This driver uses the [fog gem][fog_gem] to provision and destroy EC2
|
|
10
10
|
instances. Use Amazon's cloud for your infrastructure testing!
|
|
@@ -27,12 +27,12 @@ supported:
|
|
|
27
27
|
```ruby
|
|
28
28
|
---
|
|
29
29
|
platforms:
|
|
30
|
-
- name: ubuntu-10.04
|
|
31
|
-
- name: ubuntu-12.04
|
|
32
|
-
- name: ubuntu-12.10
|
|
33
|
-
- name: ubuntu-13.04
|
|
34
|
-
- name: centos-6.4
|
|
35
|
-
- name: debian-7.1.0
|
|
30
|
+
- name: ubuntu-10.04
|
|
31
|
+
- name: ubuntu-12.04
|
|
32
|
+
- name: ubuntu-12.10
|
|
33
|
+
- name: ubuntu-13.04
|
|
34
|
+
- name: centos-6.4
|
|
35
|
+
- name: debian-7.1.0
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
This will effectively generate a configuration similar to:
|
|
@@ -40,20 +40,20 @@ This will effectively generate a configuration similar to:
|
|
|
40
40
|
```ruby
|
|
41
41
|
---
|
|
42
42
|
platforms:
|
|
43
|
-
- name: ubuntu-10.04
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- name: ubuntu-12.04
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# ...
|
|
52
|
-
- name: centos-6.4
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# ...
|
|
43
|
+
- name: ubuntu-10.04
|
|
44
|
+
driver:
|
|
45
|
+
image_id: ami-1ab3ce73
|
|
46
|
+
username: ubuntu
|
|
47
|
+
- name: ubuntu-12.04
|
|
48
|
+
driver:
|
|
49
|
+
image_id: ami-2f115c46
|
|
50
|
+
username: ubuntu
|
|
51
|
+
# ...
|
|
52
|
+
- name: centos-6.4
|
|
53
|
+
driver:
|
|
54
|
+
image_id: ami-bf5021d6
|
|
55
|
+
username: root
|
|
56
|
+
# ...
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
For specific default values, please consult [amis.json][amis_json].
|
|
@@ -87,15 +87,29 @@ or `nil` otherwise.
|
|
|
87
87
|
The default will be read from the `AWS_SSH_KEY_ID` environment variable if set,
|
|
88
88
|
or `nil` otherwise.
|
|
89
89
|
|
|
90
|
+
### endpoint
|
|
91
|
+
|
|
92
|
+
The API endpoint for executing EC2 commands.
|
|
93
|
+
|
|
94
|
+
The default will be computed from the AWS region name for the instance.
|
|
95
|
+
|
|
90
96
|
### <a name="config-flavor-id"></a> flavor\_id
|
|
91
97
|
|
|
92
98
|
The EC2 [instance type][instance_docs] (also known as size) to use.
|
|
93
99
|
|
|
94
100
|
The default is `"m1.small"`.
|
|
95
101
|
|
|
96
|
-
### <a name="config-
|
|
102
|
+
### <a name="config-ebs-optimized"></a> ebs\_optimized
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
Option to launch EC2 instance with optimized EBS volume. See
|
|
105
|
+
[Amazon EC2 Instance Types](http://aws.amazon.com/ec2/instance-types/) to find
|
|
106
|
+
out more about instance types that can be launched as EBS-optimized instances.
|
|
107
|
+
|
|
108
|
+
The default is `false`.
|
|
109
|
+
|
|
110
|
+
### <a name="config-security-group-ids"></a> security_group_ids
|
|
111
|
+
|
|
112
|
+
An Array of EC2 [security groups][group_docs] which will be applied to the
|
|
99
113
|
instance.
|
|
100
114
|
|
|
101
115
|
The default is `["default"]`.
|
|
@@ -114,27 +128,22 @@ The SSH port number to be used when communicating with the instance.
|
|
|
114
128
|
|
|
115
129
|
The default is `22`.
|
|
116
130
|
|
|
117
|
-
### <
|
|
131
|
+
### < name="interface"></a> interface
|
|
118
132
|
|
|
119
|
-
|
|
133
|
+
The place from which to derive the hostname for communicating with the instance. May be `dns`, `public` or `private`. If this is unset, the driver will derive the hostname by failing back in the following order:
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
1. DNS Name
|
|
136
|
+
2. Public IP Address
|
|
137
|
+
3. Private IP Address
|
|
122
138
|
|
|
123
|
-
|
|
139
|
+
The default is unset.
|
|
124
140
|
|
|
125
|
-
Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
|
|
126
|
-
installed. There are several different behaviors available:
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
will skip re-installing if chef is present.
|
|
130
|
-
* `latest` - the latest release will be installed. Subsequent converges
|
|
131
|
-
will always re-install even if chef is present.
|
|
132
|
-
* `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
|
|
133
|
-
be passed the the install.sh script. Subsequent converges will skip if
|
|
134
|
-
the installed version and the desired version match.
|
|
135
|
-
* `false` or `nil` - no chef is installed.
|
|
142
|
+
### <a name="config-region"></a> region
|
|
136
143
|
|
|
137
|
-
The
|
|
144
|
+
**Required** The AWS [region][region_docs] to use.
|
|
145
|
+
|
|
146
|
+
The default is `"us-east-1"`.
|
|
138
147
|
|
|
139
148
|
### <a name="config-ssh-key"></a> ssh\_key
|
|
140
149
|
|
|
@@ -148,13 +157,6 @@ The EC2 [subnet][subnet_docs] to use.
|
|
|
148
157
|
|
|
149
158
|
The default is unset, or `nil`.
|
|
150
159
|
|
|
151
|
-
### <a name="config-sudo"></a> sudo
|
|
152
|
-
|
|
153
|
-
Whether or not to prefix remote system commands such as installing and
|
|
154
|
-
running Chef with `sudo`.
|
|
155
|
-
|
|
156
|
-
The default is `true`.
|
|
157
|
-
|
|
158
160
|
### <a name="config-tags"></a> tags
|
|
159
161
|
|
|
160
162
|
The Hash of EC tag name/value pairs which will be applied to the instance.
|
|
@@ -176,26 +178,27 @@ to override default configuration.
|
|
|
176
178
|
|
|
177
179
|
```yaml
|
|
178
180
|
---
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
driver:
|
|
182
|
+
name: ec2
|
|
181
183
|
aws_access_key_id: KAS...
|
|
182
184
|
aws_secret_access_key: 3UK...
|
|
183
185
|
aws_ssh_key_id: id_rsa-aws
|
|
184
186
|
ssh_key: /path/to/id_rsa-aws
|
|
187
|
+
security_group_ids: ["sg-1a2b3c4d"]
|
|
185
188
|
region: us-east-1
|
|
186
189
|
availability_zone: us-east-1b
|
|
187
190
|
require_chef_omnibus: true
|
|
188
191
|
subnet_id: subnet-6d6...
|
|
189
192
|
|
|
190
193
|
platforms:
|
|
191
|
-
- name: ubuntu-12.04
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
- name: centos-6.3
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
- name: ubuntu-12.04
|
|
195
|
+
driver:
|
|
196
|
+
image_id: ami-fd20ad94
|
|
197
|
+
username: ubuntu
|
|
198
|
+
- name: centos-6.3
|
|
199
|
+
driver:
|
|
200
|
+
image_id: ami-ef5ff086
|
|
201
|
+
username: ec2-user
|
|
199
202
|
|
|
200
203
|
suites:
|
|
201
204
|
# ...
|
|
@@ -206,25 +209,26 @@ ERB which can help to factor out secrets and credentials. For example:
|
|
|
206
209
|
|
|
207
210
|
```yaml
|
|
208
211
|
---
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
driver:
|
|
213
|
+
name: ec2
|
|
211
214
|
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY'] %>
|
|
212
215
|
aws_secret_access_key: <%= ENV['AWS_SECRET_KEY'] %>
|
|
213
216
|
aws_ssh_key_id: <%= ENV['AWS_SSH_KEY_ID'] %>
|
|
214
217
|
ssh_key: <%= File.expand_path('~/.ssh/id_rsa') %>
|
|
218
|
+
security_group_ids: ["sg-1a2b3c4d"]
|
|
215
219
|
region: us-east-1
|
|
216
220
|
availability_zone: us-east-1b
|
|
217
221
|
require_chef_omnibus: true
|
|
218
222
|
|
|
219
223
|
platforms:
|
|
220
|
-
- name: ubuntu-12.04
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- name: centos-6.3
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
- name: ubuntu-12.04
|
|
225
|
+
driver:
|
|
226
|
+
image_id: ami-fd20ad94
|
|
227
|
+
username: ubuntu
|
|
228
|
+
- name: centos-6.3
|
|
229
|
+
driver:
|
|
230
|
+
image_id: ami-ef5ff086
|
|
231
|
+
username: ec2-user
|
|
228
232
|
|
|
229
233
|
suites:
|
|
230
234
|
# ...
|
|
@@ -255,13 +259,13 @@ Apache 2.0 (see [LICENSE][license])
|
|
|
255
259
|
|
|
256
260
|
|
|
257
261
|
[author]: https://github.com/fnichol
|
|
258
|
-
[issues]: https://github.com/
|
|
259
|
-
[license]: https://github.com/
|
|
260
|
-
[repo]: https://github.com/
|
|
262
|
+
[issues]: https://github.com/test-kitchen/kitchen-ec2/issues
|
|
263
|
+
[license]: https://github.com/test-kitchen/kitchen-ec2/blob/master/LICENSE
|
|
264
|
+
[repo]: https://github.com/test-kitchen/kitchen-ec2
|
|
261
265
|
[driver_usage]: http://docs.kitchen-ci.org/drivers/usage
|
|
262
|
-
[chef_omnibus_dl]: http://www.
|
|
266
|
+
[chef_omnibus_dl]: http://www.getchef.com/chef/install/
|
|
263
267
|
|
|
264
|
-
[amis_json]: https://github.com/
|
|
268
|
+
[amis_json]: https://github.com/test-kitchen/kitchen-ec2/blob/master/data/amis.json
|
|
265
269
|
[ami_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html
|
|
266
270
|
[aws_site]: http://aws.amazon.com/
|
|
267
271
|
[credentials_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html#using-credentials-access-key
|
|
@@ -269,5 +273,6 @@ Apache 2.0 (see [LICENSE][license])
|
|
|
269
273
|
[group_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
|
|
270
274
|
[instance_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
|
|
271
275
|
[key_id_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/verifying-your-key-pair.html
|
|
276
|
+
[kitchenci]: http://kitchen.ci/
|
|
272
277
|
[region_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
|
|
273
278
|
[subnet_docs]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html
|
data/kitchen-ec2.gemspec
CHANGED
|
@@ -9,18 +9,19 @@ Gem::Specification.new do |gem|
|
|
|
9
9
|
gem.license = 'Apache 2.0'
|
|
10
10
|
gem.authors = ["Fletcher Nichol"]
|
|
11
11
|
gem.email = ["fnichol@nichol.ca"]
|
|
12
|
-
gem.description = "
|
|
12
|
+
gem.description = "A Test Kitchen Driver for Amazon EC2"
|
|
13
13
|
gem.summary = gem.description
|
|
14
|
-
gem.homepage = "
|
|
14
|
+
gem.homepage = "http://kitchen.ci/"
|
|
15
15
|
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
|
17
17
|
gem.executables = []
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
gem.require_paths = ["lib"]
|
|
20
20
|
|
|
21
|
-
gem.add_dependency 'test-kitchen', '~> 1.0
|
|
21
|
+
gem.add_dependency 'test-kitchen', '~> 1.0'
|
|
22
22
|
gem.add_dependency 'fog'
|
|
23
23
|
|
|
24
|
+
gem.add_development_dependency 'rspec'
|
|
24
25
|
gem.add_development_dependency 'cane'
|
|
25
26
|
gem.add_development_dependency 'tailor'
|
|
26
27
|
gem.add_development_dependency 'countloc'
|
data/lib/kitchen/driver/ec2.rb
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
require 'benchmark'
|
|
20
20
|
require 'json'
|
|
21
21
|
require 'fog'
|
|
22
|
-
|
|
23
22
|
require 'kitchen'
|
|
24
23
|
|
|
25
24
|
module Kitchen
|
|
@@ -34,13 +33,17 @@ module Kitchen
|
|
|
34
33
|
default_config :region, 'us-east-1'
|
|
35
34
|
default_config :availability_zone, 'us-east-1b'
|
|
36
35
|
default_config :flavor_id, 'm1.small'
|
|
37
|
-
default_config :
|
|
36
|
+
default_config :ebs_optimized, false
|
|
37
|
+
default_config :security_group_ids, ['default']
|
|
38
38
|
default_config :tags, { 'created-by' => 'test-kitchen' }
|
|
39
39
|
default_config :aws_access_key_id do |driver|
|
|
40
|
-
ENV['AWS_ACCESS_KEY']
|
|
40
|
+
ENV['AWS_ACCESS_KEY'] || ENV['AWS_ACCESS_KEY_ID']
|
|
41
41
|
end
|
|
42
42
|
default_config :aws_secret_access_key do |driver|
|
|
43
|
-
ENV['AWS_SECRET_KEY']
|
|
43
|
+
ENV['AWS_SECRET_KEY'] || ENV['AWS_SECRET_ACCESS_KEY']
|
|
44
|
+
end
|
|
45
|
+
default_config :aws_session_token do |driver|
|
|
46
|
+
ENV['AWS_SESSION_TOKEN'] || ENV['AWS_TOKEN']
|
|
44
47
|
end
|
|
45
48
|
default_config :aws_ssh_key_id do |driver|
|
|
46
49
|
ENV['AWS_SSH_KEY_ID']
|
|
@@ -51,6 +54,11 @@ module Kitchen
|
|
|
51
54
|
default_config :username do |driver|
|
|
52
55
|
driver.default_username
|
|
53
56
|
end
|
|
57
|
+
default_config :endpoint do |driver|
|
|
58
|
+
"https://ec2.#{driver[:region]}.amazonaws.com/"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
default_config :interface, nil
|
|
54
62
|
|
|
55
63
|
required_config :aws_access_key_id
|
|
56
64
|
required_config :aws_secret_access_key
|
|
@@ -62,9 +70,11 @@ module Kitchen
|
|
|
62
70
|
state[:server_id] = server.id
|
|
63
71
|
|
|
64
72
|
info("EC2 instance <#{state[:server_id]}> created.")
|
|
65
|
-
server.wait_for { print
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
server.wait_for { print '.'; ready? }
|
|
74
|
+
print '(server ready)'
|
|
75
|
+
state[:hostname] = hostname(server)
|
|
76
|
+
wait_for_sshd(state[:hostname], config[:username])
|
|
77
|
+
print '(ssh ready)\n'
|
|
68
78
|
debug("ec2:create '#{state[:hostname]}'")
|
|
69
79
|
rescue Fog::Errors::Error, Excon::Errors::Error => ex
|
|
70
80
|
raise ActionFailed, ex.message
|
|
@@ -81,12 +91,12 @@ module Kitchen
|
|
|
81
91
|
end
|
|
82
92
|
|
|
83
93
|
def default_ami
|
|
84
|
-
region = amis[
|
|
94
|
+
region = amis['regions'][config[:region]]
|
|
85
95
|
region && region[instance.platform.name]
|
|
86
96
|
end
|
|
87
97
|
|
|
88
98
|
def default_username
|
|
89
|
-
amis[
|
|
99
|
+
amis['usernames'][instance.platform.name] || 'root'
|
|
90
100
|
end
|
|
91
101
|
|
|
92
102
|
private
|
|
@@ -96,7 +106,9 @@ module Kitchen
|
|
|
96
106
|
:provider => :aws,
|
|
97
107
|
:aws_access_key_id => config[:aws_access_key_id],
|
|
98
108
|
:aws_secret_access_key => config[:aws_secret_access_key],
|
|
109
|
+
:aws_session_token => config[:aws_session_token],
|
|
99
110
|
:region => config[:region],
|
|
111
|
+
:endpoint => config[:endpoint],
|
|
100
112
|
)
|
|
101
113
|
end
|
|
102
114
|
|
|
@@ -105,9 +117,10 @@ module Kitchen
|
|
|
105
117
|
|
|
106
118
|
connection.servers.create(
|
|
107
119
|
:availability_zone => config[:availability_zone],
|
|
108
|
-
:
|
|
120
|
+
:security_group_ids => config[:security_group_ids],
|
|
109
121
|
:tags => config[:tags],
|
|
110
122
|
:flavor_id => config[:flavor_id],
|
|
123
|
+
:ebs_optimized => config[:ebs_optimized],
|
|
111
124
|
:image_id => config[:image_id],
|
|
112
125
|
:key_name => config[:aws_ssh_key_id],
|
|
113
126
|
:subnet_id => config[:subnet_id],
|
|
@@ -118,8 +131,9 @@ module Kitchen
|
|
|
118
131
|
debug("ec2:region '#{config[:region]}'")
|
|
119
132
|
debug("ec2:availability_zone '#{config[:availability_zone]}'")
|
|
120
133
|
debug("ec2:flavor_id '#{config[:flavor_id]}'")
|
|
134
|
+
debug("ec2:ebs_optimized '#{config[:ebs_optimized]}'")
|
|
121
135
|
debug("ec2:image_id '#{config[:image_id]}'")
|
|
122
|
-
debug("ec2:
|
|
136
|
+
debug("ec2:security_group_ids '#{config[:security_group_ids]}'")
|
|
123
137
|
debug("ec2:tags '#{config[:tags]}'")
|
|
124
138
|
debug("ec2:key_name '#{config[:aws_ssh_key_id]}'")
|
|
125
139
|
debug("ec2:subnet_id '#{config[:subnet_id]}'")
|
|
@@ -132,6 +146,25 @@ module Kitchen
|
|
|
132
146
|
JSON.load(IO.read(json_file))
|
|
133
147
|
end
|
|
134
148
|
end
|
|
149
|
+
|
|
150
|
+
def interface_types
|
|
151
|
+
{
|
|
152
|
+
'dns' => 'dns_name',
|
|
153
|
+
'public' => 'public_ip_address',
|
|
154
|
+
'private' => 'private_ip_address'
|
|
155
|
+
}
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def hostname(server)
|
|
159
|
+
if config[:interface]
|
|
160
|
+
method = interface_types.fetch(config[:interface]) do
|
|
161
|
+
raise Kitchen::UserError, 'Invalid interface'
|
|
162
|
+
end
|
|
163
|
+
server.send(method)
|
|
164
|
+
else
|
|
165
|
+
server.dns_name || server.public_ip_address || server.private_ip_address
|
|
166
|
+
end
|
|
167
|
+
end
|
|
135
168
|
end
|
|
136
169
|
end
|
|
137
170
|
end
|
data/spec/create_spec.rb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
require 'kitchen/driver/ec2'
|
|
2
|
+
require 'kitchen/provisioner/dummy'
|
|
3
|
+
|
|
4
|
+
describe Kitchen::Driver::Ec2 do
|
|
5
|
+
|
|
6
|
+
let(:config) do
|
|
7
|
+
{}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:state) do
|
|
11
|
+
{}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:server) do
|
|
15
|
+
double(:id => "123",
|
|
16
|
+
:wait_for => nil,
|
|
17
|
+
:dns_name => "server.example.com",
|
|
18
|
+
:private_ip_address => '172.13.16.11',
|
|
19
|
+
:public_ip_address => '213.225.123.134')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
let(:instance) do
|
|
23
|
+
Kitchen::Instance.new(:platform => double(:name => "centos-6.4"),
|
|
24
|
+
:suite => double(:name => "default"),
|
|
25
|
+
:driver => driver,
|
|
26
|
+
:provisioner => Kitchen::Provisioner::Dummy.new({}),
|
|
27
|
+
:busser => double("busser"),
|
|
28
|
+
:state_file => double("state_file"))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
let(:driver) do
|
|
32
|
+
Kitchen::Driver::Ec2.new(config)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
instance
|
|
37
|
+
allow(driver).to receive(:create_server).and_return(server)
|
|
38
|
+
allow(driver).to receive(:wait_for_sshd)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context 'Interface is set in config' do
|
|
42
|
+
|
|
43
|
+
it 'derives hostname from DNS when specified in the .kitchen.yml' do
|
|
44
|
+
config[:interface] = 'dns'
|
|
45
|
+
driver.create(state)
|
|
46
|
+
expect(state[:hostname]).to eql('server.example.com')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'derives hostname from public interface when specified in the .kitchen.yml' do
|
|
50
|
+
config[:interface] = 'public'
|
|
51
|
+
driver.create(state)
|
|
52
|
+
expect(state[:hostname]).to eql('213.225.123.134')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'derives hostname from private interface when specified in the .kitchen.yml' do
|
|
56
|
+
config[:interface] = 'private'
|
|
57
|
+
driver.create(state)
|
|
58
|
+
expect(state[:hostname]).to eql('172.13.16.11')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'throws a nice exception if the config is bogus' do
|
|
62
|
+
config[:interface] = 'I am an idiot'
|
|
63
|
+
expect { driver.create(state) }.to raise_error(Kitchen::UserError, 'Invalid interface')
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'Interface is derived automatically' do
|
|
69
|
+
|
|
70
|
+
let(:server) do
|
|
71
|
+
double(:id => "123",
|
|
72
|
+
:wait_for => nil,
|
|
73
|
+
:dns_name => nil,
|
|
74
|
+
:private_ip_address => nil,
|
|
75
|
+
:public_ip_address => nil)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'sets hostname to DNS value if DNS value exists' do
|
|
79
|
+
allow(server).to receive(:dns_name).and_return('server.example.com')
|
|
80
|
+
driver.create(state)
|
|
81
|
+
expect(state[:hostname]).to eql('server.example.com')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'sets hostname to public value if public value exists' do
|
|
85
|
+
allow(server).to receive(:public_ip_address).and_return('213.225.123.134')
|
|
86
|
+
driver.create(state)
|
|
87
|
+
|
|
88
|
+
expect(state[:hostname]).to eql('213.225.123.134')
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'sets hostname to private value if private value exists' do
|
|
92
|
+
allow(server).to receive(:private_ip_address).and_return('172.13.16.11')
|
|
93
|
+
driver.create(state)
|
|
94
|
+
expect(state[:hostname]).to eql('172.13.16.11')
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'sets hostname to DNS if one or more Public/Private values are set' do
|
|
98
|
+
allow(server).to receive(:dns_name).and_return('server.example.com')
|
|
99
|
+
allow(server).to receive(:public_ip_address).and_return('213.225.123.134')
|
|
100
|
+
allow(server).to receive(:private_ip_address).and_return('172.13.16.11')
|
|
101
|
+
driver.create(state)
|
|
102
|
+
expect(state[:hostname]).to eql('server.example.com')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
end
|
metadata
CHANGED
|
@@ -1,96 +1,110 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-ec2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fletcher Nichol
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-02-12 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
|
-
version: 1.0
|
|
19
|
+
version: '1.0'
|
|
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
|
-
version: 1.0
|
|
26
|
+
version: '1.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: fog
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
39
53
|
- !ruby/object:Gem::Version
|
|
40
54
|
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: cane
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
|
-
- -
|
|
59
|
+
- - ">="
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
61
|
version: '0'
|
|
48
62
|
type: :development
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
|
-
- -
|
|
66
|
+
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: tailor
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
|
-
- -
|
|
73
|
+
- - ">="
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
75
|
version: '0'
|
|
62
76
|
type: :development
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
|
-
- -
|
|
80
|
+
- - ">="
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
82
|
version: '0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: countloc
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
|
-
- -
|
|
87
|
+
- - ">="
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
89
|
version: '0'
|
|
76
90
|
type: :development
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
|
-
- -
|
|
94
|
+
- - ">="
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
96
|
version: '0'
|
|
83
|
-
description:
|
|
97
|
+
description: A Test Kitchen Driver for Amazon EC2
|
|
84
98
|
email:
|
|
85
99
|
- fnichol@nichol.ca
|
|
86
100
|
executables: []
|
|
87
101
|
extensions: []
|
|
88
102
|
extra_rdoc_files: []
|
|
89
103
|
files:
|
|
90
|
-
- .cane
|
|
91
|
-
- .gitignore
|
|
92
|
-
- .tailor
|
|
93
|
-
- .travis.yml
|
|
104
|
+
- ".cane"
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".tailor"
|
|
107
|
+
- ".travis.yml"
|
|
94
108
|
- CHANGELOG.md
|
|
95
109
|
- Gemfile
|
|
96
110
|
- LICENSE
|
|
@@ -100,7 +114,8 @@ files:
|
|
|
100
114
|
- kitchen-ec2.gemspec
|
|
101
115
|
- lib/kitchen/driver/ec2.rb
|
|
102
116
|
- lib/kitchen/driver/ec2_version.rb
|
|
103
|
-
|
|
117
|
+
- spec/create_spec.rb
|
|
118
|
+
homepage: http://kitchen.ci/
|
|
104
119
|
licenses:
|
|
105
120
|
- Apache 2.0
|
|
106
121
|
metadata: {}
|
|
@@ -110,18 +125,19 @@ require_paths:
|
|
|
110
125
|
- lib
|
|
111
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
127
|
requirements:
|
|
113
|
-
- -
|
|
128
|
+
- - ">="
|
|
114
129
|
- !ruby/object:Gem::Version
|
|
115
130
|
version: '0'
|
|
116
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
132
|
requirements:
|
|
118
|
-
- -
|
|
133
|
+
- - ">="
|
|
119
134
|
- !ruby/object:Gem::Version
|
|
120
135
|
version: '0'
|
|
121
136
|
requirements: []
|
|
122
137
|
rubyforge_project:
|
|
123
|
-
rubygems_version: 2.0
|
|
138
|
+
rubygems_version: 2.2.0
|
|
124
139
|
signing_key:
|
|
125
140
|
specification_version: 4
|
|
126
|
-
summary:
|
|
127
|
-
test_files:
|
|
141
|
+
summary: A Test Kitchen Driver for Amazon EC2
|
|
142
|
+
test_files:
|
|
143
|
+
- spec/create_spec.rb
|