-
-
Save imeyer/276412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"] | |
node_name o[:ec2][:instance_id] # instance_ids are unique, hostnames might not be | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"validation_key": "... redacted ...", | |
"attributes": { | |
"run_list": [ | |
"role[monkey]" | |
] | |
}, | |
"chef_server": "https:\/\/api.opscode.com\/organizations\/opscode", | |
"validation_client_name": "opscode-validator" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment