-
-
Save Aslan/326145 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Automatically grabs configuration from ohai ec2 metadata. | |
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] | |
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"] | |
Mixlib::Log::Formatter.show_time = true |
This file contains 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
{ | |
"attributes": { | |
"run_list": [ | |
"recipe[foo]", | |
"role[bar]" | |
] | |
}, | |
"validation_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAyehqT9Rp2mD2w4KMUwW5ctQ1z\/Kklz+EA0BPNso4Ka1X7Q4O\nJlPcVrCTrh8SUp9h6khbLpcShK4uDVh7LDTU66UzpALBMTd\/8BFkHLPjs2KCd2tj\nLP3uNeBn9UitP1PXyFM2cesHYv6iRMAfKa1XKJKZ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4fD3cnSJnR+\n9bAmzDenOXBI2o+f+zyEYdECgYAQ5u31zOa0nSiUJTC\/11C7uuR8BjCZdqvEbaA4\n4Yb2JI\/7F2TR7JF86HsxhtKVi439D8EmHLIEQ2jfxxj7PTqsle2Ou4Pm7agiZA24\nhtQhaWTJxFOC4FmiyacAEN6rz3VFQq8arf5Fe5nen+Jk5EP2HJDIZQwUv3Lim\/YS\nyMlLlwKBgQDHCxJIvdNSDj9txpvMpyiPD64XglTupy6xKRjSjiC6DLpDn2jvvisc\nD1lrEnpZCow62Azpp2kyA\/g2DbDPiwwPVDGXibvtl5TtYZCdsrzl0CZS5DXlMxfc\nwirursGexJa5Sdapio9VZnjkc2XSIDQkySdNNjfpGeF9A7xlIP17DQ==\n-----END RSA PRIVATE KEY-----\n", | |
"validation_client_name": "chef-validator", | |
"chef_server": "http:\/\/localhost:4000" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment