knife-ec2 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/ec2_ami_list.rb +1 -1
- data/lib/chef/knife/ec2_flavor_list.rb +1 -1
- data/lib/chef/knife/ec2_server_create.rb +27 -28
- data/lib/chef/knife/ec2_server_delete.rb +1 -1
- data/lib/chef/knife/ec2_server_list.rb +1 -1
- data/lib/chef/knife/helpers/ec2_base.rb +8 -1
- data/lib/knife-ec2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f43a6515a88b80445a05b61b03dda664c4ca4ae24e6e592f26afc6c65c6d24
|
4
|
+
data.tar.gz: fa1c4d420f2139ae9e7f737a1f6f063ab1627f6a8fde268d46520e4bd7807f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ec76eff0479dd69474094ff0c4cfc1ad216a5bb4eb95a8053b33bf85600fe9bedef43b62eb6447fe4e1c0f0df5b18904df353168ab90f9ccaf44bba767be188
|
7
|
+
data.tar.gz: ca9413bd62b4f62631251dc8ba536553636cee0b8b72f7964b5fd0b12955aeae0bf04128b59f9a6ac2df4a547a287a6660c2d4803fa8d431460240e7d6e1de09
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
# By default owner is aws-marketplace but you can specify following owner with the help of -o or --owner
|
28
28
|
# * self => Displays the list of AMIs created by the user
|
29
29
|
# * aws-marketplace => Displays all AMIs form trusted vendors like Ubuntu, Microsoft, SAP, Zend as well as many open source offering
|
30
|
-
# *
|
30
|
+
# * microsoft => Displays only Microsoft vendor AMIs
|
31
31
|
#
|
32
32
|
# == Platform
|
33
33
|
# By default all platform AMI's will display but you can filter your response
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
banner "knife ec2 flavor list (options) [DEPRECATED]"
|
28
28
|
|
29
29
|
def run
|
30
|
-
ui.error("knife ec2 flavor list has been deprecated as this functionality is not provided by the AWS API the previous
|
30
|
+
ui.error("knife ec2 flavor list has been deprecated as this functionality is not provided by the AWS API the previous implementation relied upon hardcoded values that were often incorrect. For an up to date list of instance types see https://www.ec2instances.info/")
|
31
31
|
exit 1
|
32
32
|
end
|
33
33
|
end
|
@@ -28,9 +28,9 @@ class Chef
|
|
28
28
|
include Knife::Ec2Base
|
29
29
|
|
30
30
|
deps do
|
31
|
-
require "tempfile"
|
32
|
-
require "uri"
|
33
|
-
require "net/ssh"
|
31
|
+
require "tempfile" unless defined?(Tempfile)
|
32
|
+
require "uri" unless defined?(URI)
|
33
|
+
require "net/ssh" unless defined?(Net::SSH)
|
34
34
|
require "net/ssh/gateway"
|
35
35
|
Chef::Knife::Bootstrap.load_deps
|
36
36
|
end
|
@@ -104,9 +104,11 @@ class Chef
|
|
104
104
|
long: "--ebs-optimized",
|
105
105
|
description: "Enabled optimized EBS I/O"
|
106
106
|
|
107
|
-
option :
|
108
|
-
long: "--ebs-
|
109
|
-
description: "
|
107
|
+
option :ebs_delete_on_term,
|
108
|
+
long: "--ebs-delete-on-term",
|
109
|
+
description: "Delete EBS volume on instance termination",
|
110
|
+
boolean: true,
|
111
|
+
default: true
|
110
112
|
|
111
113
|
option :secret,
|
112
114
|
long: "--secret ",
|
@@ -624,12 +626,18 @@ class Chef
|
|
624
626
|
exit 1
|
625
627
|
end
|
626
628
|
|
627
|
-
if config[:ebs_volume_type] && ! %w{gp2 io1 standard}.include?(config[:ebs_volume_type])
|
628
|
-
ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2'")
|
629
|
+
if config[:ebs_volume_type] && ! %w{gp2 io1 standard st1 sc1}.include?(config[:ebs_volume_type])
|
630
|
+
ui.error("--ebs-volume-type must be 'standard' or 'io1' or 'gp2' or 'st1' or 'sc1'")
|
629
631
|
msg opt_parser
|
630
632
|
exit 1
|
631
633
|
end
|
632
634
|
|
635
|
+
# validation for ebs_size
|
636
|
+
if (%w{st1 sc1}.include?(config[:ebs_volume_type])) && ! config[:ebs_size].to_i.between?(500, 16384)
|
637
|
+
ui.error("--ebs-size should be in between 500-16384 for 'st1' or 'sc1' ebs volume type.")
|
638
|
+
exit 1
|
639
|
+
end
|
640
|
+
|
633
641
|
if config[:security_groups] && config[:security_groups].class == String
|
634
642
|
ui.error("Invalid value type for knife[:security_groups] in knife configuration file (i.e knife.rb/config.rb). Type should be array. e.g - knife[:security_groups] = ['sgroup1']")
|
635
643
|
exit 1
|
@@ -708,7 +716,7 @@ class Chef
|
|
708
716
|
|
709
717
|
if winrm?
|
710
718
|
reg = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,40}$/
|
711
|
-
unless config[:connection_password]
|
719
|
+
unless config[:connection_password]&.match?(reg)
|
712
720
|
ui.error("Complexity requirements are not met. Password length should be 8-40 characters and include: 1 uppercase, 1 lowercase, 1 digit, and 1 special character")
|
713
721
|
exit 1
|
714
722
|
end
|
@@ -826,7 +834,7 @@ class Chef
|
|
826
834
|
|
827
835
|
# base64-encoded text
|
828
836
|
def encode_data(text)
|
829
|
-
require "base64"
|
837
|
+
require "base64" unless defined?(Base64)
|
830
838
|
Base64.encode64(text)
|
831
839
|
end
|
832
840
|
|
@@ -907,7 +915,7 @@ class Chef
|
|
907
915
|
attributes[:ebs_optimized] = !!config[:ebs_optimized]
|
908
916
|
|
909
917
|
if ami.root_device_type == "ebs"
|
910
|
-
if config[:ebs_encrypted]
|
918
|
+
if config[:ebs_encrypted] || %w{st1 sc1}.include?(config[:ebs_volume_type])
|
911
919
|
ami_map = ami.block_device_mappings[1]
|
912
920
|
else
|
913
921
|
ami_map = ami.block_device_mappings.first
|
@@ -924,11 +932,9 @@ class Chef
|
|
924
932
|
msg opt_parser
|
925
933
|
exit 1
|
926
934
|
end
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
ami_map.ebs.delete_on_termination if ami_map.ebs.respond_to?(:delete_on_termination)
|
931
|
-
end
|
935
|
+
|
936
|
+
delete_term = config[:ebs_delete_on_term]
|
937
|
+
|
932
938
|
iops_rate = begin
|
933
939
|
if config[:ebs_provisioned_iops]
|
934
940
|
Integer(config[:ebs_provisioned_iops]).to_s
|
@@ -1321,12 +1327,11 @@ class Chef
|
|
1321
1327
|
end
|
1322
1328
|
|
1323
1329
|
def decrypt_admin_password(encoded_password, key)
|
1324
|
-
require "base64"
|
1325
|
-
require "openssl"
|
1330
|
+
require "base64" unless defined?(Base64)
|
1331
|
+
require "openssl" unless defined?(OpenSSL)
|
1326
1332
|
private_key = OpenSSL::PKey::RSA.new(key)
|
1327
1333
|
encrypted_password = Base64.decode64(encoded_password)
|
1328
|
-
|
1329
|
-
password
|
1334
|
+
private_key.private_decrypt(encrypted_password)
|
1330
1335
|
end
|
1331
1336
|
|
1332
1337
|
def check_windows_password_available(server_id)
|
@@ -1347,7 +1352,7 @@ class Chef
|
|
1347
1352
|
data = File.read(config[:ssh_identity_file])
|
1348
1353
|
config[:connection_password] = decrypt_admin_password(response.password_data, data)
|
1349
1354
|
else
|
1350
|
-
print "\n#{ui.color("
|
1355
|
+
print "\n#{ui.color("Fetching instance details: \n", :magenta)}"
|
1351
1356
|
end
|
1352
1357
|
else
|
1353
1358
|
ui.error("Cannot find SSH Identity file, required to fetch dynamically generated password")
|
@@ -1399,13 +1404,7 @@ class Chef
|
|
1399
1404
|
end
|
1400
1405
|
|
1401
1406
|
def server_name
|
1402
|
-
|
1403
|
-
|
1404
|
-
if !server.public_dns_name.empty?
|
1405
|
-
server.public_dns_name
|
1406
|
-
else
|
1407
|
-
server.private_ip_address
|
1408
|
-
end
|
1407
|
+
server ? connection_host : nil
|
1409
1408
|
end
|
1410
1409
|
|
1411
1410
|
alias host_descriptor server_name
|
@@ -148,7 +148,7 @@ class Chef
|
|
148
148
|
server_data[id] = i.instances[0].send(id)
|
149
149
|
end
|
150
150
|
|
151
|
-
server_data["name"] = i.instances[0].tags
|
151
|
+
server_data["name"] = find_name_tag(i.instances[0].tags)
|
152
152
|
server_data["az"] = i.instances[0].placement.availability_zone
|
153
153
|
server_data["iam_instance_profile"] = ( i.instances[0].iam_instance_profile.nil? ? nil : i.instances[0].iam_instance_profile.arn[%r{instance-profile/(.*)}] )
|
154
154
|
server_data["security_groups"] = i.instances[0].security_groups.map(&:group_name).join(", ")
|
@@ -151,7 +151,7 @@ class Chef
|
|
151
151
|
server_data["id"] = server_data["instance_id"]
|
152
152
|
|
153
153
|
tags = server_obj.instances[0].tags.map(&:value)
|
154
|
-
server_data["name"] =
|
154
|
+
server_data["name"] = find_name_tag(server_obj.instances[0].tags)
|
155
155
|
server_data["placement_group"] = server_obj.instances[0].placement.group_name
|
156
156
|
server_data["security_groups"] = server_obj.instances[0].security_groups.map(&:group_name)
|
157
157
|
server_data["security_group_ids"] = server_obj.instances[0].security_groups.map(&:group_id)
|
@@ -181,6 +181,13 @@ class Chef
|
|
181
181
|
@ami ||= fetch_ami(config[:image])
|
182
182
|
end
|
183
183
|
|
184
|
+
# Name tag value return.
|
185
|
+
# @return [String]
|
186
|
+
def find_name_tag(tags)
|
187
|
+
name_tag = tags.find { |tag| tag[:key] == "Name" }
|
188
|
+
name_tag ? name_tag[:value] : nil
|
189
|
+
end
|
190
|
+
|
184
191
|
# Platform value return for Windows AMIs; otherwise, it is blank.
|
185
192
|
# @return [Boolean]
|
186
193
|
def is_image_windows?
|
data/lib/knife-ec2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|