kitchen-ec2 3.7.2 → 3.10.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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bf47b3328885d0439de770cf9e683fb9bddbab66b0d0bf40f6ab17190c7cf15
|
4
|
+
data.tar.gz: 0e384572b5d252a367c9dd689f48d64764e4540a3ccba34399402eeca7a80226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dba5e5835f48d9505a967b7d1c64f76cfd70532a6956f8c8bada246814f5affa0ebfc09176354e7f719663347056f3332176489e64b8471f073cb2452f055f6
|
7
|
+
data.tar.gz: 787c72dc701db53331e399c0080d0bcce09d9657e8814bddf3d359186ed30d409391c068b545b09dbce9a527d0fcb793d3a79197058933f5f40d3d2dd21fcbeb
|
@@ -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
|
@@ -23,8 +23,8 @@ module Kitchen
|
|
23
23
|
class Debian < StandardPlatform
|
24
24
|
StandardPlatform.platforms["debian"] = self
|
25
25
|
|
26
|
-
#
|
27
|
-
# and
|
26
|
+
# 11/12 are listed last since we default to the first item in the hash
|
27
|
+
# and 11/12 are not released yet. When they're released move them up
|
28
28
|
DEBIAN_CODENAMES = {
|
29
29
|
10 => "buster",
|
30
30
|
9 => "stretch",
|
@@ -210,10 +210,10 @@ module Kitchen
|
|
210
210
|
images = images.sort_by(&:creation_date).reverse
|
211
211
|
# P5: We prefer x86_64 over i386 (if available)
|
212
212
|
images = prefer(images) { |image| image.architecture == "x86_64" }
|
213
|
-
# P4: We prefer
|
213
|
+
# P4: We prefer (SSD) (if available)
|
214
214
|
images = prefer(images) do |image|
|
215
215
|
image.block_device_mappings.any? do |b|
|
216
|
-
b.device_name == image.root_device_name && b.ebs && b.ebs.volume_type ==
|
216
|
+
b.device_name == image.root_device_name && b.ebs && %w{gp3 gp2}.any? { |t| b.ebs.volume_type == t }
|
217
217
|
end
|
218
218
|
end
|
219
219
|
# P3: We prefer ebs over instance_store (if available)
|
data/lib/kitchen/driver/ec2.rb
CHANGED
@@ -56,7 +56,8 @@ module Kitchen
|
|
56
56
|
default_config :shared_credentials_profile, ENV["AWS_PROFILE"]
|
57
57
|
default_config :availability_zone, nil
|
58
58
|
default_config :instance_type, &:default_instance_type
|
59
|
-
default_config :ebs_optimized,
|
59
|
+
default_config :ebs_optimized, false
|
60
|
+
default_config :delete_on_termination, true
|
60
61
|
default_config :security_group_ids, nil
|
61
62
|
default_config :security_group_filter, nil
|
62
63
|
default_config :security_group_cidr_ip, "0.0.0.0/0"
|
@@ -260,13 +261,14 @@ module Kitchen
|
|
260
261
|
|
261
262
|
info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
|
262
263
|
instance.transport.connection(state).wait_until_ready
|
264
|
+
attach_network_interface(state) unless config[:elastic_network_interface_id].nil?
|
263
265
|
create_ec2_json(state) if /chef/i.match?(instance.provisioner.name)
|
264
266
|
debug("ec2:create '#{state[:hostname]}'")
|
265
|
-
rescue Exception
|
267
|
+
rescue Exception => e
|
266
268
|
# Clean up any auto-created security groups or keys on the way out.
|
267
269
|
delete_security_group(state)
|
268
270
|
delete_key(state)
|
269
|
-
raise
|
271
|
+
raise "#{e.message} in the specified region #{config[:region]}. Please check this AMI is available in this region."
|
270
272
|
end
|
271
273
|
|
272
274
|
def destroy(state)
|
@@ -283,7 +285,7 @@ module Kitchen
|
|
283
285
|
# If we are going to clean up an automatic security group, we need
|
284
286
|
# to wait for the instance to shut down. This slightly breaks the
|
285
287
|
# subsystem encapsulation, sorry not sorry.
|
286
|
-
if state[:auto_security_group_id] && server
|
288
|
+
if state[:auto_security_group_id] && server && ec2.instance_exists?(state[:server_id])
|
287
289
|
server.wait_until_terminated do |waiter|
|
288
290
|
waiter.max_attempts = config[:retryable_tries]
|
289
291
|
waiter.delay = config[:retryable_sleep]
|
@@ -318,17 +320,14 @@ module Kitchen
|
|
318
320
|
end
|
319
321
|
|
320
322
|
def default_instance_type
|
321
|
-
@instance_type ||=
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
"t1.micro"
|
330
|
-
end
|
331
|
-
end
|
323
|
+
@instance_type ||= if image && image.virtualization_type == "hvm"
|
324
|
+
info("instance_type not specified. Using free tier t2.micro instance ...")
|
325
|
+
"t2.micro"
|
326
|
+
else
|
327
|
+
info("instance_type not specified. Using free tier t1.micro instance since" \
|
328
|
+
" image is paravirtual (pick an hvm image to use the superior t2.micro!) ...")
|
329
|
+
"t1.micro"
|
330
|
+
end
|
332
331
|
end
|
333
332
|
|
334
333
|
# The actual platform is the platform detected from the image
|
@@ -459,12 +458,10 @@ module Kitchen
|
|
459
458
|
|
460
459
|
errs = []
|
461
460
|
configs.each do |conf|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
errs.append(e)
|
467
|
-
end
|
461
|
+
@config = conf
|
462
|
+
return submit_spot
|
463
|
+
rescue => e
|
464
|
+
errs.append(e)
|
468
465
|
end
|
469
466
|
raise ["Could not create a spot instance:", errs].flatten.join("\n")
|
470
467
|
end
|
@@ -473,7 +470,6 @@ module Kitchen
|
|
473
470
|
debug("Creating EC2 Spot Instance..")
|
474
471
|
instance_data = instance_generator.ec2_instance_data
|
475
472
|
|
476
|
-
request_duration = config[:spot_wait]
|
477
473
|
config_spot_price = config[:spot_price].to_s
|
478
474
|
if %w{ondemand on-demand}.include?(config_spot_price)
|
479
475
|
spot_price = ""
|
@@ -481,9 +477,10 @@ module Kitchen
|
|
481
477
|
spot_price = config_spot_price
|
482
478
|
end
|
483
479
|
spot_options = {
|
484
|
-
|
485
|
-
|
486
|
-
instance_interruption_behavior
|
480
|
+
# Must use one-time in order to use instance_interruption_behavior=terminate
|
481
|
+
# spot_instance_type: "one-time", # default
|
482
|
+
# Must use instance_interruption_behavior=terminate in order to use block_duration_minutes
|
483
|
+
# instance_interruption_behavior: "terminate", # default
|
487
484
|
}
|
488
485
|
if config[:block_duration_minutes]
|
489
486
|
spot_options[:block_duration_minutes] = config[:block_duration_minutes]
|
@@ -785,7 +782,9 @@ module Kitchen
|
|
785
782
|
ip_protocol: "tcp",
|
786
783
|
from_port: port,
|
787
784
|
to_port: port,
|
788
|
-
ip_ranges:
|
785
|
+
ip_ranges: Array(config[:security_group_cidr_ip]).map do |cidr_ip|
|
786
|
+
{ cidr_ip: cidr_ip }
|
787
|
+
end,
|
789
788
|
}
|
790
789
|
end
|
791
790
|
)
|
@@ -826,6 +825,31 @@ module Kitchen
|
|
826
825
|
state[:ssh_key] = key_path
|
827
826
|
end
|
828
827
|
|
828
|
+
def attach_network_interface(state)
|
829
|
+
info("Attaching Network interface <#{config[:elastic_network_interface_id]}> with the instance <#{state[:server_id]}> .")
|
830
|
+
client = ::Aws::EC2::Client.new(region: config[:region])
|
831
|
+
begin
|
832
|
+
check_eni = client.describe_network_interface_attribute({
|
833
|
+
attribute: "attachment",
|
834
|
+
network_interface_id: config[:elastic_network_interface_id],
|
835
|
+
})
|
836
|
+
if check_eni.attachment.nil?
|
837
|
+
unless state[:server_id].nil?
|
838
|
+
client.attach_network_interface({
|
839
|
+
device_index: 1,
|
840
|
+
instance_id: state[:server_id],
|
841
|
+
network_interface_id: config[:elastic_network_interface_id],
|
842
|
+
})
|
843
|
+
info("Attached Network interface <#{config[:elastic_network_interface_id]}> with the instance <#{state[:server_id]}> .")
|
844
|
+
end
|
845
|
+
else
|
846
|
+
puts "ENI #{config[:elastic_network_interface_id]} already attached."
|
847
|
+
end
|
848
|
+
rescue ::Aws::EC2::Errors::InvalidNetworkInterfaceIDNotFound => e
|
849
|
+
warn("#{e}")
|
850
|
+
end
|
851
|
+
end
|
852
|
+
|
829
853
|
# Clean up a temporary security group for this instance.
|
830
854
|
#
|
831
855
|
# @api private
|
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.10.1
|
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: 2021-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 1.4.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '4'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 1.4.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '4'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: aws-sdk-ec2
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,90 +64,6 @@ dependencies:
|
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '4.0'
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rspec
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '3.2'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '3.2'
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: countloc
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0.4'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - "~>"
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0.4'
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: maruku
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0.6'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '0.6'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: yard
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: 0.9.11
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 0.9.11
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: chefstyle
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - '='
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 1.4.0
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - '='
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 1.4.0
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: climate_control
|
139
|
-
requirement: !ruby/object:Gem::Requirement
|
140
|
-
requirements:
|
141
|
-
- - ">="
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
144
|
-
type: :development
|
145
|
-
prerelease: false
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '0'
|
151
67
|
description: A Test Kitchen Driver for Amazon EC2
|
152
68
|
email:
|
153
69
|
- fnichol@nichol.ca
|
@@ -182,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
98
|
requirements:
|
183
99
|
- - ">="
|
184
100
|
- !ruby/object:Gem::Version
|
185
|
-
version: '2.
|
101
|
+
version: '2.5'
|
186
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
103
|
requirements:
|
188
104
|
- - ">="
|
189
105
|
- !ruby/object:Gem::Version
|
190
106
|
version: '0'
|
191
107
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.2.22
|
193
109
|
signing_key:
|
194
110
|
specification_version: 4
|
195
111
|
summary: A Test Kitchen Driver for Amazon EC2
|