Guest User

Untitled

a guest
Apr 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. # Chef Client Config File
  2. # Automatically grabs configuration from ohai ec2 metadata.
  3.  
  4. require 'ohai'
  5. require 'json'
  6.  
  7. o = Ohai::System.new
  8. o.all_plugins
  9. chef_config = JSON.parse(o[:ec2][:userdata])
  10. if chef_config.kind_of?(Array)
  11. chef_config = chef_config[o[:ec2][:ami_launch_index]]
  12. end
  13.  
  14. log_level :info
  15. log_location STDOUT
  16. chef_server_url chef_config["chef_server"]
  17. registration_url chef_config["chef_server"]
  18. openid_url chef_config["chef_server"]
  19. template_url chef_config["chef_server"]
  20. remotefile_url chef_config["chef_server"]
  21. search_url chef_config["chef_server"]
  22. role_url chef_config["chef_server"]
  23. client_url chef_config["chef_server"]
  24.  
  25. node_name o[:ec2][:instance_id]
  26.  
  27. unless File.exists?("/etc/chef/client.pem")
  28. File.open("/etc/chef/validation.pem", "w") do |f|
  29. f.print(chef_config["validation_key"])
  30. end
  31. end
  32.  
  33. if chef_config.has_key?("attributes")
  34. File.open("/etc/chef/client-config.json", "w") do |f|
  35. f.print(JSON.pretty_generate(chef_config["attributes"]))
  36. end
  37. json_attribs "/etc/chef/client-config.json"
  38. end
  39.  
  40. validation_key "/etc/chef/validation.pem"
  41. validation_client_name chef_config["validation_client_name"]
Add Comment
Please, Sign In to add comment