kitchen-ec2 2.1.0 → 2.2.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/CHANGELOG.md +17 -0
- data/README.md +16 -26
- data/kitchen-ec2.gemspec +2 -2
- data/lib/kitchen/driver/aws/client.rb +3 -4
- data/lib/kitchen/driver/aws/instance_generator.rb +4 -3
- data/lib/kitchen/driver/aws/standard_platform.rb +16 -0
- data/lib/kitchen/driver/aws/standard_platform/amazon.rb +15 -0
- data/lib/kitchen/driver/aws/standard_platform/centos.rb +15 -0
- data/lib/kitchen/driver/aws/standard_platform/debian.rb +19 -0
- data/lib/kitchen/driver/aws/standard_platform/fedora.rb +15 -0
- data/lib/kitchen/driver/aws/standard_platform/freebsd.rb +16 -1
- data/lib/kitchen/driver/aws/standard_platform/rhel.rb +15 -0
- data/lib/kitchen/driver/aws/standard_platform/ubuntu.rb +15 -0
- data/lib/kitchen/driver/aws/standard_platform/windows.rb +15 -0
- data/lib/kitchen/driver/ec2.rb +49 -24
- data/lib/kitchen/driver/ec2_version.rb +3 -2
- data/spec/kitchen/driver/ec2/client_spec.rb +2 -1
- data/spec/kitchen/driver/ec2/image_selection_spec.rb +16 -0
- data/spec/kitchen/driver/ec2/instance_generator_spec.rb +2 -39
- data/spec/kitchen/driver/ec2_spec.rb +82 -22
- data/spec/spec_helper.rb +2 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28db84523fe129c18d97d7d4ce035e53018dae22
|
4
|
+
data.tar.gz: e9614c002ae5569a2142b0778bc55672820ae2c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d6bb1cebdbf37961f07aab3e0b53f6397cf79f3f601889ddc8f82f478730e00099430258ff059c2ce34e9247f1a57da046b316672e987fa99c757e1da9310f8
|
7
|
+
data.tar.gz: 42722c4235563507a4b30e2b4f28edb6b8fbe08c46e6a3203b90b576674e9c4b0ba7d678d7daa5ece7c5d58a13ac437f02916a3f277cd871e1246e97e4c24af9
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v2.2.0](https://github.com/test-kitchen/kitchen-ec2/tree/v2.2.0) (2018-01-27)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v2.1.0...v2.2.0)
|
6
|
+
|
7
|
+
- When config validation fails we now show you just the error message instead of the full stack trace with a buried error message
|
8
|
+
- Removed the username logic for FreeBSD < 9.1 as those releases are EOL
|
9
|
+
- Add support for Debian 10/11 so we'll support them as soon as they're released
|
10
|
+
- Added support for the 'host' tenancy value
|
11
|
+
- Added proper config validation for tenancy instead of silently skipping bad data
|
12
|
+
- Properly handle Integers in tags instead of failing the run
|
13
|
+
- Properly handle nil values in tags instead of failing the run
|
14
|
+
- Add validation to make sure the tags are passed as a single hash instead of an array of each tag
|
15
|
+
- Update our Yard dev dependency to make sure we have 0.9.11+ to avoid a CVE in earlier releases
|
16
|
+
- Update links in docs and distros in the examples
|
17
|
+
- Removed Rubocop comments that weren't necessary from the code
|
18
|
+
|
3
19
|
## [v2.1.0](https://github.com/test-kitchen/kitchen-ec2/tree/v2.1.0) (2018-01-27)
|
20
|
+
|
4
21
|
[Full Changelog](https://github.com/test-kitchen/kitchen-ec2/compare/v2.0.0...v2.1.0)
|
5
22
|
|
6
23
|
**Merged pull requests:**
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ instances. Use Amazon's cloud for your infrastructure testing!
|
|
14
14
|
1. Install [ChefDK](https://downloads.chef.io/chefdk). If testing things other
|
15
15
|
than Chef cookbooks, please consult your driver's documentation for information
|
16
16
|
on what to install.
|
17
|
-
2. Install the [AWS command line tools](
|
17
|
+
2. Install the [AWS command line tools](https://docs.aws.amazon.com/cli/latest/userguide/installing.html).
|
18
18
|
3. Run `aws configure`. This will set up your AWS credentials for both the AWS
|
19
19
|
CLI tools and kitchen-ec2.
|
20
20
|
4. Add or exit the `driver` section of your `.kitchen.yml`:
|
@@ -152,7 +152,7 @@ specify.
|
|
152
152
|
|
153
153
|
#### SSH
|
154
154
|
|
155
|
-
The `aws_ssh_key_id` value is the name of the AWS key pair you want to use. The default will be read from the `AWS_SSH_KEY_ID` environment variable if set. If a key ID is not specified, a temporary key will be created for you.
|
155
|
+
The `aws_ssh_key_id` value is the name of the AWS key pair you want to use. The default will be read from the `AWS_SSH_KEY_ID` environment variable if set. If a key ID is not specified, a temporary key will be created for you (**>= 2.1.0**).
|
156
156
|
|
157
157
|
To see a list of existing key pair IDs in a region, run `aws ec2 describe-key-pairs --region us-east-1`.
|
158
158
|
|
@@ -194,7 +194,7 @@ or `paravirtual`. (`paravirtual` images are incompatible with `t2.micro`.)
|
|
194
194
|
|
195
195
|
An Array of EC2 [security groups][group_docs] which will be applied to the
|
196
196
|
instance. If no security group is specified, a temporary group will be created
|
197
|
-
automatically which allows SSH and WinRM.
|
197
|
+
automatically which allows SSH and WinRM (**>= 2.1.0**).
|
198
198
|
|
199
199
|
#### `security_group_filter`
|
200
200
|
|
@@ -425,18 +425,8 @@ transport:
|
|
425
425
|
username: ubuntu
|
426
426
|
|
427
427
|
platforms:
|
428
|
-
- name: ubuntu-
|
429
|
-
- name: centos-6.
|
430
|
-
- name: ubuntu-15.04
|
431
|
-
driver:
|
432
|
-
image_id: ami-83211eb3
|
433
|
-
block_device_mappings:
|
434
|
-
- device_name: /dev/sda1
|
435
|
-
ebs:
|
436
|
-
volume_type: standard
|
437
|
-
virtual_name: test
|
438
|
-
volume_size: 15
|
439
|
-
delete_on_termination: true
|
428
|
+
- name: ubuntu-16.04
|
429
|
+
- name: centos-6.9
|
440
430
|
- name: centos-7
|
441
431
|
driver:
|
442
432
|
image_id: ami-c7d092f7
|
@@ -450,7 +440,7 @@ platforms:
|
|
450
440
|
transport:
|
451
441
|
username: centos
|
452
442
|
- name: windows-2012r2
|
453
|
-
- name: windows-
|
443
|
+
- name: windows-2016
|
454
444
|
|
455
445
|
suites:
|
456
446
|
# ...
|
@@ -481,17 +471,17 @@ Apache 2.0 (see [LICENSE][license])
|
|
481
471
|
[license]: https://github.com/test-kitchen/kitchen-ec2/blob/master/LICENSE
|
482
472
|
[repo]: https://github.com/test-kitchen/kitchen-ec2
|
483
473
|
[driver_usage]: https://github.com/test-kitchen/kitchen-ec2
|
484
|
-
[chef_omnibus_dl]: https://downloads.chef.io/chef
|
474
|
+
[chef_omnibus_dl]: https://downloads.chef.io/chef
|
485
475
|
[amis_json]: https://github.com/test-kitchen/kitchen-ec2/blob/master/data/amis.json
|
486
476
|
[ami_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html
|
487
477
|
[aws_site]: http://aws.amazon.com/
|
488
478
|
[iam_site]: http://aws.amazon.com/iam
|
489
|
-
[credentials_docs]:
|
490
|
-
[aws_sdk_gem]:
|
491
|
-
[group_docs]:
|
492
|
-
[instance_docs]:
|
493
|
-
[key_id_docs]:
|
494
|
-
[kitchenci]:
|
495
|
-
[region_docs]:
|
496
|
-
[subnet_docs]:
|
497
|
-
[vpc_docs]:
|
479
|
+
[credentials_docs]: https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/
|
480
|
+
[aws_sdk_gem]: https://docs.aws.amazon.com/sdkforruby/api/index.html
|
481
|
+
[group_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
|
482
|
+
[instance_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
|
483
|
+
[key_id_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
|
484
|
+
[kitchenci]: https://kitchen.ci/
|
485
|
+
[region_docs]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
|
486
|
+
[subnet_docs]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html
|
487
|
+
[vpc_docs]: https://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/ExerciseOverview.html
|
data/kitchen-ec2.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.email = ["fnichol@nichol.ca"]
|
12
12
|
gem.description = "A Test Kitchen Driver for Amazon EC2"
|
13
13
|
gem.summary = gem.description
|
14
|
-
gem.homepage = "
|
14
|
+
gem.homepage = "https://kitchen.ci/"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
gem.executables = []
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |gem|
|
|
30
30
|
gem.add_development_dependency "countloc", "~> 0.4"
|
31
31
|
gem.add_development_dependency "maruku", "~> 0.6"
|
32
32
|
gem.add_development_dependency "simplecov", "~> 0.7"
|
33
|
-
gem.add_development_dependency "yard", "~> 0.
|
33
|
+
gem.add_development_dependency "yard", "~> 0.9", ">= 0.9.11"
|
34
34
|
|
35
35
|
# style and complexity libraries are tightly version pinned as newer releases
|
36
36
|
# may introduce new and undesireable style choices which would be immediately
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Tyler Ball (<tball@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -32,7 +33,7 @@ module Kitchen
|
|
32
33
|
# @author Tyler Ball <tball@chef.io>
|
33
34
|
class Client
|
34
35
|
|
35
|
-
def initialize(
|
36
|
+
def initialize(
|
36
37
|
region,
|
37
38
|
profile_name = "default",
|
38
39
|
http_proxy = nil,
|
@@ -48,8 +49,6 @@ module Kitchen
|
|
48
49
|
::Aws.config.update(:retry_limit => retry_limit) unless retry_limit.nil?
|
49
50
|
end
|
50
51
|
|
51
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
52
|
-
|
53
52
|
def create_instance(options)
|
54
53
|
resource.create_instances(options)[0]
|
55
54
|
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Tyler Ball (<tball@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -94,7 +95,7 @@ module Kitchen
|
|
94
95
|
i[:placement] = { :availability_zone => availability_zone.downcase }
|
95
96
|
end
|
96
97
|
tenancy = config[:tenancy]
|
97
|
-
if tenancy
|
98
|
+
if tenancy
|
98
99
|
if i.key?(:placement)
|
99
100
|
i[:placement][:tenancy] = tenancy
|
100
101
|
else
|
@@ -137,7 +138,7 @@ module Kitchen
|
|
137
138
|
i[:placement] = { :availability_zone => availability_zone.downcase }
|
138
139
|
end
|
139
140
|
tenancy = config[:tenancy]
|
140
|
-
if tenancy
|
141
|
+
if tenancy
|
141
142
|
if i.key?(:placement)
|
142
143
|
i[:placement][:tenancy] = tenancy
|
143
144
|
else
|
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
1
17
|
module Kitchen
|
2
18
|
module Driver
|
3
19
|
class Aws
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -8,11 +23,15 @@ module Kitchen
|
|
8
23
|
class Debian < StandardPlatform
|
9
24
|
StandardPlatform.platforms["debian"] = self
|
10
25
|
|
26
|
+
# 10/11 are listed last since we default to the first item in the hash
|
27
|
+
# and 10/11 are not released yet. When they're released move them up
|
11
28
|
DEBIAN_CODENAMES = {
|
12
29
|
"9" => "stretch",
|
13
30
|
"8" => "jessie",
|
14
31
|
"7" => "wheezy",
|
15
32
|
"6" => "squeeze",
|
33
|
+
"11" => "bullseye",
|
34
|
+
"10" => "buster",
|
16
35
|
}
|
17
36
|
|
18
37
|
def username
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -9,7 +24,7 @@ module Kitchen
|
|
9
24
|
StandardPlatform.platforms["freebsd"] = self
|
10
25
|
|
11
26
|
def username
|
12
|
-
|
27
|
+
"ec2-user"
|
13
28
|
end
|
14
29
|
|
15
30
|
def sudo_command
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
1
16
|
require "kitchen/driver/aws/standard_platform"
|
2
17
|
|
3
18
|
module Kitchen
|
data/lib/kitchen/driver/ec2.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -46,7 +47,7 @@ module Kitchen
|
|
46
47
|
# Amazon EC2 driver for Test Kitchen.
|
47
48
|
#
|
48
49
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
49
|
-
class Ec2 < Kitchen::Driver::Base
|
50
|
+
class Ec2 < Kitchen::Driver::Base
|
50
51
|
|
51
52
|
kitchen_driver_api_version 2
|
52
53
|
|
@@ -103,8 +104,9 @@ module Kitchen
|
|
103
104
|
end
|
104
105
|
|
105
106
|
def self.validation_error(driver, old_key, new_key)
|
106
|
-
|
107
|
+
warn "ERROR: The driver[#{driver.class.name}] config key `#{old_key}` " \
|
107
108
|
"has been removed, please use `#{new_key}`"
|
109
|
+
exit!
|
108
110
|
end
|
109
111
|
|
110
112
|
# TODO: remove these in 1.1
|
@@ -142,37 +144,61 @@ module Kitchen
|
|
142
144
|
end
|
143
145
|
end
|
144
146
|
|
147
|
+
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-instance.html
|
148
|
+
validations[:tenancy] = lambda do |attr, val, _driver|
|
149
|
+
unless %w{default host dedicated}.include?(val)
|
150
|
+
warn "'#{val}' is an invalid value for option '#{attr}'. " \
|
151
|
+
"Valid values are 'default', 'host', or 'dedicated'."
|
152
|
+
exit!
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
145
156
|
# The access key/secret are now using the priority list AWS uses
|
146
157
|
# Providing these inside the .kitchen.yml is no longer recommended
|
147
158
|
validations[:aws_access_key_id] = lambda do |attr, val, _driver|
|
148
159
|
unless val.nil?
|
149
|
-
|
150
|
-
"ENV['AWS_ACCESS_KEY_ID'] or ~/.aws/credentials.
|
160
|
+
warn "#{attr} is no longer a valid config option, please use " \
|
161
|
+
"ENV['AWS_ACCESS_KEY_ID'] or ~/.aws/credentials. See " \
|
151
162
|
"the README for more details"
|
163
|
+
exit!
|
152
164
|
end
|
153
165
|
end
|
154
166
|
validations[:aws_secret_access_key] = lambda do |attr, val, _driver|
|
155
167
|
unless val.nil?
|
156
|
-
|
157
|
-
"ENV['AWS_SECRET_ACCESS_KEY'] or ~/.aws/credentials.
|
168
|
+
warn "#{attr} is no longer a valid config option, please use " \
|
169
|
+
"ENV['AWS_SECRET_ACCESS_KEY'] or ~/.aws/credentials. See " \
|
158
170
|
"the README for more details"
|
171
|
+
exit!
|
159
172
|
end
|
160
173
|
end
|
161
174
|
validations[:aws_session_token] = lambda do |attr, val, _driver|
|
162
175
|
unless val.nil?
|
163
|
-
|
164
|
-
"ENV['AWS_SESSION_TOKEN'] or ~/.aws/credentials.
|
176
|
+
warn "#{attr} is no longer a valid config option, please use " \
|
177
|
+
"ENV['AWS_SESSION_TOKEN'] or ~/.aws/credentials. See " \
|
165
178
|
"the README for more details"
|
179
|
+
exit!
|
166
180
|
end
|
167
181
|
end
|
168
182
|
validations[:instance_initiated_shutdown_behavior] = lambda do |attr, val, _driver|
|
169
183
|
unless [nil, "stop", "terminate"].include?(val)
|
170
|
-
|
184
|
+
warn "'#{val}' is an invalid value for option '#{attr}'. " \
|
171
185
|
"Valid values are 'stop' or 'terminate'"
|
186
|
+
exit!
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# empty keys cause failures when tagging and they make no sense
|
191
|
+
validations[:tags] = lambda do |attr, val, _driver|
|
192
|
+
# if someone puts the tags each on their own line it's an array not a hash
|
193
|
+
# @todo we should probably just do the right thing and support this format
|
194
|
+
if val.class == Array
|
195
|
+
warn "AWS instance tags must be specified as a single hash, not a tag " \
|
196
|
+
"on each line. Example: {:foo => 'bar', :bar => 'foo'}"
|
197
|
+
exit!
|
172
198
|
end
|
173
199
|
end
|
174
200
|
|
175
|
-
def create(state)
|
201
|
+
def create(state)
|
176
202
|
return if state[:server_id]
|
177
203
|
update_username(state)
|
178
204
|
|
@@ -211,7 +237,7 @@ module Kitchen
|
|
211
237
|
|
212
238
|
# See https://github.com/aws/aws-sdk-ruby/issues/859
|
213
239
|
# Tagging can fail with a NotFound error even though we waited until the server exists
|
214
|
-
# Waiting can also fail, so we have to also retry on that.
|
240
|
+
# Waiting can also fail, so we have to also retry on that. If it means we re-tag the
|
215
241
|
# instance, so be it.
|
216
242
|
# Tagging an instance is possible before volumes are attached. Tagging the volumes after
|
217
243
|
# instance creation is consistent.
|
@@ -350,7 +376,7 @@ module Kitchen
|
|
350
376
|
def update_username(state)
|
351
377
|
# BUG: With the following equality condition on username, if the user specifies 'root'
|
352
378
|
# as the transport's username then we will overwrite that value with one from the standard
|
353
|
-
# platform definitions.
|
379
|
+
# platform definitions. This seems difficult to handle here as the default username is
|
354
380
|
# provided by the underlying transport classes, and is often non-nil (eg; 'root'), leaving
|
355
381
|
# us no way to distinguish a user-set value from the transport's default.
|
356
382
|
# See https://github.com/test-kitchen/kitchen-ec2/pull/273
|
@@ -388,7 +414,7 @@ module Kitchen
|
|
388
414
|
ec2.create_instance(instance_data)
|
389
415
|
end
|
390
416
|
|
391
|
-
def submit_spot(state)
|
417
|
+
def submit_spot(state)
|
392
418
|
debug("Creating EC2 Spot Instance..")
|
393
419
|
|
394
420
|
spot_request_id = create_spot_request
|
@@ -428,7 +454,10 @@ module Kitchen
|
|
428
454
|
def tag_server(server)
|
429
455
|
if config[:tags] && !config[:tags].empty?
|
430
456
|
tags = config[:tags].map do |k, v|
|
431
|
-
|
457
|
+
# we convert the value to a string because
|
458
|
+
# nils should be passed as an empty String
|
459
|
+
# and Integers need to be represented as Strings
|
460
|
+
{ :key => k, :value => v.to_s }
|
432
461
|
end
|
433
462
|
server.create_tags(:tags => tags)
|
434
463
|
end
|
@@ -437,7 +466,7 @@ module Kitchen
|
|
437
466
|
def tag_volumes(server)
|
438
467
|
if config[:tags] && !config[:tags].empty?
|
439
468
|
tags = config[:tags].map do |k, v|
|
440
|
-
{ :key => k, :value => v }
|
469
|
+
{ :key => k, :value => v.to_s }
|
441
470
|
end
|
442
471
|
server.volumes.each do |volume|
|
443
472
|
volume.create_tags(:tags => tags)
|
@@ -487,7 +516,7 @@ module Kitchen
|
|
487
516
|
end
|
488
517
|
end
|
489
518
|
|
490
|
-
# Poll a block, waiting for it to return true.
|
519
|
+
# Poll a block, waiting for it to return true. If it does not succeed
|
491
520
|
# within the configured time we destroy the instance to save people money
|
492
521
|
def wait_with_destroy(server, state, status_msg, &block)
|
493
522
|
wait_log = proc do |attempts|
|
@@ -512,7 +541,6 @@ module Kitchen
|
|
512
541
|
end
|
513
542
|
end
|
514
543
|
|
515
|
-
# rubocop:disable Lint/UnusedBlockArgument
|
516
544
|
def fetch_windows_admin_password(server, state)
|
517
545
|
wait_with_destroy(server, state, "to fetch windows admin password") do |aws_instance|
|
518
546
|
enc = server.client.get_password_data(
|
@@ -527,7 +555,6 @@ module Kitchen
|
|
527
555
|
state[:password] = pass
|
528
556
|
info("Retrieved Windows password for instance <#{state[:server_id]}>.")
|
529
557
|
end
|
530
|
-
# rubocop:enable Lint/UnusedBlockArgument
|
531
558
|
|
532
559
|
def with_request_limit_backoff(state)
|
533
560
|
retries = 0
|
@@ -544,7 +571,7 @@ module Kitchen
|
|
544
571
|
end
|
545
572
|
|
546
573
|
#
|
547
|
-
# Ordered mapping from config name to Fog name.
|
574
|
+
# Ordered mapping from config name to Fog name. Ordered by preference
|
548
575
|
# when looking up hostname.
|
549
576
|
#
|
550
577
|
INTERFACE_TYPES =
|
@@ -556,8 +583,8 @@ module Kitchen
|
|
556
583
|
}
|
557
584
|
|
558
585
|
#
|
559
|
-
# Lookup hostname of provided server.
|
560
|
-
# that interface to lookup hostname.
|
586
|
+
# Lookup hostname of provided server. If interface_type is provided use
|
587
|
+
# that interface to lookup hostname. Otherwise, try ordered list of
|
561
588
|
# options.
|
562
589
|
#
|
563
590
|
def hostname(server, interface_type = nil)
|
@@ -584,7 +611,6 @@ module Kitchen
|
|
584
611
|
instance.provisioner[:sudo] ? instance.provisioner[:sudo_command].to_s : ""
|
585
612
|
end
|
586
613
|
|
587
|
-
# rubocop:disable Metrics/MethodLength, Metrics/LineLength
|
588
614
|
def create_ec2_json(state)
|
589
615
|
if windows_os?
|
590
616
|
cmd = "New-Item -Force C:\\chef\\ohai\\hints\\ec2.json -ItemType File"
|
@@ -649,7 +675,6 @@ module Kitchen
|
|
649
675
|
</powershell>
|
650
676
|
EOH
|
651
677
|
end
|
652
|
-
# rubocop:enable Metrics/MethodLength, Metrics/LineLength
|
653
678
|
|
654
679
|
def show_chosen_image
|
655
680
|
# Print some debug stuff
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
|
+
# Copyright:: 2012-2018, Fletcher Nichol
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -21,6 +22,6 @@ module Kitchen
|
|
21
22
|
module Driver
|
22
23
|
|
23
24
|
# Version string for EC2 Test Kitchen driver
|
24
|
-
EC2_VERSION = "2.
|
25
|
+
EC2_VERSION = "2.2.0"
|
25
26
|
end
|
26
27
|
end
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Tyler Ball (<tball@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
3
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
1
17
|
require "kitchen/driver/ec2"
|
2
18
|
require "kitchen/provisioner/dummy"
|
3
19
|
require "kitchen/transport/dummy"
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Tyler Ball (<tball@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -336,25 +337,6 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
|
|
336
337
|
end
|
337
338
|
end
|
338
339
|
|
339
|
-
context "when tenancy is not supported" do
|
340
|
-
let(:config) do
|
341
|
-
{
|
342
|
-
:region => "eu-east-1",
|
343
|
-
:tenancy => "ephemeral",
|
344
|
-
}
|
345
|
-
end
|
346
|
-
it "is not added to the instance data" do
|
347
|
-
expect(generator.ec2_instance_data).to eq(
|
348
|
-
:instance_type => nil,
|
349
|
-
:ebs_optimized => nil,
|
350
|
-
:image_id => nil,
|
351
|
-
:key_name => nil,
|
352
|
-
:subnet_id => nil,
|
353
|
-
:private_ip_address => nil
|
354
|
-
)
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
340
|
context "when availability_zone and tenancy are provided" do
|
359
341
|
let(:config) do
|
360
342
|
{
|
@@ -397,25 +379,6 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
|
|
397
379
|
end
|
398
380
|
end
|
399
381
|
|
400
|
-
context "when tenancy is not supported" do
|
401
|
-
let(:config) do
|
402
|
-
{
|
403
|
-
:region => "eu-east-1",
|
404
|
-
:tenancy => "ephemeral",
|
405
|
-
}
|
406
|
-
end
|
407
|
-
it "is not added to the instance data" do
|
408
|
-
expect(generator.ec2_instance_data).to eq(
|
409
|
-
:instance_type => nil,
|
410
|
-
:ebs_optimized => nil,
|
411
|
-
:image_id => nil,
|
412
|
-
:key_name => nil,
|
413
|
-
:subnet_id => nil,
|
414
|
-
:private_ip_address => nil
|
415
|
-
)
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
382
|
context "when subnet_id is provided" do
|
420
383
|
let(:config) do
|
421
384
|
{
|
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Tyler Ball (<tball@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -264,19 +265,50 @@ describe Kitchen::Driver::Ec2 do
|
|
264
265
|
end
|
265
266
|
|
266
267
|
describe "#tag_server" do
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
268
|
+
context "with no tags specified" do
|
269
|
+
it "does not raise" do
|
270
|
+
config[:tags] = nil
|
271
|
+
expect { driver.tag_server(server) }.not_to raise_error
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context "with standard string tags" do
|
276
|
+
it "tags the server" do
|
277
|
+
config[:tags] = { :key1 => "value1", :key2 => "value2" }
|
278
|
+
expect(server).to receive(:create_tags).with(
|
279
|
+
:tags => [
|
280
|
+
{ :key => :key1, :value => "value1" },
|
281
|
+
{ :key => :key2, :value => "value2" },
|
282
|
+
]
|
283
|
+
)
|
284
|
+
driver.tag_server(server)
|
285
|
+
end
|
276
286
|
end
|
277
|
-
|
278
|
-
|
279
|
-
|
287
|
+
|
288
|
+
context "with a tag that includes a Integer value" do
|
289
|
+
it "tags the server" do
|
290
|
+
config[:tags] = { :key1 => "value1", :key2 => 1 }
|
291
|
+
expect(server).to receive(:create_tags).with(
|
292
|
+
:tags => [
|
293
|
+
{ :key => :key1, :value => "value1" },
|
294
|
+
{ :key => :key2, :value => "1" },
|
295
|
+
]
|
296
|
+
)
|
297
|
+
driver.tag_server(server)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
context "with a tag that includes a Nil value" do
|
302
|
+
it "tags the server" do
|
303
|
+
config[:tags] = { :key1 => "value1", :key2 => nil }
|
304
|
+
expect(server).to receive(:create_tags).with(
|
305
|
+
:tags => [
|
306
|
+
{ :key => :key1, :value => "value1" },
|
307
|
+
{ :key => :key2, :value => "" },
|
308
|
+
]
|
309
|
+
)
|
310
|
+
driver.tag_server(server)
|
311
|
+
end
|
280
312
|
end
|
281
313
|
end
|
282
314
|
|
@@ -285,15 +317,43 @@ describe Kitchen::Driver::Ec2 do
|
|
285
317
|
before do
|
286
318
|
allow(server).to receive(:volumes).and_return([volume])
|
287
319
|
end
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
:
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
320
|
+
context "with standard string tags" do
|
321
|
+
it "tags the instance volumes" do
|
322
|
+
config[:tags] = { :key1 => "value1", :key2 => "value2" }
|
323
|
+
expect(volume).to receive(:create_tags).with(
|
324
|
+
:tags => [
|
325
|
+
{ :key => :key1, :value => "value1" },
|
326
|
+
{ :key => :key2, :value => "value2" },
|
327
|
+
]
|
328
|
+
)
|
329
|
+
driver.tag_volumes(server)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
context "with a tag that includes a Integer value" do
|
334
|
+
it "tags the instance volumes" do
|
335
|
+
config[:tags] = { :key1 => "value1", :key2 => 2 }
|
336
|
+
expect(volume).to receive(:create_tags).with(
|
337
|
+
:tags => [
|
338
|
+
{ :key => :key1, :value => "value1" },
|
339
|
+
{ :key => :key2, :value => "2" },
|
340
|
+
]
|
341
|
+
)
|
342
|
+
driver.tag_volumes(server)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
context "with a tag that includes a Nil value" do
|
347
|
+
it "tags the instance volumes" do
|
348
|
+
config[:tags] = { :key1 => "value1", :key2 => nil }
|
349
|
+
expect(volume).to receive(:create_tags).with(
|
350
|
+
:tags => [
|
351
|
+
{ :key => :key1, :value => "value1" },
|
352
|
+
{ :key => :key2, :value => "" },
|
353
|
+
]
|
354
|
+
)
|
355
|
+
driver.tag_volumes(server)
|
356
|
+
end
|
297
357
|
end
|
298
358
|
end
|
299
359
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
#
|
3
3
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
4
|
#
|
5
|
-
# Copyright
|
5
|
+
# Copyright:: 2015-2018, Fletcher Nichol
|
6
|
+
# Copyright:: 2016-2018, Chef Software, Inc.
|
6
7
|
#
|
7
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.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: 2018-
|
11
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -148,14 +148,20 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: '0.
|
151
|
+
version: '0.9'
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.9.11
|
152
155
|
type: :development
|
153
156
|
prerelease: false
|
154
157
|
version_requirements: !ruby/object:Gem::Requirement
|
155
158
|
requirements:
|
156
159
|
- - "~>"
|
157
160
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0.
|
161
|
+
version: '0.9'
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 0.9.11
|
159
165
|
- !ruby/object:Gem::Dependency
|
160
166
|
name: chefstyle
|
161
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,7 +225,7 @@ files:
|
|
219
225
|
- spec/kitchen/driver/ec2/instance_generator_spec.rb
|
220
226
|
- spec/kitchen/driver/ec2_spec.rb
|
221
227
|
- spec/spec_helper.rb
|
222
|
-
homepage:
|
228
|
+
homepage: https://kitchen.ci/
|
223
229
|
licenses:
|
224
230
|
- Apache 2.0
|
225
231
|
metadata: {}
|