knife-ec2 0.17.0 → 0.18.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/CHANGELOG.md +7 -4
- data/DOC_CHANGES.md +5 -5
- data/RELEASE_NOTES.md +6 -11
- data/lib/chef/knife/ec2_server_create.rb +39 -9
- data/lib/knife-ec2/version.rb +1 -1
- data/spec/unit/ec2_server_create_spec.rb +64 -5
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 734b0e6c5929ce79f6ddf8a829920e8789fa3e8c
|
|
4
|
+
data.tar.gz: abcebcb7e4ae42eef0051b0aa505bc89c4d72873
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dafdfbaf8f511db58a17e0bc519ffeae58be4805247068aecf73e3f4d67ab7a5fcc8fb681450e0d4515171e557cd294375477fb72d51928943872e0f8b0518e4
|
|
7
|
+
data.tar.gz: 1ecf06ea19040b5b893e4d987b5049e0c87549b63447161bcf08507275ecdc5e0333fa4f6b98ef0d5b24e6404f141e709c217cce82226c1f105311b68ee98211
|
data/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,15 @@ Note: this log contains only changes from knife-ec2 release 0.8.0 and later
|
|
|
5
5
|
prior to release 0.8.0, please visit the [source repository](https://github.com/chef/knife-ec2/commits).
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
## Latest Release 0.
|
|
8
|
+
## Latest Release 0.18.0 (2018-04-05)
|
|
9
|
+
* [knife-ec2:#520](https://github.com/chef/knife-ec2/pull/520) Options `--aws-tag` and `--chef-tag` are added for tagging EC2 instance in AWS and Chef separately.
|
|
10
|
+
|
|
11
|
+
## Release 0.17.0 (2018-02-07)
|
|
9
12
|
* [knife-ec2:#515](https://github.com/chef/knife-ec2/pull/515) Allow re-use of existing ENI for primary interface.
|
|
10
13
|
* [knife-ec2:#514](https://github.com/chef/knife-ec2/pull/514) Add `--instance-initiated-shutdown-behavior` option.
|
|
11
14
|
* [knife-ec2:#513](https://github.com/chef/knife-ec2/pull/513) require `rb-readline` to avoid ruby 2.4 warnings about `Fixnum`.
|
|
12
15
|
|
|
13
|
-
##
|
|
16
|
+
## Release 0.16.0 (2017-11-07)
|
|
14
17
|
* [knife-ec2:#503](https://github.com/chef/knife-ec2/pull/503) Update list of instance_types that support ebs-encryption.
|
|
15
18
|
* [knife-ec2:#496](https://github.com/chef/knife-ec2/pull/496) Change Winrm cert to 10 year expiry.
|
|
16
19
|
* [knife-ec2:#492](https://github.com/chef/knife-ec2/pull/492) Added support to tag node details to chef.
|
|
@@ -19,7 +22,7 @@ prior to release 0.8.0, please visit the [source repository](https://github.com/
|
|
|
19
22
|
* [knife-ec2:#488](https://github.com/chef/knife-ec2/pull/488) Added support to tag EBS volumes on node creation.
|
|
20
23
|
* [knife-ec2:#487](https://github.com/chef/knife-ec2/pull/487) Added new column description in EC2 AMIs list.
|
|
21
24
|
|
|
22
|
-
##
|
|
25
|
+
## Release 0.15.0 (2017-02-15)
|
|
23
26
|
* [knife-ec2:#484](https://github.com/chef/knife-ec2/pull/484) sleep for collecting windows password
|
|
24
27
|
* [knife-ec2:#481](https://github.com/chef/knife-ec2/pull/481) Updated readme for EC2 AMI list
|
|
25
28
|
* [knife-ec2:#482](https://github.com/chef/knife-ec2/pull/482) Allow search for EC2 AMIs
|
|
@@ -30,7 +33,7 @@ prior to release 0.8.0, please visit the [source repository](https://github.com/
|
|
|
30
33
|
* [knife-ec2:#468](https://github.com/chef/knife-ec2/pull/468) In VPC mode use private IP when public IP and DNS not available
|
|
31
34
|
* [knife-ec2:#464](https://github.com/chef/knife-ec2/pull/464) default value and desription is changed for --ebs-volume-type
|
|
32
35
|
|
|
33
|
-
##
|
|
36
|
+
## Release 0.14.0 (2016-12-02)
|
|
34
37
|
* `knife-ec2` requires `chef-client 12.14` or newer.
|
|
35
38
|
* [knife-ec2:#442](https://github.com/chef/knife-ec2/pull/442) Added support to show flavor list in json format.
|
|
36
39
|
* [knife-ec2:#439](https://github.com/chef/knife-ec2/pull/439) Allow to accept multiple security group ids using --security-group-id option multiple times and added deprecated message for comma seprated --security-group-ids option.
|
data/DOC_CHANGES.md
CHANGED
|
@@ -4,14 +4,14 @@ This file is reset everytime when a new release is done. Contents of this file i
|
|
|
4
4
|
|
|
5
5
|
# knife-ec2 doc changes
|
|
6
6
|
|
|
7
|
-
Documentation changes are given below for **knife-ec2 version 0.
|
|
7
|
+
Documentation changes are given below for **knife-ec2 version 0.18.0**.
|
|
8
8
|
|
|
9
9
|
## `knife ec2 server create` subcommand changes
|
|
10
10
|
|
|
11
|
-
### `--
|
|
11
|
+
### `--aws-tag` option
|
|
12
12
|
|
|
13
|
-
The `--
|
|
13
|
+
The `--aws-tag` option is used for tagging the EC2 instances in AWS as `key=value` pair. Use this option like e.g. `--aws-tag <key1=value1>`. Multiple tags can be added by specifying the option multiple times.
|
|
14
14
|
|
|
15
|
-
### `--
|
|
15
|
+
### `--chef-tag` option
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The `--chef-tag` option is used for tagging the EC2 instances on the Chef server. Use this option like e.g. `--chef-tag <myTag>`. Multiple tags can be added by specifying the option multiple times.
|
data/RELEASE_NOTES.md
CHANGED
|
@@ -7,16 +7,11 @@ Example Note:
|
|
|
7
7
|
Details about the thing that changed that needs to get included in the Release Notes in markdown.
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
|
-
# knife-ec2 0.
|
|
11
|
-
In this release we have added features for
|
|
10
|
+
# knife-ec2 0.18.0 release notes:
|
|
11
|
+
In this release we have added separate features for tagging EC2 instances in AWS and Chef. Option `--aws-tag` is used for tagging the node in AWS and option `--chef-tag` is used for tagging the node in Chef. Subsequently the `--tag-node-in-chef` and `--tags` are now deprecated.
|
|
12
12
|
|
|
13
|
-
## Features added in knife-ec2 0.
|
|
13
|
+
## Features added in knife-ec2 0.18.0
|
|
14
|
+
* Added support for tagging node in AWS as well as in Chef with separate options `--aws-tag` and `--chef-tag`. PR: [520](https://github.com/chef/knife-ec2/pull/520).
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Added support to set the `--instance-initiated-shutdown-behavior` with the option to set "stop" or "terminate" the instance on shutdown. The default is "stop". PR: [514](https://github.com/chef/knife-ec2/pull/514).
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Enhancement in knife-ec2 0.17.0
|
|
21
|
-
|
|
22
|
-
* require `rb-readline` to avoid ruby 2.4 warnings about `Fixnum` PR: [513](https://github.com/chef/knife-ec2/pull/513)
|
|
16
|
+
## Enhancement in knife-ec2 0.18.0
|
|
17
|
+
* No enhancements.
|
|
@@ -110,8 +110,11 @@ class Chef
|
|
|
110
110
|
option :tags,
|
|
111
111
|
:short => "-T T=V[,T=V,...]",
|
|
112
112
|
:long => "--tags Tag=Value[,Tag=Value...]",
|
|
113
|
-
:description => "The tags for this server",
|
|
114
|
-
:proc => Proc.new { |
|
|
113
|
+
:description => "The tags for this server. [DEPRECATED] Use --aws-tag instead.",
|
|
114
|
+
:proc => Proc.new { |v|
|
|
115
|
+
Chef::Log.warn("[DEPRECATED] --tags option is deprecated. Use --aws-tag option instead.")
|
|
116
|
+
v
|
|
117
|
+
}
|
|
115
118
|
|
|
116
119
|
option :availability_zone,
|
|
117
120
|
:short => "-Z ZONE",
|
|
@@ -453,7 +456,11 @@ class Chef
|
|
|
453
456
|
|
|
454
457
|
option :tag_node_in_chef,
|
|
455
458
|
:long => "--tag-node-in-chef",
|
|
456
|
-
:description => "Flag for tagging node in ec2 and chef both",
|
|
459
|
+
:description => "Flag for tagging node in ec2 and chef both. [DEPRECATED] Use --chef-tag instead.",
|
|
460
|
+
:proc => Proc.new { |v|
|
|
461
|
+
Chef::Log.warn("[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead.")
|
|
462
|
+
v
|
|
463
|
+
},
|
|
457
464
|
:boolean => true,
|
|
458
465
|
:default => false
|
|
459
466
|
|
|
@@ -461,6 +468,24 @@ class Chef
|
|
|
461
468
|
:long => "--instance-initiated-shutdown-behavior SHUTDOWN_BEHAVIOR",
|
|
462
469
|
:description => "Indicates whether an instance stops or terminates when you initiate shutdown from the instance. Possible values are 'stop' and 'terminate', default is 'stop'."
|
|
463
470
|
|
|
471
|
+
option :chef_tag,
|
|
472
|
+
:long => "--chef-tag CHEF_TAG",
|
|
473
|
+
:description => "Use to tag the node in chef server; Provide --chef-tag option multiple times when specifying multiple tags e.g. --chef-tag tag1 --chef-tag tag2.",
|
|
474
|
+
:proc => Proc.new { |chef_tag|
|
|
475
|
+
Chef::Config[:knife][:chef_tag] ||= []
|
|
476
|
+
Chef::Config[:knife][:chef_tag].push(chef_tag)
|
|
477
|
+
Chef::Config[:knife][:chef_tag]
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
option :aws_tag,
|
|
481
|
+
:long => "--aws-tag AWS_TAG",
|
|
482
|
+
:description => "AWS tag for this server; Use the --aws-tag option multiple times when specifying multiple tags e.g. --aws-tag key1=value1 --aws-tag key2=value2.",
|
|
483
|
+
:proc => Proc.new { |aws_tag|
|
|
484
|
+
Chef::Config[:knife][:aws_tag] ||= []
|
|
485
|
+
Chef::Config[:knife][:aws_tag].push(aws_tag)
|
|
486
|
+
Chef::Config[:knife][:aws_tag]
|
|
487
|
+
}
|
|
488
|
+
|
|
464
489
|
def run
|
|
465
490
|
$stdout.sync = true
|
|
466
491
|
validate!
|
|
@@ -527,7 +552,7 @@ class Chef
|
|
|
527
552
|
end
|
|
528
553
|
end
|
|
529
554
|
|
|
530
|
-
|
|
555
|
+
printed_aws_tags = hashed_tags.map{ |tag, val| "#{tag}: #{val}" }.join(", ")
|
|
531
556
|
|
|
532
557
|
hashed_volume_tags={}
|
|
533
558
|
volume_tags = locate_config_value(:volume_tags)
|
|
@@ -554,7 +579,7 @@ class Chef
|
|
|
554
579
|
|
|
555
580
|
msg_pair("IAM Profile", locate_config_value(:iam_instance_profile))
|
|
556
581
|
|
|
557
|
-
msg_pair("Tags",
|
|
582
|
+
msg_pair("AWS Tags", printed_aws_tags)
|
|
558
583
|
msg_pair("Volume Tags", printed_volume_tags)
|
|
559
584
|
msg_pair("SSH Key", @server.key_name)
|
|
560
585
|
|
|
@@ -641,7 +666,8 @@ class Chef
|
|
|
641
666
|
msg_pair("Security Group Ids", printed_security_group_ids) if vpc_mode? or @server.security_group_ids
|
|
642
667
|
msg_pair("IAM Profile", locate_config_value(:iam_instance_profile)) if locate_config_value(:iam_instance_profile)
|
|
643
668
|
msg_pair("Primary ENI", locate_config_value(:primary_eni)) if locate_config_value(:primary_eni)
|
|
644
|
-
msg_pair("Tags",
|
|
669
|
+
msg_pair("AWS Tags", printed_aws_tags)
|
|
670
|
+
msg_pair("Chef Tags", locate_config_value(:chef_tag)) if locate_config_value(:chef_tag)
|
|
645
671
|
msg_pair("SSH Key", @server.key_name)
|
|
646
672
|
msg_pair("Root Device Type", @server.root_device_type)
|
|
647
673
|
msg_pair("Root Volume Tags", printed_volume_tags)
|
|
@@ -771,6 +797,7 @@ class Chef
|
|
|
771
797
|
bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item)
|
|
772
798
|
bootstrap.config[:use_sudo_password] = locate_config_value(:use_sudo_password)
|
|
773
799
|
bootstrap.config[:yes] = locate_config_value(:yes)
|
|
800
|
+
bootstrap.config[:tags] = config[:chef_tag] if locate_config_value(:chef_tag)
|
|
774
801
|
# Modify global configuration state to ensure hint gets set by
|
|
775
802
|
# knife-bootstrap
|
|
776
803
|
Chef::Config[:knife][:hints] ||= {}
|
|
@@ -1004,12 +1031,15 @@ class Chef
|
|
|
1004
1031
|
end
|
|
1005
1032
|
end
|
|
1006
1033
|
|
|
1034
|
+
if locate_config_value(:tag_node_in_chef)
|
|
1035
|
+
ui.warn("[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead.")
|
|
1036
|
+
end
|
|
1007
1037
|
end
|
|
1008
1038
|
|
|
1009
1039
|
def tags
|
|
1010
|
-
tags = locate_config_value(:
|
|
1040
|
+
tags = locate_config_value(:aws_tag)
|
|
1011
1041
|
if !tags.nil? and tags.length != tags.to_s.count('=')
|
|
1012
|
-
ui.error("Tags should be entered in a key = value pair")
|
|
1042
|
+
ui.error("AWS Tags should be entered in a key = value pair")
|
|
1013
1043
|
exit 1
|
|
1014
1044
|
end
|
|
1015
1045
|
tags
|
|
@@ -1219,7 +1249,7 @@ EOH
|
|
|
1219
1249
|
server_def[:disable_api_termination] = locate_config_value(:disable_api_termination) if locate_config_value(:spot_price).nil?
|
|
1220
1250
|
|
|
1221
1251
|
server_def[:instance_initiated_shutdown_behavior] = locate_config_value(:instance_initiated_shutdown_behavior)
|
|
1222
|
-
|
|
1252
|
+
server_def[:chef_tag] = locate_config_value(:chef_tag)
|
|
1223
1253
|
server_def
|
|
1224
1254
|
end
|
|
1225
1255
|
|
data/lib/knife-ec2/version.rb
CHANGED
|
@@ -134,7 +134,8 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
134
134
|
:placement_group => nil,
|
|
135
135
|
:iam_instance_profile_name => nil,
|
|
136
136
|
:ebs_optimized => "false",
|
|
137
|
-
:instance_initiated_shutdown_behavior => nil
|
|
137
|
+
:instance_initiated_shutdown_behavior => nil,
|
|
138
|
+
:chef_tag => nil
|
|
138
139
|
}
|
|
139
140
|
allow(@bootstrap).to receive(:run)
|
|
140
141
|
end
|
|
@@ -476,16 +477,16 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
|
476
477
|
knife_ec2_create.run
|
|
477
478
|
end
|
|
478
479
|
|
|
479
|
-
it "sets the Name tag to the specified name when given --
|
|
480
|
-
knife_ec2_create.config[:
|
|
480
|
+
it "sets the Name tag to the specified name when given --aws-tag Name=NAME" do
|
|
481
|
+
knife_ec2_create.config[:aws_tag] = ["Name=bobcat"]
|
|
481
482
|
expect(ec2_connection.tags).to receive(:create).with(:key => "Name",
|
|
482
483
|
:value => "bobcat",
|
|
483
484
|
:resource_id => new_ec2_server.id)
|
|
484
485
|
knife_ec2_create.run
|
|
485
486
|
end
|
|
486
487
|
|
|
487
|
-
it "sets arbitrary tags" do
|
|
488
|
-
knife_ec2_create.config[:
|
|
488
|
+
it "sets arbitrary aws tags" do
|
|
489
|
+
knife_ec2_create.config[:aws_tag] = ["foo=bar"]
|
|
489
490
|
expect(ec2_connection.tags).to receive(:create).with(:key => "foo",
|
|
490
491
|
:value => "bar",
|
|
491
492
|
:resource_id => new_ec2_server.id)
|
|
@@ -2571,6 +2572,64 @@ netstat > c:\\netstat_data.txt
|
|
|
2571
2572
|
end
|
|
2572
2573
|
end
|
|
2573
2574
|
|
|
2575
|
+
describe '--chef-tag option' do
|
|
2576
|
+
before do
|
|
2577
|
+
allow(Fog::Compute::AWS).to receive(:new).and_return(ec2_connection)
|
|
2578
|
+
end
|
|
2579
|
+
|
|
2580
|
+
context 'when mulitple values provided from cli for e.g. --chef-tag "foo" --chef-tag "bar"' do
|
|
2581
|
+
let(:ec2_server_create) { Chef::Knife::Ec2ServerCreate.new(['--chef-tag', 'foo', '--chef-tag', 'bar'])}
|
|
2582
|
+
it 'creates array of chef tag' do
|
|
2583
|
+
server_def = ec2_server_create.create_server_def
|
|
2584
|
+
expect(server_def[:chef_tag]).to eq(['foo', 'bar'])
|
|
2585
|
+
end
|
|
2586
|
+
end
|
|
2587
|
+
|
|
2588
|
+
context 'when single value provided from cli for e.g. --chef-tag foo' do
|
|
2589
|
+
let(:ec2_server_create) { Chef::Knife::Ec2ServerCreate.new(['--chef-tag', 'foo'])}
|
|
2590
|
+
it 'creates array of chef tag' do
|
|
2591
|
+
server_def = ec2_server_create.create_server_def
|
|
2592
|
+
expect(server_def[:chef_tag]).to eq(['foo'])
|
|
2593
|
+
end
|
|
2594
|
+
end
|
|
2595
|
+
end
|
|
2596
|
+
|
|
2597
|
+
describe '--aws-tag option' do
|
|
2598
|
+
before do
|
|
2599
|
+
allow(Fog::Compute::AWS).to receive(:new).and_return(ec2_connection)
|
|
2600
|
+
end
|
|
2601
|
+
|
|
2602
|
+
context 'when mulitple values provided from cli for e.g. --aws-tag "foo=bar" --aws-tag "foo1=bar1"' do
|
|
2603
|
+
let(:ec2_server_create) { Chef::Knife::Ec2ServerCreate.new(['--aws-tag', 'foo=bar', '--aws-tag', 'foo1=bar1'])}
|
|
2604
|
+
it 'creates array of aws tag' do
|
|
2605
|
+
server_def = ec2_server_create.config
|
|
2606
|
+
expect(server_def[:aws_tag]).to eq(['foo=bar', 'foo1=bar1'])
|
|
2607
|
+
end
|
|
2608
|
+
end
|
|
2609
|
+
|
|
2610
|
+
context 'when single value provided from cli for e.g. --aws-tag foo=bar' do
|
|
2611
|
+
let(:ec2_server_create) { Chef::Knife::Ec2ServerCreate.new(['--aws-tag', 'foo=bar'])}
|
|
2612
|
+
it 'creates array of aws tag' do
|
|
2613
|
+
server_def = ec2_server_create.config
|
|
2614
|
+
expect(server_def[:aws_tag]).to eq(['foo=bar'])
|
|
2615
|
+
end
|
|
2616
|
+
end
|
|
2617
|
+
end
|
|
2618
|
+
|
|
2619
|
+
describe '--tag-node-in-chef option' do
|
|
2620
|
+
before do
|
|
2621
|
+
allow(Fog::Compute::AWS).to receive(:new).and_return(ec2_connection)
|
|
2622
|
+
end
|
|
2623
|
+
|
|
2624
|
+
context 'when provided from cli for e.g. --tag-node-in-chef' do
|
|
2625
|
+
let(:ec2_server_create) { Chef::Knife::Ec2ServerCreate.new(['--tag-node-in-chef'])}
|
|
2626
|
+
it 'raises deprecated warning "[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead."' do
|
|
2627
|
+
expect(ec2_server_create.ui).to receive(:warn).with("[DEPRECATED] --tag-node-in-chef option is deprecated. Use --chef-tag option instead.")
|
|
2628
|
+
ec2_server_create.validate!
|
|
2629
|
+
end
|
|
2630
|
+
end
|
|
2631
|
+
end
|
|
2632
|
+
|
|
2574
2633
|
describe 'evaluate_node_name' do
|
|
2575
2634
|
before do
|
|
2576
2635
|
knife_ec2_create.instance_variable_set(:@server, server)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife-ec2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-
|
|
12
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fog-aws
|
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
165
|
version: '0'
|
|
166
166
|
requirements: []
|
|
167
167
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 2.6.
|
|
168
|
+
rubygems_version: 2.6.14
|
|
169
169
|
signing_key:
|
|
170
170
|
specification_version: 4
|
|
171
171
|
summary: EC2 Support for Chef's Knife Command
|