knife-ec2 2.0.4 → 2.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16530eadac768b8b35d935346fe20b291ff40623b302b2c050c5b63e8c38879f
4
- data.tar.gz: 49d24390d1c3e6ba4bcfe330628bf1b1debd8bf4bd38725b1892eb8c066a624d
3
+ metadata.gz: 101ad79cef06c0ed4fefa6a7a7268472f8be49c7af9b4db0069769084a24f17e
4
+ data.tar.gz: 9645491d5482a1058b21d43ee933ab6a4e0a2f50bfded899a03ff530e63e127f
5
5
  SHA512:
6
- metadata.gz: 26a987b8e84c65929f8ad6bdaab50258320a7b58747a689c61e4d294f156ad612338cf57a1fd34a6a33cd1c510d3812faa061a1ae978315c258343093c6ea08d
7
- data.tar.gz: 8e7e4e7e3cc6c7181555ab0b412f7560b6f976554c8671c9586daf7832d6937a9af51b42997a8f6844fb7b05d21ae2b36c831bbabb5d1f078c8d152763d3f63e
6
+ metadata.gz: 14c05f935d5c5c8b706ab43b8628732f4745845a7f064aa257b5d51ecc75c793738d9609cfae45455a5349d040db71ed3a7ea287900abe280e10e93497c08fbb
7
+ data.tar.gz: 3d6c72dd313f4144d782b91e213fb2fca0e0243c8fdb1742c4590c8142eda6e75f9574ef05d0153a11289fa7c7df469cd02991331aa99ba724a5874eb54dce2b
@@ -104,9 +104,11 @@ class Chef
104
104
  long: "--ebs-optimized",
105
105
  description: "Enabled optimized EBS I/O"
106
106
 
107
- option :ebs_no_delete_on_term,
108
- long: "--ebs-no-delete-on-term",
109
- description: "Do not delete EBS volume on instance termination"
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
@@ -706,7 +714,7 @@ class Chef
706
714
  exit 1
707
715
  end
708
716
 
709
- if winrm?
717
+ if winrm? && !config[:connection_password].nil?
710
718
  reg = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,40}$/
711
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")
@@ -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
- delete_term = if config[:ebs_no_delete_on_term]
928
- "false"
929
- else
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
@@ -957,7 +963,7 @@ class Chef
957
963
  if config[:ephemeral] && config[:ephemeral].length > 0
958
964
  ephemeral_blocks = []
959
965
  config[:ephemeral].each_with_index do |device_name, i|
960
- ephemeral_blocks << { virtual_name: "ephemeral#{i}", device_name: device_name, ebs: { volume_size: ebs_size } }
966
+ ephemeral_blocks << { virtual_name: "ephemeral#{i}", device_name: device_name }
961
967
  end
962
968
  attributes[:block_device_mappings] += ephemeral_blocks
963
969
  end
@@ -1398,13 +1404,7 @@ class Chef
1398
1404
  end
1399
1405
 
1400
1406
  def server_name
1401
- return nil unless server
1402
-
1403
- if !server.public_dns_name.empty?
1404
- server.public_dns_name
1405
- else
1406
- server.private_ip_address
1407
- end
1407
+ server ? connection_host : nil
1408
1408
  end
1409
1409
 
1410
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[0].value
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(", ")
@@ -166,7 +166,7 @@ class Chef
166
166
  tags = extract_tags(i.instances[0].tags)
167
167
 
168
168
  if config[:name]
169
- server_data["name"] = tags[0]
169
+ server_data["name"] = find_name_tag(i.instances[0].tags)
170
170
  end
171
171
 
172
172
  if config[:az]
@@ -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"] = tags[0]
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?
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "2.0.4".freeze
3
+ VERSION = "2.1.3".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
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.0.4
4
+ version: 2.1.3
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-08-21 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.0.3
94
+ rubygems_version: 3.1.4
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Amazon EC2 Support for Chef's Knife Command