knife-ec2 0.5.10 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +97 -0
- data/README.rdoc +2 -2
- data/knife-ec2.gemspec +3 -3
- data/lib/chef/knife/ec2_base.rb +1 -1
- data/lib/chef/knife/ec2_server_create.rb +49 -8
- data/lib/chef/knife/ec2_server_delete.rb +39 -1
- data/lib/chef/knife/ec2_server_list.rb +1 -1
- data/lib/knife-ec2/version.rb +1 -2
- data/spec/unit/ec2_server_create_spec.rb +72 -12
- metadata +43 -39
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
knife-ec2 (0.5.11)
|
5
|
+
chef (>= 0.10.10)
|
6
|
+
fog (~> 1.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
builder (3.0.0)
|
12
|
+
bunny (0.7.9)
|
13
|
+
chef (0.10.10)
|
14
|
+
bunny (>= 0.6.0)
|
15
|
+
erubis
|
16
|
+
highline (>= 1.6.9)
|
17
|
+
json (>= 1.4.4, <= 1.6.1)
|
18
|
+
mixlib-authentication (>= 1.1.0)
|
19
|
+
mixlib-cli (>= 1.1.0)
|
20
|
+
mixlib-config (>= 1.1.2)
|
21
|
+
mixlib-log (>= 1.3.0)
|
22
|
+
mixlib-shellout (~> 1.0.0.rc)
|
23
|
+
moneta
|
24
|
+
net-ssh (~> 2.2.2)
|
25
|
+
net-ssh-multi (~> 1.1.0)
|
26
|
+
ohai (>= 0.6.0)
|
27
|
+
rest-client (>= 1.0.4, < 1.7.0)
|
28
|
+
treetop (~> 1.4.9)
|
29
|
+
uuidtools
|
30
|
+
yajl-ruby (>= 1.1.0)
|
31
|
+
diff-lcs (1.1.3)
|
32
|
+
erubis (2.7.0)
|
33
|
+
excon (0.13.4)
|
34
|
+
fog (1.3.1)
|
35
|
+
builder
|
36
|
+
excon (~> 0.13.0)
|
37
|
+
formatador (~> 0.2.0)
|
38
|
+
mime-types
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
net-scp (~> 1.0.4)
|
41
|
+
net-ssh (>= 2.1.3)
|
42
|
+
nokogiri (~> 1.5.0)
|
43
|
+
ruby-hmac
|
44
|
+
formatador (0.2.1)
|
45
|
+
highline (1.6.12)
|
46
|
+
ipaddress (0.8.0)
|
47
|
+
json (1.6.1)
|
48
|
+
mime-types (1.18)
|
49
|
+
mixlib-authentication (1.1.4)
|
50
|
+
mixlib-log
|
51
|
+
mixlib-cli (1.2.2)
|
52
|
+
mixlib-config (1.1.2)
|
53
|
+
mixlib-log (1.3.0)
|
54
|
+
mixlib-shellout (1.0.0)
|
55
|
+
moneta (0.6.0)
|
56
|
+
multi_json (1.3.4)
|
57
|
+
net-scp (1.0.4)
|
58
|
+
net-ssh (>= 1.99.1)
|
59
|
+
net-ssh (2.2.2)
|
60
|
+
net-ssh-gateway (1.1.0)
|
61
|
+
net-ssh (>= 1.99.1)
|
62
|
+
net-ssh-multi (1.1)
|
63
|
+
net-ssh (>= 2.1.4)
|
64
|
+
net-ssh-gateway (>= 0.99.0)
|
65
|
+
nokogiri (1.5.2)
|
66
|
+
ohai (0.6.12)
|
67
|
+
ipaddress
|
68
|
+
mixlib-cli
|
69
|
+
mixlib-config
|
70
|
+
mixlib-log
|
71
|
+
systemu
|
72
|
+
yajl-ruby
|
73
|
+
polyglot (0.3.3)
|
74
|
+
rest-client (1.6.7)
|
75
|
+
mime-types (>= 1.16)
|
76
|
+
rspec (2.7.0)
|
77
|
+
rspec-core (~> 2.7.0)
|
78
|
+
rspec-expectations (~> 2.7.0)
|
79
|
+
rspec-mocks (~> 2.7.0)
|
80
|
+
rspec-core (2.7.1)
|
81
|
+
rspec-expectations (2.7.0)
|
82
|
+
diff-lcs (~> 1.1.2)
|
83
|
+
rspec-mocks (2.7.0)
|
84
|
+
ruby-hmac (0.4.0)
|
85
|
+
systemu (2.5.0)
|
86
|
+
treetop (1.4.10)
|
87
|
+
polyglot
|
88
|
+
polyglot (>= 0.3.1)
|
89
|
+
uuidtools (2.1.2)
|
90
|
+
yajl-ruby (1.1.0)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
knife-ec2!
|
97
|
+
rspec (~> 2.7.0)
|
data/README.rdoc
CHANGED
@@ -31,7 +31,7 @@ If your knife.rb file will be checked into a SCM system (ie readable by others)
|
|
31
31
|
You also have the option of passing your AWS API Key/Secret into the individual knife subcommands using the <tt>-A</tt> (or <tt>--aws-access-key-id</tt>) <tt>-K</tt> (or <tt>--aws-secret-access-key</tt>) command options
|
32
32
|
|
33
33
|
# provision a new m1.small Ubuntu 10.04 webserver
|
34
|
-
knife ec2 server create 'role[webserver]' -I ami-7000f019 -f m1.small -A 'Your AWS Access Key ID' -K "Your AWS Secret Access Key"
|
34
|
+
knife ec2 server create -r 'role[webserver]' -I ami-7000f019 -f m1.small -A 'Your AWS Access Key ID' -K "Your AWS Secret Access Key"
|
35
35
|
|
36
36
|
Additionally the following options may be set in your `knife.rb`:
|
37
37
|
|
@@ -53,7 +53,7 @@ Provisions a new server in the Amazon EC2 and then perform a Chef bootstrap (usi
|
|
53
53
|
|
54
54
|
== knife ec2 server delete
|
55
55
|
|
56
|
-
Deletes an existing server in the currently configured AWS account. <b>PLEASE NOTE</b> - this does not delete the associated node and client objects from the Chef server.
|
56
|
+
Deletes an existing server in the currently configured AWS account. <b>PLEASE NOTE</b> - By default, this does not delete the associated node and client objects from the Chef server. To do so, add the <tt>--purge</tt> flag.
|
57
57
|
|
58
58
|
== knife ec2 server list
|
59
59
|
|
data/knife-ec2.gemspec
CHANGED
@@ -9,14 +9,14 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Adam Jacob","Seth Chisamore"]
|
10
10
|
s.email = ["adam@opscode.com","schisamo@opscode.com"]
|
11
11
|
s.homepage = "http://wiki.opscode.com/display/chef"
|
12
|
-
s.summary = "
|
12
|
+
s.summary = "EC2 Support for Chef's Knife Command"
|
13
13
|
s.description = s.summary
|
14
14
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "fog", "~>
|
19
|
+
s.add_dependency "fog", "~> 1.3"
|
20
|
+
s.add_dependency "chef", ">= 0.10.10"
|
20
21
|
s.require_paths = ["lib"]
|
21
|
-
|
22
22
|
end
|
data/lib/chef/knife/ec2_base.rb
CHANGED
@@ -82,7 +82,7 @@ class Chef
|
|
82
82
|
keys.each do |k|
|
83
83
|
pretty_key = k.to_s.gsub(/_/, ' ').gsub(/\w+/){ |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize }
|
84
84
|
if Chef::Config[:knife][k].nil?
|
85
|
-
errors << "You did not
|
85
|
+
errors << "You did not provide a valid '#{pretty_key}' value."
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -57,6 +57,12 @@ class Chef
|
|
57
57
|
:default => ["default"],
|
58
58
|
:proc => Proc.new { |groups| groups.split(',') }
|
59
59
|
|
60
|
+
option :tags,
|
61
|
+
:short => "-T T=V[,T=V,...]",
|
62
|
+
:long => "--tags Tag=Value[,Tag=Value...]",
|
63
|
+
:description => "The tags for this server",
|
64
|
+
:proc => Proc.new { |tags| tags.split(',') }
|
65
|
+
|
60
66
|
option :availability_zone,
|
61
67
|
:short => "-Z ZONE",
|
62
68
|
:long => "--availability-zone ZONE",
|
@@ -86,6 +92,13 @@ class Chef
|
|
86
92
|
:long => "--ssh-password PASSWORD",
|
87
93
|
:description => "The ssh password"
|
88
94
|
|
95
|
+
option :ssh_port,
|
96
|
+
:short => "-p PORT",
|
97
|
+
:long => "--ssh-port PORT",
|
98
|
+
:description => "The ssh port",
|
99
|
+
:default => "22",
|
100
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
|
101
|
+
|
89
102
|
option :identity_file,
|
90
103
|
:short => "-i IDENTITY_FILE",
|
91
104
|
:long => "--identity-file IDENTITY_FILE",
|
@@ -103,9 +116,9 @@ class Chef
|
|
103
116
|
option :distro,
|
104
117
|
:short => "-d DISTRO",
|
105
118
|
:long => "--distro DISTRO",
|
106
|
-
:description => "Bootstrap a distro using a template",
|
119
|
+
:description => "Bootstrap a distro using a template; default is 'chef-full'",
|
107
120
|
:proc => Proc.new { |d| Chef::Config[:knife][:distro] = d },
|
108
|
-
:default => "
|
121
|
+
:default => "chef-full"
|
109
122
|
|
110
123
|
option :template_file,
|
111
124
|
:long => "--template-file TEMPLATE",
|
@@ -148,7 +161,7 @@ class Chef
|
|
148
161
|
:default => nil
|
149
162
|
|
150
163
|
def tcp_test_ssh(hostname)
|
151
|
-
tcp_socket = TCPSocket.new(hostname,
|
164
|
+
tcp_socket = TCPSocket.new(hostname, config[:ssh_port])
|
152
165
|
readable = IO.select([tcp_socket], nil, nil, 5)
|
153
166
|
if readable
|
154
167
|
Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
|
@@ -171,6 +184,10 @@ class Chef
|
|
171
184
|
rescue Errno::EHOSTUNREACH
|
172
185
|
sleep 2
|
173
186
|
false
|
187
|
+
# This happens on EC2 sometimes
|
188
|
+
rescue Errno::ENETUNREACH
|
189
|
+
sleep 2
|
190
|
+
false
|
174
191
|
ensure
|
175
192
|
tcp_socket && tcp_socket.close
|
176
193
|
end
|
@@ -182,12 +199,25 @@ class Chef
|
|
182
199
|
|
183
200
|
server = connection.servers.create(create_server_def)
|
184
201
|
|
202
|
+
hashed_tags={}
|
203
|
+
tags.map{ |t| key,val=t.split('='); hashed_tags[key]=val} unless tags.nil?
|
204
|
+
|
205
|
+
# Always set the Name tag
|
206
|
+
unless hashed_tags.keys.include? "Name"
|
207
|
+
hashed_tags["Name"] = locate_config_value(:chef_node_name) || server.id
|
208
|
+
end
|
209
|
+
|
210
|
+
hashed_tags.each_pair do |key,val|
|
211
|
+
connection.tags.create :key => key, :value => val, :resource_id => server.id
|
212
|
+
end
|
213
|
+
|
185
214
|
msg_pair("Instance ID", server.id)
|
186
215
|
msg_pair("Flavor", server.flavor_id)
|
187
216
|
msg_pair("Image", server.image_id)
|
188
217
|
msg_pair("Region", connection.instance_variable_get(:@region))
|
189
218
|
msg_pair("Availability Zone", server.availability_zone)
|
190
219
|
msg_pair("Security Groups", server.groups.join(", "))
|
220
|
+
msg_pair("Tags", hashed_tags)
|
191
221
|
msg_pair("SSH Key", server.key_name)
|
192
222
|
|
193
223
|
print "\n#{ui.color("Waiting for server", :magenta)}"
|
@@ -196,7 +226,7 @@ class Chef
|
|
196
226
|
server.wait_for { print "."; ready? }
|
197
227
|
|
198
228
|
puts("\n")
|
199
|
-
|
229
|
+
|
200
230
|
if vpc_mode?
|
201
231
|
msg_pair("Subnet ID", server.subnet_id)
|
202
232
|
else
|
@@ -207,9 +237,9 @@ class Chef
|
|
207
237
|
msg_pair("Private IP Address", server.private_ip_address)
|
208
238
|
|
209
239
|
print "\n#{ui.color("Waiting for sshd", :magenta)}"
|
210
|
-
|
240
|
+
|
211
241
|
fqdn = vpc_mode? ? server.private_ip_address : server.dns_name
|
212
|
-
|
242
|
+
|
213
243
|
print(".") until tcp_test_ssh(fqdn) {
|
214
244
|
sleep @initial_sleep_delay ||= (vpc_mode? ? 40 : 10)
|
215
245
|
puts("done")
|
@@ -224,6 +254,7 @@ class Chef
|
|
224
254
|
msg_pair("Region", connection.instance_variable_get(:@region))
|
225
255
|
msg_pair("Availability Zone", server.availability_zone)
|
226
256
|
msg_pair("Security Groups", server.groups.join(", "))
|
257
|
+
msg_pair("Tags", hashed_tags)
|
227
258
|
msg_pair("SSH Key", server.key_name)
|
228
259
|
msg_pair("Root Device Type", server.root_device_type)
|
229
260
|
if server.root_device_type == "ebs"
|
@@ -259,6 +290,7 @@ class Chef
|
|
259
290
|
bootstrap.name_args = [fqdn]
|
260
291
|
bootstrap.config[:run_list] = config[:run_list]
|
261
292
|
bootstrap.config[:ssh_user] = config[:ssh_user]
|
293
|
+
bootstrap.config[:ssh_port] = config[:ssh_port]
|
262
294
|
bootstrap.config[:identity_file] = config[:identity_file]
|
263
295
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
|
264
296
|
bootstrap.config[:prerelease] = config[:prerelease]
|
@@ -291,7 +323,16 @@ class Chef
|
|
291
323
|
exit 1
|
292
324
|
end
|
293
325
|
end
|
294
|
-
|
326
|
+
|
327
|
+
def tags
|
328
|
+
tags = locate_config_value(:tags)
|
329
|
+
if !tags.nil? and tags.length != tags.to_s.count('=')
|
330
|
+
ui.error("Tags should be entered in a key = value pair")
|
331
|
+
exit 1
|
332
|
+
end
|
333
|
+
tags
|
334
|
+
end
|
335
|
+
|
295
336
|
def create_server_def
|
296
337
|
server_def = {
|
297
338
|
:image_id => locate_config_value(:image),
|
@@ -335,7 +376,7 @@ class Chef
|
|
335
376
|
'Ebs.DeleteOnTermination' => delete_term
|
336
377
|
}]
|
337
378
|
end
|
338
|
-
|
379
|
+
|
339
380
|
server_def
|
340
381
|
end
|
341
382
|
end
|
@@ -19,6 +19,10 @@
|
|
19
19
|
|
20
20
|
require 'chef/knife/ec2_base'
|
21
21
|
|
22
|
+
# These two are needed for the '--purge' deletion case
|
23
|
+
require 'chef/node'
|
24
|
+
require 'chef/api_client'
|
25
|
+
|
22
26
|
class Chef
|
23
27
|
class Knife
|
24
28
|
class Ec2ServerDelete < Knife
|
@@ -27,6 +31,33 @@ class Chef
|
|
27
31
|
|
28
32
|
banner "knife ec2 server delete SERVER [SERVER] (options)"
|
29
33
|
|
34
|
+
option :purge,
|
35
|
+
:short => "-P",
|
36
|
+
:long => "--purge",
|
37
|
+
:boolean => true,
|
38
|
+
:default => false,
|
39
|
+
:description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the EC2 node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
|
40
|
+
|
41
|
+
option :chef_node_name,
|
42
|
+
:short => "-N NAME",
|
43
|
+
:long => "--node-name NAME",
|
44
|
+
:description => "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
|
45
|
+
|
46
|
+
# Extracted from Chef::Knife.delete_object, because it has a
|
47
|
+
# confirmation step built in... By specifying the '--purge'
|
48
|
+
# flag (and also explicitly confirming the server destruction!)
|
49
|
+
# the user is already making their intent known. It is not
|
50
|
+
# necessary to make them confirm two more times.
|
51
|
+
def destroy_item(klass, name, type_name)
|
52
|
+
begin
|
53
|
+
object = klass.load(name)
|
54
|
+
object.destroy
|
55
|
+
ui.warn("Deleted #{type_name} #{name}")
|
56
|
+
rescue Net::HTTPServerException
|
57
|
+
ui.warn("Could not find a #{type_name} named #{name} to delete!")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
30
61
|
def run
|
31
62
|
|
32
63
|
validate!
|
@@ -56,6 +87,14 @@ class Chef
|
|
56
87
|
|
57
88
|
ui.warn("Deleted server #{server.id}")
|
58
89
|
|
90
|
+
if config[:purge]
|
91
|
+
thing_to_delete = config[:chef_node_name] || instance_id
|
92
|
+
destroy_item(Chef::Node, thing_to_delete, "node")
|
93
|
+
destroy_item(Chef::ApiClient, thing_to_delete, "client")
|
94
|
+
else
|
95
|
+
ui.warn("Corresponding node and client for the #{instance_id} server were not deleted and remain registered with the Chef Server")
|
96
|
+
end
|
97
|
+
|
59
98
|
rescue NoMethodError
|
60
99
|
ui.error("Could not locate server '#{instance_id}'. Please verify it was provisioned in the '#{locate_config_value(:region)}' region.")
|
61
100
|
end
|
@@ -65,4 +104,3 @@ class Chef
|
|
65
104
|
end
|
66
105
|
end
|
67
106
|
end
|
68
|
-
|
data/lib/knife-ec2/version.rb
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -17,15 +17,27 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require File.expand_path('../../spec_helper', __FILE__)
|
20
|
+
require 'fog'
|
21
|
+
require 'chef/knife/bootstrap'
|
20
22
|
|
21
23
|
describe Chef::Knife::Ec2ServerCreate do
|
22
24
|
before do
|
23
|
-
@knife_ec2_create = Chef::Knife::Ec2ServerCreate.new
|
24
|
-
@knife_ec2_create.name_args = ['role[base]']
|
25
|
+
@knife_ec2_create = Chef::Knife::Ec2ServerCreate.new
|
25
26
|
@knife_ec2_create.initial_sleep_delay = 0
|
26
27
|
@knife_ec2_create.stub!(:tcp_test_ssh).and_return(true)
|
27
28
|
|
28
|
-
|
29
|
+
{
|
30
|
+
:image => 'image',
|
31
|
+
:aws_ssh_key_id => 'aws_ssh_key_id',
|
32
|
+
:aws_access_key_id => 'aws_access_key_id',
|
33
|
+
:aws_secret_access_key => 'aws_secret_access_key'
|
34
|
+
}.each do |key, value|
|
35
|
+
Chef::Config[:knife][key] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
@ec2_connection = mock(Fog::Compute::AWS)
|
39
|
+
@ec2_connection.stub_chain(:tags).and_return mock('create', :create => true)
|
40
|
+
@ec2_connection.stub_chain(:images, :get).and_return mock('ami', :root_device_type => 'not_ebs')
|
29
41
|
@ec2_servers = mock()
|
30
42
|
@new_ec2_server = mock()
|
31
43
|
|
@@ -36,9 +48,10 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
36
48
|
:key_name => 'my_ssh_key',
|
37
49
|
:groups => ['group1', 'group2'],
|
38
50
|
:dns_name => 'ec2-75.101.253.10.compute-1.amazonaws.com',
|
39
|
-
:
|
51
|
+
:public_ip_address => '75.101.253.10',
|
40
52
|
:private_dns_name => 'ip-10-251-75-20.ec2.internal',
|
41
|
-
:private_ip_address => '10.251.75.20'
|
53
|
+
:private_ip_address => '10.251.75.20',
|
54
|
+
:root_device_type => 'not_ebs' }
|
42
55
|
|
43
56
|
@ec2_server_attribs.each_pair do |attrib, value|
|
44
57
|
@new_ec2_server.stub!(attrib).and_return(value)
|
@@ -46,13 +59,12 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
46
59
|
end
|
47
60
|
|
48
61
|
describe "run" do
|
49
|
-
|
50
62
|
it "creates an EC2 instance and bootstraps it" do
|
51
63
|
@new_ec2_server.should_receive(:wait_for).and_return(true)
|
52
64
|
@ec2_servers.should_receive(:create).and_return(@new_ec2_server)
|
53
65
|
@ec2_connection.should_receive(:servers).and_return(@ec2_servers)
|
54
66
|
|
55
|
-
Fog::AWS
|
67
|
+
Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
|
56
68
|
|
57
69
|
@knife_ec2_create.stub!(:puts)
|
58
70
|
@knife_ec2_create.stub!(:print)
|
@@ -64,6 +76,48 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
64
76
|
@bootstrap.should_receive(:run)
|
65
77
|
@knife_ec2_create.run
|
66
78
|
end
|
79
|
+
end
|
80
|
+
describe "when setting tags" do
|
81
|
+
before do
|
82
|
+
Fog::Compute::AWS.should_receive(:new).and_return(@ec2_connection)
|
83
|
+
@knife_ec2_create.stub!(:bootstrap_for_node).and_return mock("bootstrap", :run => true)
|
84
|
+
@ec2_connection.stub!(:servers).and_return(@ec2_servers)
|
85
|
+
@new_ec2_server.stub!(:wait_for).and_return(true)
|
86
|
+
@ec2_servers.stub!(:create).and_return(@new_ec2_server)
|
87
|
+
@knife_ec2_create.stub!(:puts)
|
88
|
+
@knife_ec2_create.stub!(:print)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "sets the Name tag to the instance id by default" do
|
92
|
+
@ec2_connection.tags.should_receive(:create).with(:key => "Name",
|
93
|
+
:value => @new_ec2_server.id,
|
94
|
+
:resource_id => @new_ec2_server.id)
|
95
|
+
@knife_ec2_create.run
|
96
|
+
end
|
97
|
+
|
98
|
+
it "sets the Name tag to the chef_node_name when given" do
|
99
|
+
@knife_ec2_create.config[:chef_node_name] = "wombat"
|
100
|
+
@ec2_connection.tags.should_receive(:create).with(:key => "Name",
|
101
|
+
:value => "wombat",
|
102
|
+
:resource_id => @new_ec2_server.id)
|
103
|
+
@knife_ec2_create.run
|
104
|
+
end
|
105
|
+
|
106
|
+
it "sets the Name tag to the specified name when given --tags Name=NAME" do
|
107
|
+
@knife_ec2_create.config[:tags] = ["Name=bobcat"]
|
108
|
+
@ec2_connection.tags.should_receive(:create).with(:key => "Name",
|
109
|
+
:value => "bobcat",
|
110
|
+
:resource_id => @new_ec2_server.id)
|
111
|
+
@knife_ec2_create.run
|
112
|
+
end
|
113
|
+
|
114
|
+
it "sets arbitrary tags" do
|
115
|
+
@knife_ec2_create.config[:tags] = ["foo=bar"]
|
116
|
+
@ec2_connection.tags.should_receive(:create).with(:key => "foo",
|
117
|
+
:value => "bar",
|
118
|
+
:resource_id => @new_ec2_server.id)
|
119
|
+
@knife_ec2_create.run
|
120
|
+
end
|
67
121
|
|
68
122
|
end
|
69
123
|
|
@@ -71,11 +125,13 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
71
125
|
before do
|
72
126
|
@knife_ec2_create.config[:ssh_user] = "ubuntu"
|
73
127
|
@knife_ec2_create.config[:identity_file] = "~/.ssh/aws-key.pem"
|
128
|
+
@knife_ec2_create.config[:ssh_port] = 22
|
74
129
|
@knife_ec2_create.config[:chef_node_name] = "blarf"
|
75
130
|
@knife_ec2_create.config[:template_file] = '~/.chef/templates/my-bootstrap.sh.erb'
|
76
131
|
@knife_ec2_create.config[:distro] = 'ubuntu-10.04-magic-sparkles'
|
132
|
+
@knife_ec2_create.config[:run_list] = ['role[base]']
|
77
133
|
|
78
|
-
@bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
|
134
|
+
@bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
|
79
135
|
end
|
80
136
|
|
81
137
|
it "should set the bootstrap 'name argument' to the hostname of the EC2 server" do
|
@@ -94,6 +150,10 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
94
150
|
@bootstrap.config[:identity_file].should == "~/.ssh/aws-key.pem"
|
95
151
|
end
|
96
152
|
|
153
|
+
it "configures the bootstrap to use the correct ssh_port number" do
|
154
|
+
@bootstrap.config[:ssh_port].should == 22
|
155
|
+
end
|
156
|
+
|
97
157
|
it "configures the bootstrap to use the configured node name if provided" do
|
98
158
|
@bootstrap.config[:chef_node_name].should == 'blarf'
|
99
159
|
end
|
@@ -101,7 +161,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
101
161
|
it "configures the bootstrap to use the EC2 server id if no explicit node name is set" do
|
102
162
|
@knife_ec2_create.config[:chef_node_name] = nil
|
103
163
|
|
104
|
-
bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
|
164
|
+
bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
|
105
165
|
bootstrap.config[:chef_node_name].should == @new_ec2_server.id
|
106
166
|
end
|
107
167
|
|
@@ -110,7 +170,7 @@ describe Chef::Knife::Ec2ServerCreate do
|
|
110
170
|
|
111
171
|
@knife_ec2_create.config[:prerelease] = true
|
112
172
|
|
113
|
-
bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server)
|
173
|
+
bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
|
114
174
|
bootstrap.config[:prerelease].should be_true
|
115
175
|
end
|
116
176
|
|
metadata
CHANGED
@@ -1,45 +1,53 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-ec2
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.12
|
4
5
|
prerelease:
|
5
|
-
version: 0.5.10
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Adam Jacob
|
9
9
|
- Seth Chisamore
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
dependencies:
|
17
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-05-15 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
18
16
|
name: fog
|
19
|
-
|
20
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &70349127587980 !ruby/object:Gem::Requirement
|
21
18
|
none: false
|
22
|
-
requirements:
|
19
|
+
requirements:
|
23
20
|
- - ~>
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version:
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.3'
|
26
23
|
type: :runtime
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70349127587980
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: chef
|
28
|
+
requirement: &70349127587440 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.10
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70349127587440
|
37
|
+
description: EC2 Support for Chef's Knife Command
|
38
|
+
email:
|
30
39
|
- adam@opscode.com
|
31
40
|
- schisamo@opscode.com
|
32
41
|
executables: []
|
33
|
-
|
34
42
|
extensions: []
|
35
|
-
|
36
|
-
extra_rdoc_files:
|
43
|
+
extra_rdoc_files:
|
37
44
|
- README.rdoc
|
38
45
|
- LICENSE
|
39
|
-
files:
|
46
|
+
files:
|
40
47
|
- .gitignore
|
41
48
|
- .rspec
|
42
49
|
- Gemfile
|
50
|
+
- Gemfile.lock
|
43
51
|
- LICENSE
|
44
52
|
- README.rdoc
|
45
53
|
- Rakefile
|
@@ -52,34 +60,30 @@ files:
|
|
52
60
|
- lib/knife-ec2/version.rb
|
53
61
|
- spec/spec_helper.rb
|
54
62
|
- spec/unit/ec2_server_create_spec.rb
|
55
|
-
has_rdoc: true
|
56
63
|
homepage: http://wiki.opscode.com/display/chef
|
57
64
|
licenses: []
|
58
|
-
|
59
65
|
post_install_message:
|
60
66
|
rdoc_options: []
|
61
|
-
|
62
|
-
require_paths:
|
67
|
+
require_paths:
|
63
68
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
70
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
76
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version:
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
76
81
|
requirements: []
|
77
|
-
|
78
82
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.17
|
80
84
|
signing_key:
|
81
85
|
specification_version: 3
|
82
|
-
summary:
|
83
|
-
test_files:
|
86
|
+
summary: EC2 Support for Chef's Knife Command
|
87
|
+
test_files:
|
84
88
|
- spec/spec_helper.rb
|
85
89
|
- spec/unit/ec2_server_create_spec.rb
|