Sha256: ecbbc84b38abc8db95faa77ecaa47fa224b6f253b2c652d3ad44e801947c12c2

Contents?: true

Size: 865 Bytes

Versions: 12

Compression:

Stored size: 865 Bytes

Contents

module VagrantPlugins
module CORL
module Action
class InitKeys < BaseAction

  def call(env)
    super do
      env[:ui].info I18n.t("corl.vagrant.actions.init_keys.start")

      if node.public_key
        ssh_key = ::CORL::Util::Disk.read(node.public_key)

        if ssh_key && ! ssh_key.empty?
          env[:machine].communicate.tap do |comm|
            comm.execute("echo '#{ssh_key}' > \$HOME/.ssh/authorized_keys")
          end
          node.set_cache_setting(:use_private_key, true)
          env[:machine].config.ssh.private_key_path = node.private_key

          # Needed for Vagrant 1.7+
          vagrant_key_file = env[:machine].data_dir.join("private_key")
          ::CORL::Util::Disk.delete(vagrant_key_file) if File.exists?(vagrant_key_file)

          node.machine.load
        end
      end
      @app.call env
    end
  end
end
end
end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
corl-0.5.18 lib/core/vagrant/actions/init_keys.rb
corl-0.5.17 lib/core/vagrant/actions/init_keys.rb
corl-0.5.16 lib/core/vagrant/actions/init_keys.rb
corl-0.5.15 lib/core/vagrant/actions/init_keys.rb
corl-0.5.14 lib/core/vagrant/actions/init_keys.rb
corl-0.5.13 lib/core/vagrant/actions/init_keys.rb
corl-0.5.12 lib/core/vagrant/actions/init_keys.rb
corl-0.5.11 lib/core/vagrant/actions/init_keys.rb
corl-0.5.10 lib/core/vagrant/actions/init_keys.rb
corl-0.5.9 lib/core/vagrant/actions/init_keys.rb
corl-0.5.8 lib/core/vagrant/actions/init_keys.rb
corl-0.5.7 lib/core/vagrant/actions/init_keys.rb