vagrant info

Travis build status

Disclaimer This plugin actually doesn't nothing more than the commands ssh-config and global-status

Installation

$ vagrant plugin install vagrant-info

Usage

This package offers two vagrant subcommands:

info-ssh : Outputs the same output as ssh-config but with the machine id as instead machine name in the Hostname.

info-ssh : Outputs a csv with the entries of machine_index, same as global-status

Tutorial

Let's guess that you have the following multi-machine Vagrantfile, inside the directory ~/some/where:

# -*- mode: ruby -*-

Vagrant.configure("2") do |config|
  config.ssh.forward_agent = true

  config.vm.define "web" do |web|
    web.vm.box      = "ubuntu/trusty64"
    web.vm.hostname = "ubuntu"
  end

  config.vm.define "db" do |db|
    db.vm.box      = "chef/centos-6.5"
    db.vm.hostname = "centos"
  end
end

And you need to connect through ssh to the machine named db

Normal steps

  1. Start up the machine db, you can choose the following options:

    • Go to ~/some/where and execute vagrant up db
    • Check the id of your machine with vagrant global-status or vagrant info-index and execute vagrant up <id>
  2. Go to ~/some/where and execute vagrant ssh db

With vagrant-info

  1. (Same step 1.)
  2. Execute vagrant info-ssh <id> >> ~/.ssh/config and the next time you can use: ssh <id>.

If you don't want to polute your ssh_config(5) with configurations of vagrant machines you can use a custom configfile:

   $ vagrant info-ssh <id> >> ~/.vagrant-sshconfig
   $ ssh -T ~/.vagrant-sshconfig <id>