knife-ec2 2.1.4 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fa7c53da4012983a77593f22b1f639192ddfca69cb72e7cfbcffc662c5001f1
4
- data.tar.gz: 97fc956cdfb920451831057192cb0ad4392c6cc90352473b5444c83f0c54a3fb
3
+ metadata.gz: 1c9e95c46220d9a4108d3f92dced810864d8df0439108d1478d00f0239c6a1c0
4
+ data.tar.gz: ae0bce69fb7b2e7f0405db5a484b99adfb2dc8872c5b60fc860c61e988e05f62
5
5
  SHA512:
6
- metadata.gz: 946d1dfa4c3800619e4250c6097e4614faa7f705f7fcac23b7b8a74787939a3cb7d9517611e69c2ac34ece01334a8eedec2fb523d69536123543c9c9b3bbcbcf
7
- data.tar.gz: 9ea88798ea2c08ded66b0122c45aa663a3bbe40263a8a9bc76161850f42f08ba3f18b11db2076a869baf04879802ab0267059e9bc819272ec1774464e63ffda6
6
+ metadata.gz: 1fa2fa5e742a2e30267d02b1c0ab5663559eb15290c936f3fac5501a13eac5f045256b4ec105f828fefd90b8eacfce4173a633a726d71fbb13f3b8ba1395c4b5
7
+ data.tar.gz: 8602b3465992ec4c0674f879ed8c22a7dc413588d7272c453e80a3a678cf24a8baf896ce0df12d3ec06f7010ea70f75a83f773a36de70d3648eb76022ce74e0e
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Piyush Awasthi (<piyush.awasthi@msystechnologies.com>)
3
- # Copyright:: Copyright (c) Chef Software Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -93,18 +93,23 @@ class Chef
93
93
 
94
94
  def ami_hashes
95
95
  all_data = {}
96
- ec2_connection.describe_images(image_params).images.each do |v|
96
+ response = ec2_connection.describe_images(image_params)
97
+ response.images.each do |v|
97
98
  v_data = {}
98
99
  if config[:search]
99
- next unless v.description.downcase.include?(config[:search].downcase)
100
+ next unless v.description.to_s.downcase.include?(config[:search].downcase)
100
101
  end
101
102
 
102
103
  %w{image_id platform description architecture}.each do |id|
103
- v_data[id] = v.send(id)
104
+ v_data[id] = v.respond_to?(id) ? v.send(id) : v[id]
104
105
  end
105
106
 
106
- v_data["name"] = v.name.split(/\W+/).first
107
- v_data["size"] = v.block_device_mappings[0].ebs.volume_size.to_s
107
+ name = v.respond_to?(:name) ? v.name : v[:name]
108
+ v_data["name"] = name ? name.split(/\W+/).first : nil
109
+
110
+ mappings = v.respond_to?(:block_device_mappings) ? v.block_device_mappings : v[:block_device_mappings]
111
+ v_data["size"] = mappings && mappings[0] && mappings[0][:ebs] ? mappings[0][:ebs][:volume_size].to_s : nil
112
+
108
113
  all_data[v_data["image_id"]] = v_data
109
114
  end
110
115
  all_data
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith (<tsmith@chef.io>)
3
- # Copyright:: Copyright (c) 2018-2019 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Seth Chisamore (<schisamo@chef.io>)
3
- # Copyright:: Copyright (c) 2012-2019 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith (<tsmith@chef.io>)
3
- # Copyright:: Copyright (c) 2018-2019 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Seth Chisamore (<schisamo@chef.io>)
4
- # Copyright:: Copyright (c) Chef Software Inc.
4
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,6 +25,10 @@ class Chef
25
25
  class Knife
26
26
  class Ec2ServerCreate < Chef::Knife::Bootstrap
27
27
 
28
+ GP_VOLUME_TYPES = %w{gp2 gp3}.freeze
29
+ IOPS_VOLUME_TYPES = %w{io1 io2}.freeze
30
+ EBS_VOLUME_TYPES = (%w{standard st1 sc1} + GP_VOLUME_TYPES + IOPS_VOLUME_TYPES).freeze
31
+
28
32
  include Knife::Ec2Base
29
33
 
30
34
  deps do
@@ -161,12 +165,12 @@ class Chef
161
165
 
162
166
  option :ebs_volume_type,
163
167
  long: "--ebs-volume-type TYPE",
164
- description: "Possible values are standard (magnetic) | io1 | gp2 | sc1 | st1. Default is gp2",
165
- default: "gp2"
168
+ description: "Possible values are #{EBS_VOLUME_TYPES.join(" | ")}. Default is gp3",
169
+ default: "gp3"
166
170
 
167
171
  option :ebs_provisioned_iops,
168
172
  long: "--provisioned-iops IOPS",
169
- description: "IOPS rate, only used when ebs volume type is 'io1'",
173
+ description: "IOPS rate, only used when ebs volume type is '#{IOPS_VOLUME_TYPES.join(" or ")}'",
170
174
  default: nil
171
175
 
172
176
  option :validation_key_url,
@@ -330,10 +334,16 @@ class Chef
330
334
  msg_pair("IAM Profile", config[:iam_instance_profile])
331
335
 
332
336
  msg_pair("AWS Tags", printed_aws_tags)
337
+
333
338
  msg_pair("Volume Tags", printed_volume_tags)
334
339
  msg_pair("SSH Key", server.key_name)
335
340
  msg_pair("T2/T3 Unlimited", printed_t2_t3_unlimited)
336
341
 
342
+ # Update Name tag after instance creation if chef_node_name contains %s
343
+ if config[:chef_node_name] && config[:chef_node_name].include?("%s")
344
+ config[:chef_node_name] = evaluate_node_name(config[:chef_node_name])
345
+ end
346
+
337
347
  puts("\n")
338
348
 
339
349
  # occasionally 'ready?' isn't, so retry a couple times if needed.
@@ -495,13 +505,11 @@ class Chef
495
505
  end
496
506
 
497
507
  def validation_key_path
498
- @validation_key_path ||= begin
499
- if URI(config[:validation_key_url]).scheme == "file"
500
- URI(config[:validation_key_url]).path
501
- else
502
- validation_key_tmpfile.path
503
- end
504
- end
508
+ @validation_key_path ||= if URI(config[:validation_key_url]).scheme == "file"
509
+ URI(config[:validation_key_url]).path
510
+ else
511
+ validation_key_tmpfile.path
512
+ end
505
513
  end
506
514
 
507
515
  # @return [Tempfile]
@@ -521,9 +529,7 @@ class Chef
521
529
  end
522
530
 
523
531
  def s3_validation_key
524
- @s3_validation_key ||= begin
525
- Chef::Knife::S3Source.fetch(config[:validation_key_url], config)
526
- end
532
+ @s3_validation_key ||= Chef::Knife::S3Source.fetch(config[:validation_key_url], config)
527
533
  end
528
534
 
529
535
  def s3_secret
@@ -616,18 +622,18 @@ class Chef
616
622
  end
617
623
  end
618
624
 
619
- if config[:ebs_provisioned_iops] && (config[:ebs_volume_type] != "io1")
620
- ui.error("--provisioned-iops option is only supported for volume type of 'io1'")
625
+ if config[:ebs_provisioned_iops] && !IOPS_VOLUME_TYPES.include?(config[:ebs_volume_type])
626
+ ui.error("--provisioned-iops option is only supported for volume type of '#{IOPS_VOLUME_TYPES.join(" or ")}'")
621
627
  exit 1
622
628
  end
623
629
 
624
- if (config[:ebs_volume_type] == "io1") && config[:ebs_provisioned_iops].nil?
625
- ui.error("--provisioned-iops option is required when using volume type of 'io1'")
630
+ if IOPS_VOLUME_TYPES.include?(config[:ebs_volume_type]) && config[:ebs_provisioned_iops].nil?
631
+ ui.error("--provisioned-iops option is required when using volume type of '#{IOPS_VOLUME_TYPES.join(" or ")}'")
626
632
  exit 1
627
633
  end
628
634
 
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'")
635
+ if config[:ebs_volume_type] && ! EBS_VOLUME_TYPES.include?(config[:ebs_volume_type])
636
+ ui.error("--ebs-volume-type must be '#{EBS_VOLUME_TYPES.join("' or '")}'")
631
637
  msg opt_parser
632
638
  exit 1
633
639
  end
@@ -682,10 +688,12 @@ class Chef
682
688
  # validation for ebs_size and ebs_volume_type and ebs_encrypted
683
689
  if !config[:ebs_size]
684
690
  errors << "--ebs-encrypted option requires valid --ebs-size to be specified."
685
- elsif (config[:ebs_volume_type] == "gp2") && ! config[:ebs_size].to_i.between?(1, 16384)
686
- errors << "--ebs-size should be in between 1-16384 for 'gp2' ebs volume type."
691
+ elsif (GP_VOLUME_TYPES.include?(config[:ebs_volume_type])) && ! config[:ebs_size].to_i.between?(1, 16384)
692
+ errors << "--ebs-size should be in between 1-16384 for '#{GP_VOLUME_TYPES.join("' or '")}' ebs volume type."
687
693
  elsif (config[:ebs_volume_type] == "io1") && ! config[:ebs_size].to_i.between?(4, 16384)
688
694
  errors << "--ebs-size should be in between 4-16384 for 'io1' ebs volume type."
695
+ elsif (config[:ebs_volume_type] == "io2") && ! config[:ebs_size].to_i.between?(4, 65536)
696
+ errors << "--ebs-size should be in between 4-65536 for 'io2' ebs volume type."
689
697
  elsif (config[:ebs_volume_type] == "standard") && ! config[:ebs_size].to_i.between?(1, 1024)
690
698
  errors << "--ebs-size should be in between 1-1024 for 'standard' ebs volume type."
691
699
  end
@@ -757,8 +765,8 @@ class Chef
757
765
  user = connection_user.split("\\")
758
766
  if (user[0] == ".") || (user[0] == "") || (user.length == 1)
759
767
  user_related_commands = <<~EOH
760
- net user /add #{connection_user.delete('.\\')} #{windows_password} #{@allow_long_password};
761
- net localgroup Administrators /add #{connection_user.delete('.\\')};
768
+ net user /add #{connection_user.delete(".\\")} #{windows_password} #{@allow_long_password};
769
+ net localgroup Administrators /add #{connection_user.delete(".\\")};
762
770
  EOH
763
771
  end
764
772
  <<~EOH
@@ -953,7 +961,7 @@ class Chef
953
961
  ebs: {
954
962
  delete_on_termination: delete_term,
955
963
  volume_size: ebs_size,
956
- volume_type: config[:ebs_volume_type], # accepts standard, io1, gp2, sc1, st1
964
+ volume_type: config[:ebs_volume_type], # accepts standard, io1, io2, gp2, gp3, sc1, st1
957
965
  },
958
966
  }]
959
967
  attributes[:block_device_mappings][0][:ebs][:iops] = iops_rate unless iops_rate.nil? || iops_rate.empty?
@@ -979,6 +987,16 @@ class Chef
979
987
  cpu_credits: config[:cpu_credits],
980
988
  }
981
989
  end
990
+ # Add tag_specifications for instance tags at creation time
991
+ tags = hashed_tags.map { |k, v| { key: k, value: v } }
992
+ unless tags.empty?
993
+ attributes[:tag_specifications] = [
994
+ {
995
+ resource_type: "instance",
996
+ tags: tags,
997
+ },
998
+ ]
999
+ end
982
1000
  attributes
983
1001
  end
984
1002
 
@@ -1139,15 +1157,13 @@ class Chef
1139
1157
  # Otherwise assign public DNS or public IP.
1140
1158
  # @return [String]
1141
1159
  def connect_attribute
1142
- @connect_attribute ||= begin
1143
- if !!config[:server_connect_attribute]
1144
- config[:server_connect_attribute]
1145
- elsif vpc_mode? && !(subnet_public_ip_on_launch? || config[:associate_public_ip] || config[:associate_eip])
1146
- "private_ip_address"
1147
- else
1148
- server.public_dns_name ? "public_dns_name" : "public_ip_address"
1149
- end
1150
- end
1160
+ @connect_attribute ||= if !!config[:server_connect_attribute]
1161
+ config[:server_connect_attribute]
1162
+ elsif vpc_mode? && !(subnet_public_ip_on_launch? || config[:associate_public_ip] || config[:associate_eip])
1163
+ "private_ip_address"
1164
+ else
1165
+ server.public_dns_name ? "public_dns_name" : "public_ip_address"
1166
+ end
1151
1167
  end
1152
1168
 
1153
1169
  def create_tags(hashed_tags)
@@ -1448,9 +1464,9 @@ class Chef
1448
1464
  # Always set the Name tag
1449
1465
  unless ht.key?("Name")
1450
1466
  if config[:chef_node_name]
1451
- ht["Name"] = evaluate_node_name(config[:chef_node_name])
1467
+ ht["Name"] = config[:chef_node_name]
1452
1468
  else
1453
- ht["Name"] = server.id
1469
+ ht["Name"] = server&.id
1454
1470
  end
1455
1471
  end
1456
1472
 
@@ -1475,3 +1491,4 @@ class Chef
1475
1491
  end
1476
1492
  end
1477
1493
  end
1494
+
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Seth Chisamore (<schisamo@chef.io>)
4
- # Copyright:: Copyright (c) 2009-2019 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Seth Chisamore (<schisamo@chef.io>)
4
- # Copyright:: Copyright (c) Chef Software Inc.
4
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith (<tsmith@chef.io>)
3
- # Copyright:: Copyright (c) 2018-2019 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Tim Smith (<tsmith@chef.io>)
3
- # Copyright:: Copyright (c) 2018-2019 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,7 +1,7 @@
1
1
 
2
2
  #
3
3
  # Author:: Seth Chisamore (<schisamo@chef.io>)
4
- # Copyright:: Copyright (c) Chef Software Inc.
4
+ # Copyright:: Copyright (c) 2011-2024 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -184,8 +184,17 @@ class Chef
184
184
  # Name tag value return.
185
185
  # @return [String]
186
186
  def find_name_tag(tags)
187
- name_tag = tags.find { |tag| tag[:key] == "Name" }
188
- name_tag ? name_tag[:value] : nil
187
+ name_tag = tags.find do |tag|
188
+ key_value = tag.respond_to?(:key) ? tag.key : (tag[:key] || tag["key"])
189
+ key_value == "Name"
190
+ end
191
+ if name_tag
192
+ if name_tag.respond_to?(:value)
193
+ name_tag.value
194
+ else
195
+ name_tag[:value] || name_tag["value"]
196
+ end
197
+ end
189
198
  end
190
199
 
191
200
  # Platform value return for Windows AMIs; otherwise, it is blank.
@@ -234,13 +243,11 @@ class Chef
234
243
  # if default location exists on disk fallback to that
235
244
  # @return [String, nil] location to aws credentials file or nil if none exists
236
245
  def aws_cred_file_location
237
- @cred_file ||= begin
238
- if !config[:aws_credential_file].nil?
239
- config[:aws_credential_file]
240
- else
241
- Chef::Util::PathHelper.home(".aws", "credentials") if ::File.exist?(Chef::Util::PathHelper.home(".aws", "credentials"))
242
- end
243
- end
246
+ @cred_file ||= if !config[:aws_credential_file].nil?
247
+ config[:aws_credential_file]
248
+ else
249
+ Chef::Util::PathHelper.home(".aws", "credentials") if ::File.exist?(Chef::Util::PathHelper.home(".aws", "credentials"))
250
+ end
244
251
  end
245
252
 
246
253
  # @return [String]
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "2.1.4".freeze
3
+ VERSION = "2.2.0".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.2.0
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: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2026-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: chef
14
+ name: knife
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '15.11'
19
+ version: '18.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '15.11'
26
+ version: '18.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk-s3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.95'
55
+ - !ruby/object:Gem::Dependency
56
+ name: abbrev
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: syslog
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
55
83
  description: Amazon EC2 Support for Chef's Knife Command
56
84
  email:
57
85
  - info@chef.io
@@ -84,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
112
  requirements:
85
113
  - - ">="
86
114
  - !ruby/object:Gem::Version
87
- version: '2.6'
115
+ version: '3.1'
88
116
  required_rubygems_version: !ruby/object:Gem::Requirement
89
117
  requirements:
90
118
  - - ">="
91
119
  - !ruby/object:Gem::Version
92
120
  version: '0'
93
121
  requirements: []
94
- rubygems_version: 3.1.4
122
+ rubygems_version: 3.3.27
95
123
  signing_key:
96
124
  specification_version: 4
97
125
  summary: Amazon EC2 Support for Chef's Knife Command