class VagrantPlugins::CORL::Action::InitKeys
Public Instance Methods
call(env)
click to toggle source
Calls superclass method
VagrantPlugins::CORL::BaseAction#call
# File lib/core/vagrant/actions/init_keys.rb 7 def call(env) 8 super do 9 env[:ui].info I18n.t("corl.vagrant.actions.init_keys.start") 10 11 if node.public_key 12 ssh_key = ::CORL::Util::Disk.read(node.public_key) 13 14 if ssh_key && ! ssh_key.empty? 15 env[:machine].communicate.tap do |comm| 16 comm.execute("echo '#{ssh_key}' > \$HOME/.ssh/authorized_keys") 17 end 18 node.set_cache_setting(:use_private_key, true) 19 env[:machine].config.ssh.private_key_path = node.private_key 20 21 # Needed for Vagrant 1.7+ 22 vagrant_key_file = env[:machine].data_dir.join("private_key") 23 ::CORL::Util::Disk.delete(vagrant_key_file) if File.exists?(vagrant_key_file) 24 25 node.machine.load 26 end 27 end 28 @app.call env 29 end 30 end