kitchen-ec2 3.10.0 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/aws/client.rb +7 -0
- data/lib/kitchen/driver/aws/instance_generator.rb +12 -8
- data/lib/kitchen/driver/aws/standard_platform/debian.rb +20 -7
- data/lib/kitchen/driver/aws/standard_platform/windows.rb +1 -1
- data/lib/kitchen/driver/ec2.rb +40 -21
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f76f759771ac4c8597dacffcf992e7d33fe1784c61be5ae6c84f00c77633b141
|
4
|
+
data.tar.gz: 324f1dd4944162dcd51bd6569dbfbabe9701ec58f6c1f8bf02ff96811bf48c65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c946144405da7ec33817582d1115ac68dc76486307d86b8d7519a238d0aa0637d03152a0aad3b96fdfad25955e40eb96c513c862f7794f1ec4aeca3d029558
|
7
|
+
data.tar.gz: 136f94bcf170b07848f8bd7dd56d2918e38482003ece6d0da4029790651e60c1cd25ddd0e13749e6d90efdf6f6cf346f9d6d2eba17c45067db04ac8e4662558d
|
@@ -75,6 +75,13 @@ module Kitchen
|
|
75
75
|
).to_a[0]
|
76
76
|
end
|
77
77
|
|
78
|
+
# check if instance exists, given an id
|
79
|
+
# @param id [String] aws instance id
|
80
|
+
# @return boolean
|
81
|
+
def instance_exists?(id)
|
82
|
+
resource.instance(id).exists?
|
83
|
+
end
|
84
|
+
|
78
85
|
def client
|
79
86
|
@client ||= ::Aws::EC2::Client.new
|
80
87
|
end
|
@@ -47,15 +47,19 @@ module Kitchen
|
|
47
47
|
vpc_id = nil
|
48
48
|
client = ::Aws::EC2::Client.new(region: config[:region])
|
49
49
|
if config[:subnet_id].nil? && config[:subnet_filter]
|
50
|
-
|
51
|
-
|
50
|
+
filters = [config[:subnet_filter]].flatten
|
51
|
+
|
52
|
+
r = { filters: [] }
|
53
|
+
filters.each do |subnet_filter|
|
54
|
+
r[:filters] <<
|
52
55
|
{
|
53
|
-
name: "tag:#{
|
54
|
-
values: [
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
name: "tag:#{subnet_filter[:tag]}",
|
57
|
+
values: [subnet_filter[:value]],
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
subnets = client.describe_subnets(r).subnets
|
62
|
+
raise "Subnets with tags '#{filters}' not found during security group creation" if subnets.empty?
|
59
63
|
|
60
64
|
# => Select the least-populated subnet if we have multiple matches
|
61
65
|
subnet = subnets.max_by { |s| s[:available_ip_address_count] }
|
@@ -23,16 +23,17 @@ module Kitchen
|
|
23
23
|
class Debian < StandardPlatform
|
24
24
|
StandardPlatform.platforms["debian"] = self
|
25
25
|
|
26
|
-
#
|
27
|
-
# and
|
26
|
+
# 12/13 are listed last since we default to the first item in the hash
|
27
|
+
# and 12/13 are not released yet. When they're released move them up
|
28
28
|
DEBIAN_CODENAMES = {
|
29
|
+
11 => "bullseye",
|
29
30
|
10 => "buster",
|
30
31
|
9 => "stretch",
|
31
32
|
8 => "jessie",
|
32
33
|
7 => "wheezy",
|
33
34
|
6 => "squeeze",
|
34
|
-
11 => "bullseye",
|
35
35
|
12 => "bookworm",
|
36
|
+
13 => "trixie",
|
36
37
|
}.freeze
|
37
38
|
|
38
39
|
# default username for this platform's ami
|
@@ -51,11 +52,23 @@ module Kitchen
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def image_search
|
54
|
-
search = {
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
search = {}
|
56
|
+
|
57
|
+
# The Debian AWS owner ID changed for releases 10 and onwards
|
58
|
+
# See https://wiki.debian.org/Amazon/EC2/HowTo/awscli
|
59
|
+
if version.nil?
|
60
|
+
search["owner-id"] = "136693071363"
|
61
|
+
search["name"] = "debian-#{DEBIAN_CODENAMES.keys.first}-*"
|
62
|
+
elsif version.to_i >= 10
|
63
|
+
search["owner-id"] = "136693071363"
|
64
|
+
search["name"] = "debian-#{version.to_i}-*"
|
65
|
+
else
|
66
|
+
search["owner-id"] = "379101102735"
|
67
|
+
search["name"] = "debian-#{codename}-*"
|
68
|
+
end
|
69
|
+
|
58
70
|
search["architecture"] = architecture if architecture
|
71
|
+
|
59
72
|
search
|
60
73
|
end
|
61
74
|
|
@@ -134,7 +134,7 @@ module Kitchen
|
|
134
134
|
|
135
135
|
def windows_name_filter # rubocop:disable Metrics/MethodLength
|
136
136
|
major, revision, service_pack = windows_version_parts
|
137
|
-
if major == 2019 || major == 2016
|
137
|
+
if major == 2022 || major == 2019 || major == 2016
|
138
138
|
"Windows_Server-#{major}-English-Full-Base-*"
|
139
139
|
elsif major == 1709 || major == 1803
|
140
140
|
"Windows_Server-#{major}-English-Core-ContainersLatest-*"
|
data/lib/kitchen/driver/ec2.rb
CHANGED
@@ -265,9 +265,8 @@ module Kitchen
|
|
265
265
|
create_ec2_json(state) if /chef/i.match?(instance.provisioner.name)
|
266
266
|
debug("ec2:create '#{state[:hostname]}'")
|
267
267
|
rescue Exception => e
|
268
|
-
# Clean up any auto-created security groups or keys on the way out.
|
269
|
-
|
270
|
-
delete_key(state)
|
268
|
+
# Clean up the instance and any auto-created security groups or keys on the way out.
|
269
|
+
destroy(state)
|
271
270
|
raise "#{e.message} in the specified region #{config[:region]}. Please check this AMI is available in this region."
|
272
271
|
end
|
273
272
|
|
@@ -285,14 +284,17 @@ module Kitchen
|
|
285
284
|
# If we are going to clean up an automatic security group, we need
|
286
285
|
# to wait for the instance to shut down. This slightly breaks the
|
287
286
|
# subsystem encapsulation, sorry not sorry.
|
288
|
-
if state[:auto_security_group_id] && server
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
info "Waited #{attempts * waiter.delay}/#{waiter.delay * waiter.max_attempts}s for instance <#{server.id}> to terminate."
|
294
|
-
end
|
287
|
+
if state[:auto_security_group_id] && server && ec2.instance_exists?(state[:server_id])
|
288
|
+
wait_log = proc do |attempts|
|
289
|
+
c = attempts * config[:retryable_sleep]
|
290
|
+
t = config[:retryable_tries] * config[:retryable_sleep]
|
291
|
+
info "Waited #{c}/#{t}s for instance <#{server.id}> to terminate."
|
295
292
|
end
|
293
|
+
server.wait_until_terminated(
|
294
|
+
max_attempts: config[:retryable_tries],
|
295
|
+
delay: config[:retryable_sleep],
|
296
|
+
before_attempt: wait_log
|
297
|
+
)
|
296
298
|
end
|
297
299
|
info("EC2 instance <#{state[:server_id]}> destroyed.")
|
298
300
|
state.delete(:server_id)
|
@@ -365,7 +367,7 @@ module Kitchen
|
|
365
367
|
if actual_platform &&
|
366
368
|
instance.transport[:username] == instance.transport.class.defaults[:username]
|
367
369
|
debug("No SSH username specified: using default username #{actual_platform.username} " \
|
368
|
-
"
|
370
|
+
"for image #{config[:image_id]}, which we detected as #{actual_platform}.")
|
369
371
|
state[:username] = actual_platform.username
|
370
372
|
end
|
371
373
|
end
|
@@ -430,15 +432,21 @@ module Kitchen
|
|
430
432
|
else
|
431
433
|
# => Enable cascading through matching subnets
|
432
434
|
client = ::Aws::EC2::Client.new(region: config[:region])
|
433
|
-
|
434
|
-
|
435
|
+
|
436
|
+
filters = [config[:subnet_filter]].flatten
|
437
|
+
|
438
|
+
r = { filters: [] }
|
439
|
+
filters.each do |subnet_filter|
|
440
|
+
r[:filters] <<
|
435
441
|
{
|
436
|
-
name: "tag:#{
|
437
|
-
values: [
|
438
|
-
}
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
+
name: "tag:#{subnet_filter[:tag]}",
|
443
|
+
values: [subnet_filter[:value]],
|
444
|
+
}
|
445
|
+
end
|
446
|
+
|
447
|
+
subnets = client.describe_subnets(r).subnets
|
448
|
+
|
449
|
+
raise "Subnets with tags '#{filters}' not found!" if subnets.empty?
|
442
450
|
|
443
451
|
configs = subnets.map do |subnet|
|
444
452
|
new_config = config.clone
|
@@ -748,8 +756,19 @@ module Kitchen
|
|
748
756
|
|
749
757
|
subnets.first.vpc_id
|
750
758
|
elsif config[:subnet_filter]
|
751
|
-
|
752
|
-
|
759
|
+
filters = [config[:subnet_filter]].flatten
|
760
|
+
|
761
|
+
r = { filters: [] }
|
762
|
+
filters.each do |subnet_filter|
|
763
|
+
r[:filters] << {
|
764
|
+
name: "tag:#{subnet_filter[:tag]}",
|
765
|
+
values: [subnet_filter[:value]],
|
766
|
+
}
|
767
|
+
end
|
768
|
+
|
769
|
+
subnets = ec2.client.describe_subnets(r).subnets
|
770
|
+
|
771
|
+
raise "Subnets with tags '#{filters}' not found during security group creation" if subnets.empty?
|
753
772
|
|
754
773
|
subnets.first.vpc_id
|
755
774
|
else
|
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.12.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: 2021-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -98,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '2.
|
101
|
+
version: '2.6'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.2.
|
108
|
+
rubygems_version: 3.2.32
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A Test Kitchen Driver for Amazon EC2
|