kitchen-ec2 3.11.0 → 3.13.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 +13 -8
- data/lib/kitchen/driver/ec2.rb +51 -33
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c5ed0f1bbc994d156a6374c98a1c48f00d2f789f8540b0cb33ae0755996ffca5
|
|
4
|
+
data.tar.gz: 0f5f90acb192d7a649ebd9d7861ed2bfbec2ae1665d32c5e66d75685518b1eff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 890a0a34755ab636605a8fcfbc45ce8c0f055adb0fa5404c48d516060da3089628091d37bbc9ad555601d742f40647183f2b34988dc703ca03477722b3dfb1bf
|
|
7
|
+
data.tar.gz: 617aaee4fdd8b335e17731621abb9ae140b73286e4da2e77adbb46cdc560789f02eeb85f208217e3ffbd03746c52a46f4ae051d93ab1436fb2fb8f3f2b267351
|
|
@@ -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] }
|
|
@@ -149,6 +153,7 @@ module Kitchen
|
|
|
149
153
|
i[:block_device_mappings] = config[:block_device_mappings]
|
|
150
154
|
end
|
|
151
155
|
i[:security_group_ids] = Array(config[:security_group_ids]) if config[:security_group_ids]
|
|
156
|
+
i[:metadata_options] = config[:metadata_options] if config[:metadata_options]
|
|
152
157
|
i[:user_data] = prepared_user_data if prepared_user_data
|
|
153
158
|
if config[:iam_profile_name]
|
|
154
159
|
i[:iam_instance_profile] = { name: config[:iam_profile_name] }
|
data/lib/kitchen/driver/ec2.rb
CHANGED
|
@@ -251,23 +251,14 @@ module Kitchen
|
|
|
251
251
|
wait_until_ready(server, state)
|
|
252
252
|
end
|
|
253
253
|
|
|
254
|
-
if windows_os? &&
|
|
255
|
-
instance.transport[:username] =~ /administrator/i &&
|
|
256
|
-
instance.transport[:password].nil?
|
|
257
|
-
# If we're logging into the administrator user and a password isn't
|
|
258
|
-
# supplied, try to fetch it from the AWS instance
|
|
259
|
-
fetch_windows_admin_password(server, state)
|
|
260
|
-
end
|
|
261
|
-
|
|
262
254
|
info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
|
|
263
255
|
instance.transport.connection(state).wait_until_ready
|
|
264
256
|
attach_network_interface(state) unless config[:elastic_network_interface_id].nil?
|
|
265
257
|
create_ec2_json(state) if /chef/i.match?(instance.provisioner.name)
|
|
266
258
|
debug("ec2:create '#{state[:hostname]}'")
|
|
267
259
|
rescue Exception => e
|
|
268
|
-
# Clean up any auto-created security groups or keys on the way out.
|
|
269
|
-
|
|
270
|
-
delete_key(state)
|
|
260
|
+
# Clean up the instance and any auto-created security groups or keys on the way out.
|
|
261
|
+
destroy(state)
|
|
271
262
|
raise "#{e.message} in the specified region #{config[:region]}. Please check this AMI is available in this region."
|
|
272
263
|
end
|
|
273
264
|
|
|
@@ -286,13 +277,16 @@ module Kitchen
|
|
|
286
277
|
# to wait for the instance to shut down. This slightly breaks the
|
|
287
278
|
# subsystem encapsulation, sorry not sorry.
|
|
288
279
|
if state[:auto_security_group_id] && server && ec2.instance_exists?(state[:server_id])
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
info "Waited #{attempts * waiter.delay}/#{waiter.delay * waiter.max_attempts}s for instance <#{server.id}> to terminate."
|
|
294
|
-
end
|
|
280
|
+
wait_log = proc do |attempts|
|
|
281
|
+
c = attempts * config[:retryable_sleep]
|
|
282
|
+
t = config[:retryable_tries] * config[:retryable_sleep]
|
|
283
|
+
info "Waited #{c}/#{t}s for instance <#{server.id}> to terminate."
|
|
295
284
|
end
|
|
285
|
+
server.wait_until_terminated(
|
|
286
|
+
max_attempts: config[:retryable_tries],
|
|
287
|
+
delay: config[:retryable_sleep],
|
|
288
|
+
before_attempt: wait_log
|
|
289
|
+
)
|
|
296
290
|
end
|
|
297
291
|
info("EC2 instance <#{state[:server_id]}> destroyed.")
|
|
298
292
|
state.delete(:server_id)
|
|
@@ -365,7 +359,7 @@ module Kitchen
|
|
|
365
359
|
if actual_platform &&
|
|
366
360
|
instance.transport[:username] == instance.transport.class.defaults[:username]
|
|
367
361
|
debug("No SSH username specified: using default username #{actual_platform.username} " \
|
|
368
|
-
"
|
|
362
|
+
"for image #{config[:image_id]}, which we detected as #{actual_platform}.")
|
|
369
363
|
state[:username] = actual_platform.username
|
|
370
364
|
end
|
|
371
365
|
end
|
|
@@ -430,15 +424,21 @@ module Kitchen
|
|
|
430
424
|
else
|
|
431
425
|
# => Enable cascading through matching subnets
|
|
432
426
|
client = ::Aws::EC2::Client.new(region: config[:region])
|
|
433
|
-
|
|
434
|
-
|
|
427
|
+
|
|
428
|
+
filters = [config[:subnet_filter]].flatten
|
|
429
|
+
|
|
430
|
+
r = { filters: [] }
|
|
431
|
+
filters.each do |subnet_filter|
|
|
432
|
+
r[:filters] <<
|
|
435
433
|
{
|
|
436
|
-
name: "tag:#{
|
|
437
|
-
values: [
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
434
|
+
name: "tag:#{subnet_filter[:tag]}",
|
|
435
|
+
values: [subnet_filter[:value]],
|
|
436
|
+
}
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
subnets = client.describe_subnets(r).subnets
|
|
440
|
+
|
|
441
|
+
raise "Subnets with tags '#{filters}' not found!" if subnets.empty?
|
|
442
442
|
|
|
443
443
|
configs = subnets.map do |subnet|
|
|
444
444
|
new_config = config.clone
|
|
@@ -528,12 +528,19 @@ module Kitchen
|
|
|
528
528
|
state[:hostname] = hostname(aws_instance, nil)
|
|
529
529
|
end
|
|
530
530
|
if ready && windows_os?
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
531
|
+
if instance.transport[:username] =~ /administrator/i &&
|
|
532
|
+
instance.transport[:password].nil?
|
|
533
|
+
# If we're logging into the administrator user and a password isn't
|
|
534
|
+
# supplied, try to fetch it from the AWS instance
|
|
535
|
+
fetch_windows_admin_password(server, state)
|
|
536
|
+
else
|
|
537
|
+
output = server.console_output.output
|
|
538
|
+
unless output.nil?
|
|
539
|
+
output = Base64.decode64(output)
|
|
540
|
+
debug "Console output: --- \n#{output}"
|
|
541
|
+
end
|
|
542
|
+
ready = !!(output =~ /Windows is Ready to use/)
|
|
535
543
|
end
|
|
536
|
-
ready = !!(output =~ /Windows is Ready to use/)
|
|
537
544
|
end
|
|
538
545
|
ready
|
|
539
546
|
end
|
|
@@ -748,8 +755,19 @@ module Kitchen
|
|
|
748
755
|
|
|
749
756
|
subnets.first.vpc_id
|
|
750
757
|
elsif config[:subnet_filter]
|
|
751
|
-
|
|
752
|
-
|
|
758
|
+
filters = [config[:subnet_filter]].flatten
|
|
759
|
+
|
|
760
|
+
r = { filters: [] }
|
|
761
|
+
filters.each do |subnet_filter|
|
|
762
|
+
r[:filters] << {
|
|
763
|
+
name: "tag:#{subnet_filter[:tag]}",
|
|
764
|
+
values: [subnet_filter[:value]],
|
|
765
|
+
}
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
subnets = ec2.client.describe_subnets(r).subnets
|
|
769
|
+
|
|
770
|
+
raise "Subnets with tags '#{filters}' not found during security group creation" if subnets.empty?
|
|
753
771
|
|
|
754
772
|
subnets.first.vpc_id
|
|
755
773
|
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.13.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: 2022-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
105
105
|
- !ruby/object:Gem::Version
|
|
106
106
|
version: '0'
|
|
107
107
|
requirements: []
|
|
108
|
-
rubygems_version: 3.2.
|
|
108
|
+
rubygems_version: 3.2.3
|
|
109
109
|
signing_key:
|
|
110
110
|
specification_version: 4
|
|
111
111
|
summary: A Test Kitchen Driver for Amazon EC2
|