chef 0.9.10.rc.1 → 0.9.10.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/bootstrap.rb +40 -25
- data/lib/chef/knife/rackspace_server_create.rb +1 -1
- data/lib/chef/node/attribute.rb +7 -0
- data/lib/chef/version.rb +1 -1
- metadata +3 -3
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -109,49 +109,64 @@ class Chef
|
|
109
109
|
context = {}
|
110
110
|
context[:run_list] = config[:run_list]
|
111
111
|
context[:config] = config
|
112
|
-
|
112
|
+
Erubis::Eruby.new(template).evaluate(context)
|
113
113
|
end
|
114
114
|
|
115
115
|
def run
|
116
116
|
require 'highline'
|
117
117
|
|
118
|
-
|
119
|
-
Chef::Log.error("Must pass an FQDN or ip to bootstrap")
|
120
|
-
exit 1
|
121
|
-
end
|
122
|
-
|
123
|
-
config[:server_name] = Array(@name_args).first
|
118
|
+
validate_name_args!
|
124
119
|
|
125
120
|
$stdout.sync = true
|
126
121
|
|
127
|
-
|
122
|
+
Chef::Log.info("Bootstrapping Chef on #{h.color(config[:server_name], :bold)}")
|
128
123
|
|
129
|
-
|
130
|
-
|
124
|
+
begin
|
125
|
+
knife_ssh.run
|
126
|
+
rescue Net::SSH::AuthenticationFailed
|
127
|
+
unless config[:ssh_password]
|
128
|
+
puts "Failed to authenticate #{config[:ssh_user]} - trying password auth"
|
129
|
+
knife_ssh_with_password_auth.run
|
130
|
+
end
|
131
131
|
end
|
132
|
+
end
|
132
133
|
|
133
|
-
|
134
|
+
def validate_name_args!
|
135
|
+
if Array(@name_args).first.nil?
|
136
|
+
Chef::Log.error("Must pass an FQDN or ip to bootstrap")
|
137
|
+
exit 1
|
138
|
+
end
|
139
|
+
end
|
134
140
|
|
141
|
+
def server_name
|
142
|
+
Array(@name_args).first
|
143
|
+
end
|
144
|
+
|
145
|
+
def knife_ssh
|
135
146
|
ssh = Chef::Knife::Ssh.new
|
136
|
-
ssh.name_args = [
|
147
|
+
ssh.name_args = [ server_name, ssh_command ]
|
137
148
|
ssh.config[:ssh_user] = config[:ssh_user]
|
138
|
-
ssh.config[:
|
149
|
+
ssh.config[:ssh_password] = config[:ssh_password]
|
139
150
|
ssh.config[:identity_file] = config[:identity_file]
|
140
151
|
ssh.config[:manual] = true
|
152
|
+
ssh
|
153
|
+
end
|
141
154
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
155
|
+
def knife_ssh_with_password_auth
|
156
|
+
ssh = knife_ssh
|
157
|
+
ssh.config[:identity_file] = nil
|
158
|
+
ssh.config[:ssh_password] = ssh.get_password
|
159
|
+
ssh
|
160
|
+
end
|
161
|
+
|
162
|
+
def ssh_command
|
163
|
+
command = render_template(load_template(config[:bootstrap_template]))
|
164
|
+
|
165
|
+
if config[:use_sudo]
|
166
|
+
command = "sudo #{command}"
|
154
167
|
end
|
168
|
+
|
169
|
+
command
|
155
170
|
end
|
156
171
|
|
157
172
|
end
|
@@ -144,7 +144,7 @@ EOH
|
|
144
144
|
ssh.name_args = [ server.addresses["public"][0], "/bin/bash /etc/install-chef && /usr/bin/chef-client -j /etc/chef/first-boot.json" ]
|
145
145
|
ssh.config[:ssh_user] = "root"
|
146
146
|
ssh.config[:manual] = true
|
147
|
-
ssh.config[:
|
147
|
+
ssh.config[:ssh_password] = saved_password
|
148
148
|
ssh.password = saved_password
|
149
149
|
ssh.run
|
150
150
|
|
data/lib/chef/node/attribute.rb
CHANGED
@@ -364,6 +364,10 @@ class Chef
|
|
364
364
|
data_hash
|
365
365
|
end
|
366
366
|
|
367
|
+
def auto_vivifiy_on_read?
|
368
|
+
auto_vivifiy_on_read
|
369
|
+
end
|
370
|
+
|
367
371
|
def auto_vivifiy(data_hash, key)
|
368
372
|
if data_hash.has_key?(key)
|
369
373
|
unless data_hash[key].respond_to?(:has_key?)
|
@@ -417,6 +421,9 @@ class Chef
|
|
417
421
|
self[symbol]
|
418
422
|
elsif key?(symbol.to_s)
|
419
423
|
self[symbol.to_s]
|
424
|
+
elsif auto_vivifiy_on_read?
|
425
|
+
self[symbol] = Mash.new
|
426
|
+
self[symbol]
|
420
427
|
else
|
421
428
|
raise ArgumentError, "Attribute #{symbol} is not defined!" unless auto_vivifiy_on_read
|
422
429
|
end
|
data/lib/chef/version.rb
CHANGED
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 9
|
8
8
|
- 10
|
9
9
|
- rc
|
10
|
-
-
|
11
|
-
version: 0.9.10.rc.
|
10
|
+
- 2
|
11
|
+
version: 0.9.10.rc.2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Adam Jacob
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-08 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|