require "tempfile"
require "veil"

secrets_file = ENV['SECRETS_FILE'] || "/etc/opscode/private-chef-secrets.json"
credentials = Veil::CredentialCollection::ChefSecretsFile.from_file(secrets_file)

key = Tempfile.new("latovip")
key.puts credentials.get("chef-server", "superuser_key")
key.flush
key.close

node_name "pivotal"
chef_server_url "<%= @prefix %>://<%= @vip %>"
chef_server_root "<%= @prefix %>://<%= @vip %>"
no_proxy "<%= node['private_chef']['lb']['vip'] %>"
client_key key.path
ssl_verify_mode :verify_none

require "tempfile"
require "veil"

secrets_file = ENV['SECRETS_FILE'] || "/etc/opscode/private-chef-secrets.json"
credentials = Veil::CredentialCollection::ChefSecretsFile.from_file(secrets_file)

key = Tempfile.new("latovip")
key.puts credentials.get("chef-server", "superuser_key")
key.flush
key.close

node_name "pivotal"
chef_server_url "<%= @prefix %>://<%= @vip %>"
chef_server_root "<%= @prefix %>://<%= @vip %>"
no_proxy "<%= node['private_chef']['lb']['vip'] %>"
client_key key.path
ssl_verify_mode :verify_none

at_exit do
  # By holding onto key to reference it in at_exit,
  # we ensure that it won't be GC'd and unlinked before
  # knife is done with it.
  key.unlink
end

Use at_exit to prevent tempfile from unlinkng too soon
Use at_exit to prevent tempfile from unlinkng too soon

Signed-off-by: Marc A. Paradise <4ac6359ea5d0ef3cc5b5e469a74ec987143cad16@gmail.com>
