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.
@@ -109,49 +109,64 @@ class Chef
109
109
  context = {}
110
110
  context[:run_list] = config[:run_list]
111
111
  context[:config] = config
112
- command = Erubis::Eruby.new(template).evaluate(context)
112
+ Erubis::Eruby.new(template).evaluate(context)
113
113
  end
114
114
 
115
115
  def run
116
116
  require 'highline'
117
117
 
118
- if @name_args.first == nil
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
- command = render_template(load_template(config[:bootstrap_template]))
122
+ Chef::Log.info("Bootstrapping Chef on #{h.color(config[:server_name], :bold)}")
128
123
 
129
- if config[:use_sudo]
130
- command = "sudo #{command}"
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
- Chef::Log.info("Bootstrapping Chef on #{h.color(config[:server_name], :bold)}")
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 = [ config[:server_name], command ]
147
+ ssh.name_args = [ server_name, ssh_command ]
137
148
  ssh.config[:ssh_user] = config[:ssh_user]
138
- ssh.config[:password] = config[:ssh_password]
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
- begin
143
- ssh.run
144
- rescue Net::SSH::AuthenticationFailed
145
- unless config[:ssh_password]
146
- puts "Failed to authenticate #{config[:ssh_user]} - trying password auth"
147
- ssh = Chef::Knife::Ssh.new
148
- ssh.name_args = [ config[:server_name], command ]
149
- ssh.config[:ssh_user] = config[:ssh_user]
150
- ssh.config[:manual] = true
151
- ssh.config[:password] = ssh.get_password
152
- ssh.run
153
- end
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[:password] = saved_password
147
+ ssh.config[:ssh_password] = saved_password
148
148
  ssh.password = saved_password
149
149
  ssh.run
150
150
 
@@ -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
@@ -17,5 +17,5 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '0.9.10.rc.1'
20
+ VERSION = '0.9.10.rc.2'
21
21
  end
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 9
8
8
  - 10
9
9
  - rc
10
- - 1
11
- version: 0.9.10.rc.1
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-07 00:00:00 -07:00
19
+ date: 2010-10-08 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency