kitchen-ec2 3.1.0 → 3.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/lib/kitchen/driver/aws/instance_generator.rb +1 -1
- data/lib/kitchen/driver/aws/standard_platform/centos.rb +1 -0
- data/lib/kitchen/driver/aws/standard_platform/freebsd.rb +1 -2
- data/lib/kitchen/driver/aws/standard_platform/windows.rb +5 -3
- data/lib/kitchen/driver/ec2.rb +23 -16
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 828a479cf1ebe8de5423fad1926bc74f1cb66ddc1a1b4f853977424e65dd4709
|
|
4
|
+
data.tar.gz: 67851982c4d376be9ca701040e38d8e7b5cb308a7cf52cd0056da8f898558dcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1165fa8225401552970c19983091d8cb38f234a08f9f84a68ebb45cdf05b5670271e92b780b9e8fa0fdecc1c18083e3702f3ddace3561a76628226d09f67ce26
|
|
7
|
+
data.tar.gz: abe70ab29dacefda005ec11ffa0710841532e7f8407c203daf6bd782acb1c1da59d95c1c188bfca81cc20bd010d2ce7df5c6e78371eff0960f46dcbf3c885245
|
|
@@ -127,7 +127,7 @@ module Kitchen
|
|
|
127
127
|
if config[:iam_profile_name]
|
|
128
128
|
i[:iam_instance_profile] = { name: config[:iam_profile_name] }
|
|
129
129
|
end
|
|
130
|
-
|
|
130
|
+
unless config.fetch(:associate_public_ip, nil).nil?
|
|
131
131
|
i[:network_interfaces] =
|
|
132
132
|
[{
|
|
133
133
|
device_index: 0,
|
|
@@ -47,6 +47,8 @@ module Kitchen
|
|
|
47
47
|
# Windows_Server-2012-R2_RTM-
|
|
48
48
|
# "windows-2016" -> [2016, 0, nil]
|
|
49
49
|
# Windows_Server-2016-
|
|
50
|
+
# "windows-2019" -> [2019, 0, nil]
|
|
51
|
+
# Windows_Server-2019-
|
|
50
52
|
def image_search
|
|
51
53
|
search = {
|
|
52
54
|
"owner-alias" => "amazon",
|
|
@@ -94,6 +96,7 @@ module Kitchen
|
|
|
94
96
|
# 2012sp4 -> [ 2012, 0, 4 ]
|
|
95
97
|
# 2012rtm -> [ 2012, 0, 0 ]
|
|
96
98
|
# 2016 -> [ 2016, 0, nil ]
|
|
99
|
+
# 2019 -> [ 2019, 0, nil ]
|
|
97
100
|
# 1709 -> [ 1709, 0, nil ]
|
|
98
101
|
# 1803 -> [ 1803, 0, nil ]
|
|
99
102
|
def windows_version_parts
|
|
@@ -129,9 +132,8 @@ module Kitchen
|
|
|
129
132
|
|
|
130
133
|
def windows_name_filter # rubocop:disable Metrics/MethodLength
|
|
131
134
|
major, revision, service_pack = windows_version_parts
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"Windows_Server-2016-English-Full-Base-*"
|
|
135
|
+
if major == 2019 || major == 2016
|
|
136
|
+
"Windows_Server-#{major}-English-Full-Base-*"
|
|
135
137
|
elsif major == 1709 || major == 1803
|
|
136
138
|
"Windows_Server-#{major}-English-Core-ContainersLatest-*"
|
|
137
139
|
else
|
data/lib/kitchen/driver/ec2.rb
CHANGED
|
@@ -56,9 +56,7 @@ module Kitchen
|
|
|
56
56
|
default_config :region, ENV["AWS_REGION"] || "us-east-1"
|
|
57
57
|
default_config :shared_credentials_profile, ENV["AWS_PROFILE"]
|
|
58
58
|
default_config :availability_zone, nil
|
|
59
|
-
default_config :instance_type
|
|
60
|
-
driver.default_instance_type
|
|
61
|
-
end
|
|
59
|
+
default_config :instance_type, &:default_instance_type
|
|
62
60
|
default_config :ebs_optimized, false
|
|
63
61
|
default_config :security_group_ids, nil
|
|
64
62
|
default_config :security_group_filter, nil
|
|
@@ -80,9 +78,7 @@ module Kitchen
|
|
|
80
78
|
default_config :aws_secret_access_key, nil
|
|
81
79
|
default_config :aws_session_token, nil
|
|
82
80
|
default_config :aws_ssh_key_id, ENV["AWS_SSH_KEY_ID"]
|
|
83
|
-
default_config :image_id
|
|
84
|
-
driver.default_ami
|
|
85
|
-
end
|
|
81
|
+
default_config :image_id, &:default_ami
|
|
86
82
|
default_config :image_search, nil
|
|
87
83
|
default_config :username, nil
|
|
88
84
|
default_config :associate_public_ip, nil
|
|
@@ -110,7 +106,7 @@ module Kitchen
|
|
|
110
106
|
end
|
|
111
107
|
|
|
112
108
|
# TODO: remove these in 1.1
|
|
113
|
-
deprecated_configs =
|
|
109
|
+
deprecated_configs = %i{ebs_volume_size ebs_delete_on_termination ebs_device_name}
|
|
114
110
|
deprecated_configs.each do |d|
|
|
115
111
|
validations[d] = lambda do |attr, val, driver|
|
|
116
112
|
unless val.nil?
|
|
@@ -200,6 +196,7 @@ module Kitchen
|
|
|
200
196
|
|
|
201
197
|
def create(state)
|
|
202
198
|
return if state[:server_id]
|
|
199
|
+
|
|
203
200
|
update_username(state)
|
|
204
201
|
|
|
205
202
|
info(Kitchen::Util.outdent!(<<-END)) unless config[:skip_cost_warning]
|
|
@@ -422,6 +419,7 @@ module Kitchen
|
|
|
422
419
|
|
|
423
420
|
def config
|
|
424
421
|
return super unless @config
|
|
422
|
+
|
|
425
423
|
@config
|
|
426
424
|
end
|
|
427
425
|
|
|
@@ -429,7 +427,7 @@ module Kitchen
|
|
|
429
427
|
def expand_config(conf, key)
|
|
430
428
|
configs = []
|
|
431
429
|
|
|
432
|
-
if conf[key] && conf[key].
|
|
430
|
+
if conf[key] && conf[key].is_a?(Array)
|
|
433
431
|
values = conf[key]
|
|
434
432
|
values.each do |value|
|
|
435
433
|
new_config = conf.clone
|
|
@@ -446,7 +444,7 @@ module Kitchen
|
|
|
446
444
|
def submit_spots(state)
|
|
447
445
|
configs = [config]
|
|
448
446
|
expanded = []
|
|
449
|
-
keys =
|
|
447
|
+
keys = %i{instance_type subnet_id}
|
|
450
448
|
|
|
451
449
|
keys.each do |key|
|
|
452
450
|
configs.each do |conf|
|
|
@@ -492,7 +490,7 @@ module Kitchen
|
|
|
492
490
|
def create_spot_request
|
|
493
491
|
request_duration = config[:spot_wait]
|
|
494
492
|
config_spot_price = config[:spot_price].to_s
|
|
495
|
-
if
|
|
493
|
+
if %w{ondemand on-demand}.include?(config_spot_price)
|
|
496
494
|
spot_price = ""
|
|
497
495
|
else
|
|
498
496
|
spot_price = config_spot_price
|
|
@@ -543,8 +541,7 @@ module Kitchen
|
|
|
543
541
|
ready_volume_count = 0
|
|
544
542
|
if aws_instance.exists?
|
|
545
543
|
described_volume_count = ec2.client.describe_volumes(filters: [
|
|
546
|
-
{ name: "attachment.instance-id", values: ["#{state[:server_id]}"] }]
|
|
547
|
-
).volumes.length
|
|
544
|
+
{ name: "attachment.instance-id", values: ["#{state[:server_id]}"] }]).volumes.length
|
|
548
545
|
aws_instance.volumes.each { ready_volume_count += 1 }
|
|
549
546
|
end
|
|
550
547
|
(described_volume_count > 0) && (described_volume_count == ready_volume_count)
|
|
@@ -626,6 +623,7 @@ module Kitchen
|
|
|
626
623
|
yield
|
|
627
624
|
rescue ::Aws::EC2::Errors::RequestLimitExceeded, ::Aws::Waiters::Errors::UnexpectedError => e
|
|
628
625
|
raise unless retries < 5 && e.message.include?("Request limit exceeded")
|
|
626
|
+
|
|
629
627
|
retries += 1
|
|
630
628
|
info("Request limit exceeded for instance <#{state[:server_id]}>." \
|
|
631
629
|
" Trying again in #{retries**2} seconds.")
|
|
@@ -689,7 +687,7 @@ module Kitchen
|
|
|
689
687
|
def default_windows_user_data
|
|
690
688
|
base_script = Kitchen::Util.outdent!(<<-EOH)
|
|
691
689
|
$OSVersion = (get-itemproperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" -Name ProductName).ProductName
|
|
692
|
-
If($OSVersion.contains('2016') -Or $OSVersion -eq 'Windows Server Datacenter') {
|
|
690
|
+
If($OSVersion.contains('2016') -Or $OSVersion.contains('2019') -Or $OSVersion -eq 'Windows Server Datacenter') {
|
|
693
691
|
New-Item -ItemType Directory -Force -Path 'C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Log'
|
|
694
692
|
$logfile='C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Log\\kitchen-ec2.log'
|
|
695
693
|
# EC2Launch doesn't init extra disks by default
|
|
@@ -779,11 +777,17 @@ module Kitchen
|
|
|
779
777
|
# @return [void]
|
|
780
778
|
def create_security_group(state)
|
|
781
779
|
return if state[:auto_security_group_id]
|
|
780
|
+
|
|
782
781
|
# Work out which VPC, if any, we are creating in.
|
|
783
782
|
vpc_id = if config[:subnet_id]
|
|
784
783
|
# Get the VPC ID for the subnet.
|
|
785
784
|
subnets = ec2.client.describe_subnets(filters: [{ name: "subnet-id", values: [config[:subnet_id]] }]).subnets
|
|
786
785
|
raise "Subnet #{config[:subnet_id]} not found during security group creation" if subnets.empty?
|
|
786
|
+
|
|
787
|
+
subnets.first.vpc_id
|
|
788
|
+
elsif config[:subnet_filter]
|
|
789
|
+
subnets = ec2.client.describe_subnets(filters: [{ name: "tag:#{config[:subnet_filter][:tag]}", values: [config[:subnet_filter][:value]] }]).subnets
|
|
790
|
+
raise "Subnets with tag '#{config[:subnet_filter][:tag]}=#{config[:subnet_filter][:value]}' not found during security group creation" if subnets.empty?
|
|
787
791
|
subnets.first.vpc_id
|
|
788
792
|
else
|
|
789
793
|
# Try to check for a default VPC.
|
|
@@ -799,13 +803,13 @@ module Kitchen
|
|
|
799
803
|
# Create the SG.
|
|
800
804
|
params = {
|
|
801
805
|
group_name: "kitchen-#{Array.new(8) { rand(36).to_s(36) }.join}",
|
|
802
|
-
description: "Test Kitchen for #{instance.name} by #{Etc.getlogin ||
|
|
806
|
+
description: "Test Kitchen for #{instance.name} by #{Etc.getlogin || "nologin"} on #{Socket.gethostname}",
|
|
803
807
|
}
|
|
804
808
|
params[:vpc_id] = vpc_id if vpc_id
|
|
805
809
|
resp = ec2.client.create_security_group(params)
|
|
806
810
|
state[:auto_security_group_id] = resp.group_id
|
|
807
811
|
info("Created automatic security group #{state[:auto_security_group_id]}")
|
|
808
|
-
debug(" in VPC #{vpc_id ||
|
|
812
|
+
debug(" in VPC #{vpc_id || "none"}")
|
|
809
813
|
# Set up SG rules.
|
|
810
814
|
ec2.client.authorize_security_group_ingress(
|
|
811
815
|
group_id: state[:auto_security_group_id],
|
|
@@ -828,6 +832,7 @@ module Kitchen
|
|
|
828
832
|
# @return [void]
|
|
829
833
|
def create_key(state)
|
|
830
834
|
return if state[:auto_key_id]
|
|
835
|
+
|
|
831
836
|
# Encode a bunch of metadata into the name because that's all we can
|
|
832
837
|
# set for a key pair.
|
|
833
838
|
name_parts = [
|
|
@@ -842,7 +847,7 @@ module Kitchen
|
|
|
842
847
|
# to rapidly exhaust local entropy by creating a lot of keys. So this is
|
|
843
848
|
# probably fine. If you want very high security, probably don't use this
|
|
844
849
|
# feature anyway.
|
|
845
|
-
resp = ec2.client.create_key_pair(key_name: "kitchen-#{name_parts.join(
|
|
850
|
+
resp = ec2.client.create_key_pair(key_name: "kitchen-#{name_parts.join("-")}")
|
|
846
851
|
state[:auto_key_id] = resp.key_name
|
|
847
852
|
info("Created automatic key pair #{state[:auto_key_id]}")
|
|
848
853
|
# Write the key out with safe permissions
|
|
@@ -862,6 +867,7 @@ module Kitchen
|
|
|
862
867
|
# @return [void]
|
|
863
868
|
def delete_security_group(state)
|
|
864
869
|
return unless state[:auto_security_group_id]
|
|
870
|
+
|
|
865
871
|
info("Removing automatic security group #{state[:auto_security_group_id]}")
|
|
866
872
|
ec2.client.delete_security_group(group_id: state[:auto_security_group_id])
|
|
867
873
|
state.delete(:auto_security_group_id)
|
|
@@ -874,6 +880,7 @@ module Kitchen
|
|
|
874
880
|
# @return [void]
|
|
875
881
|
def delete_key(state)
|
|
876
882
|
return unless state[:auto_key_id]
|
|
883
|
+
|
|
877
884
|
info("Removing automatic key pair #{state[:auto_key_id]}")
|
|
878
885
|
ec2.client.delete_key_pair(key_name: state[:auto_key_id])
|
|
879
886
|
state.delete(:auto_key_id)
|
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: 3.
|
|
4
|
+
version: 3.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: 2019-
|
|
11
|
+
date: 2019-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -76,16 +76,22 @@ dependencies:
|
|
|
76
76
|
name: retryable
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
-
- - "
|
|
79
|
+
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: '2.0'
|
|
82
|
+
- - "<"
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '4.0'
|
|
82
85
|
type: :runtime
|
|
83
86
|
prerelease: false
|
|
84
87
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
88
|
requirements:
|
|
86
|
-
- - "
|
|
89
|
+
- - ">="
|
|
87
90
|
- !ruby/object:Gem::Version
|
|
88
91
|
version: '2.0'
|
|
92
|
+
- - "<"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '4.0'
|
|
89
95
|
- !ruby/object:Gem::Dependency
|
|
90
96
|
name: rspec
|
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -162,14 +168,14 @@ dependencies:
|
|
|
162
168
|
requirements:
|
|
163
169
|
- - '='
|
|
164
170
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 0.
|
|
171
|
+
version: 0.13.3
|
|
166
172
|
type: :development
|
|
167
173
|
prerelease: false
|
|
168
174
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
175
|
requirements:
|
|
170
176
|
- - '='
|
|
171
177
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 0.
|
|
178
|
+
version: 0.13.3
|
|
173
179
|
- !ruby/object:Gem::Dependency
|
|
174
180
|
name: climate_control
|
|
175
181
|
requirement: !ruby/object:Gem::Requirement
|