adamhjk (owner)

Revisions

gist: 216395 Download_button fork
public
Public Clone URL: git://gist.github.com/216395.git
Embed All Files: show embed
client.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Chef Client Config File
 
require 'ohai'
require 'json'
 
o = Ohai::System.new
o.all_plugins
chef_config = JSON.parse(o[:ec2][:userdata])
if chef_config.kind_of?(Array)
  chef_config = chef_config[o[:ec2][:ami_launch_index]]
end
 
log_level :info
log_location STDOUT
chef_server_url chef_config["chef_server"]
registration_url chef_config["chef_server"]
openid_url chef_config["chef_server"]
template_url chef_config["chef_server"]
remotefile_url chef_config["chef_server"]
search_url chef_config["chef_server"]
role_url chef_config["chef_server"]
client_url chef_config["chef_server"]
 
unless File.exists?("/etc/chef/client.pem")
  File.open("/etc/chef/validation.pem", "w") do |f|
    f.print(chef_config["validation_key"])
  end
end
 
if chef_config.has_key?("attributes")
  File.open("/etc/chef/client-config.json", "w") do |f|
    f.print(JSON.pretty_generate(chef_config["attributes"]))
  end
  json_attribs "/etc/chef/client-config.json"
end
 
validation_key "/etc/chef/validation.pem"
validation_client_name chef_config["validation_client_name"]
 
Chef::Log::Formatter.show_time = true