knife-ec2 2.0.6 → 2.1.4

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: a5c34fa2e9535195634d8a10601644c01c708584db8dd67114a583980d6df21c
4
- data.tar.gz: 6ddb72f9b0538218edbb5293ee9ed87dfd5fe29eae1766206a9c017c26ba1c8c
3
+ metadata.gz: 1fa7c53da4012983a77593f22b1f639192ddfca69cb72e7cfbcffc662c5001f1
4
+ data.tar.gz: 97fc956cdfb920451831057192cb0ad4392c6cc90352473b5444c83f0c54a3fb
5
5
  SHA512:
6
- metadata.gz: 395034c7c53dbce57370882f376444a9a633e1affc953ef030a28c6d9369af8def67e800de10f32404091a480f6fb3051d7340960dedc0e1ea8fe721e5396a4c
7
- data.tar.gz: db14778ebc52428e00d1aa4e998edafa7a789e906d8fbeb5c92037178ba76c4e5799abc55cbe50388a415cc602e2980c29c00c66283bfab4f9ea18713349c660
6
+ metadata.gz: 946d1dfa4c3800619e4250c6097e4614faa7f705f7fcac23b7b8a74787939a3cb7d9517611e69c2ac34ece01334a8eedec2fb523d69536123543c9c9b3bbcbcf
7
+ data.tar.gz: 9ea88798ea2c08ded66b0122c45aa663a3bbe40263a8a9bc76161850f42f08ba3f18b11db2076a869baf04879802ab0267059e9bc819272ec1774464e63ffda6
@@ -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 ",
@@ -520,7 +522,7 @@ class Chef
520
522
 
521
523
  def s3_validation_key
522
524
  @s3_validation_key ||= begin
523
- Chef::Knife::S3Source.fetch(config[:validation_key_url])
525
+ Chef::Knife::S3Source.fetch(config[:validation_key_url], config)
524
526
  end
525
527
  end
526
528
 
@@ -528,7 +530,7 @@ class Chef
528
530
  @s3_secret ||= begin
529
531
  return false unless config[:s3_secret]
530
532
 
531
- Chef::Knife::S3Source.fetch(config[:s3_secret])
533
+ Chef::Knife::S3Source.fetch(config[:s3_secret], config)
532
534
  end
533
535
  end
534
536
 
@@ -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
@@ -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?
@@ -17,11 +17,12 @@
17
17
  class Chef
18
18
  class Knife
19
19
  class S3Source
20
- attr_accessor :url
20
+ attr_accessor :url, :config
21
21
 
22
- def self.fetch(url)
22
+ def self.fetch(url, config)
23
23
  source = Chef::Knife::S3Source.new
24
24
  source.url = url
25
+ source.config = config
25
26
  source.body
26
27
  end
27
28
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "2.0.6".freeze
3
+ VERSION = "2.1.4".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.6
4
+ version: 2.1.4
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-10-13 00:00:00.000000000 Z
11
+ date: 2021-03-25 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