vagrant-info 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +13 -0
- data/Gemfile +7 -0
- data/README.md +64 -0
- data/Rakefile +7 -0
- data/lib/vagrant-info.rb +6 -0
- data/lib/vagrant-info/infoindex_command.rb +43 -0
- data/lib/vagrant-info/infossh_command.rb +51 -0
- data/lib/vagrant-info/plugin.rb +21 -0
- data/lib/vagrant-info/version.rb +5 -0
- data/vagrant-info.gemspec +23 -0
- metadata +83 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e97480d99c1f359fbe3b551643f7ef68e92b87d3
|
|
4
|
+
data.tar.gz: 8d8fb69ba1ceb5b57e0cb53a8b68731846221854
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d67e3c3a96dda53fb209a6249cd2da8fae8fc2b01e8ddc5d88f4739b08ff3755c122d21478853b650a6979a574c20fa0398222ccd663ee7cd7895689720c198a
|
|
7
|
+
data.tar.gz: 42d93212f30b18b79c3edf9930547e6f38f1417ab3b977c67521c6e6e87bbd6434b7cdedd5d2047c248868d446653c43c2317c6b5ce62e9c21c86db01f644d71
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
script: rake build
|
|
3
|
+
rvm:
|
|
4
|
+
- 2.1
|
|
5
|
+
- 2.0.0
|
|
6
|
+
deploy:
|
|
7
|
+
provider: rubygems
|
|
8
|
+
api_key:
|
|
9
|
+
secure: eT/LaxKL3Pz1sJMERnEQMPetQKZI0CZ17xzS7NUxvRwZuGfiot4V23YHxmts5bfbQB/ZhkbxWwgI51fsUu7oyHBYLxen6RIGVPuSaQF2CnIVivYB7/JG0iRb59cIfE0nsU4OcDnvb5mAJt5RNmhFUbrs4eAM08a2Oxkg0UGzsR8=
|
|
10
|
+
gem: vagrant-info
|
|
11
|
+
on:
|
|
12
|
+
tags: true
|
|
13
|
+
repo: marsam/vagrant-info
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# vagrant info
|
|
2
|
+
[](https://travis-ci.org/marsam/vagrant-info)
|
|
3
|
+
|
|
4
|
+
> **Disclaimer** This plugin actually doesn't nothing more than the commands [ssh-config][] and [global-status][]
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
$ vagrant plugin install vagrant-info
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
This package offers two vagrant subcommands:
|
|
13
|
+
|
|
14
|
+
`info-ssh`
|
|
15
|
+
: Outputs the same output as [ssh-config][] but with the machine `id` as instead machine name in the `Hostname`.
|
|
16
|
+
|
|
17
|
+
`info-ssh`
|
|
18
|
+
: Outputs a csv with the entries of [machine_index](https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/machine_index.rb), same as [global-status][]
|
|
19
|
+
|
|
20
|
+
### Tutorial
|
|
21
|
+
Let's guess that you have the following [multi-machine](https://docs.vagrantup.com/v2/multi-machine/) Vagrantfile, inside the directory `~/some/where`:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
# -*- mode: ruby -*-
|
|
25
|
+
|
|
26
|
+
Vagrant.configure("2") do |config|
|
|
27
|
+
config.ssh.forward_agent = true
|
|
28
|
+
|
|
29
|
+
config.vm.define "web" do |web|
|
|
30
|
+
web.vm.box = "ubuntu/trusty64"
|
|
31
|
+
web.vm.hostname = "ubuntu"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
config.vm.define "db" do |db|
|
|
35
|
+
db.vm.box = "chef/centos-6.5"
|
|
36
|
+
db.vm.hostname = "centos"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
And you need to connect through ssh to the machine named `db`
|
|
42
|
+
|
|
43
|
+
**Normal steps**
|
|
44
|
+
|
|
45
|
+
1. Start up the machine `db`, you can choose the following options:
|
|
46
|
+
+ Go to `~/some/where` and execute `vagrant up db`
|
|
47
|
+
+ Check the `id` of your machine with `vagrant global-status` or `vagrant info-index` and execute `vagrant up <id>`
|
|
48
|
+
|
|
49
|
+
2. Go to `~/some/where` and execute `vagrant ssh db`
|
|
50
|
+
|
|
51
|
+
**With `vagrant-info`**
|
|
52
|
+
|
|
53
|
+
1. (Same step 1.)
|
|
54
|
+
2. Execute `vagrant info-ssh <id> >> ~/.ssh/config` and the next time you can use: `ssh <id>`.
|
|
55
|
+
|
|
56
|
+
If you don't want to polute your `ssh_config(5)` with configurations of vagrant machines you can use a custom configfile:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
$ vagrant info-ssh <id> >> ~/.vagrant-sshconfig
|
|
60
|
+
$ ssh -T ~/.vagrant-sshconfig <id>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
[ssh-config]: https://docs.vagrantup.com/v2/cli/ssh_config.html "vagrant ssh-config"
|
|
64
|
+
[global-status]: https://docs.vagrantup.com/v2/cli/global-status.html "vagrant global-status"
|
data/Rakefile
ADDED
data/lib/vagrant-info.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'csv'
|
|
2
|
+
require 'optparse'
|
|
3
|
+
|
|
4
|
+
require "vagrant/util/safe_puts"
|
|
5
|
+
|
|
6
|
+
module VagrantPlugins
|
|
7
|
+
module CommandInfo
|
|
8
|
+
class Command < Vagrant.plugin("2", :command)
|
|
9
|
+
include Vagrant::Util::SafePuts
|
|
10
|
+
|
|
11
|
+
def self.synopsis
|
|
12
|
+
"Outputs machine readable infomation of a vagrant machine_index."
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def execute
|
|
16
|
+
opts = OptionParser.new do |o|
|
|
17
|
+
o.banner = "Usage: vagrant info"
|
|
18
|
+
o.separator ""
|
|
19
|
+
end
|
|
20
|
+
argv = parse_options(opts)
|
|
21
|
+
return if !argv
|
|
22
|
+
|
|
23
|
+
columns = [["id", :id],
|
|
24
|
+
["name", :name],
|
|
25
|
+
["provider", :provider],
|
|
26
|
+
["state", :state],
|
|
27
|
+
["directory", :vagrantfile_path]]
|
|
28
|
+
output = CSV.generate do |csv|
|
|
29
|
+
csv << columns.map { |header, _| header }
|
|
30
|
+
@env.machine_index.each do |entry|
|
|
31
|
+
csv << columns.map do |_, method|
|
|
32
|
+
v = entry.send(method)
|
|
33
|
+
method == :id ? v[0...7] : v
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
safe_puts output
|
|
38
|
+
0
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'csv'
|
|
2
|
+
require 'optparse'
|
|
3
|
+
|
|
4
|
+
require "vagrant/util/safe_puts"
|
|
5
|
+
|
|
6
|
+
module VagrantPlugins
|
|
7
|
+
module CommandInfo
|
|
8
|
+
class Command < Vagrant.plugin("2", :command)
|
|
9
|
+
include Vagrant::Util::SafePuts
|
|
10
|
+
|
|
11
|
+
def self.synopsis
|
|
12
|
+
"Ouput the ssh configuration of a vagrant box."
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def execute
|
|
16
|
+
opts = OptionParser.new do |o|
|
|
17
|
+
o.banner = "Usage: vagrant sshinfo [name]"
|
|
18
|
+
o.separator ""
|
|
19
|
+
end
|
|
20
|
+
argv = parse_options(opts)
|
|
21
|
+
return if !argv
|
|
22
|
+
|
|
23
|
+
with_target_vms(argv) do |machine|
|
|
24
|
+
safe_puts sshconfig machine
|
|
25
|
+
safe_puts
|
|
26
|
+
end
|
|
27
|
+
0
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
def sshconfig(machine)
|
|
33
|
+
ssh_info = machine.ssh_info
|
|
34
|
+
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
|
35
|
+
variables = {
|
|
36
|
+
host_key: machine.index_uuid.to_s[0...7],
|
|
37
|
+
ssh_host: ssh_info[:host],
|
|
38
|
+
ssh_port: ssh_info[:port],
|
|
39
|
+
ssh_user: ssh_info[:username],
|
|
40
|
+
private_key_path: ssh_info[:private_key_path],
|
|
41
|
+
forward_agent: ssh_info[:forward_agent],
|
|
42
|
+
forward_x11: ssh_info[:forward_x11],
|
|
43
|
+
proxy_command: ssh_info[:proxy_command]
|
|
44
|
+
}
|
|
45
|
+
template = "commands/ssh_config/config"
|
|
46
|
+
Vagrant::Util::TemplateRenderer.render(template, variables)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module CommandInfo
|
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
|
4
|
+
name "info command"
|
|
5
|
+
|
|
6
|
+
description <<-DESC
|
|
7
|
+
This plugin shows the information of a vagrant box
|
|
8
|
+
DESC
|
|
9
|
+
|
|
10
|
+
command("info-index") do
|
|
11
|
+
require File.expand_path("../infoindex_command", __FILE__)
|
|
12
|
+
Command
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
command("info-ssh") do
|
|
16
|
+
require File.expand_path("../infossh_command", __FILE__)
|
|
17
|
+
Command
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'vagrant-info/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "vagrant-info"
|
|
8
|
+
spec.version = VagrantPlugins::Info::VERSION
|
|
9
|
+
spec.authors = ["Mario Rodas"]
|
|
10
|
+
spec.email = ["marsam@users.noreply.github.com"]
|
|
11
|
+
spec.homepage = "https://github.com/marsam/vagrant-info"
|
|
12
|
+
spec.summary = %q{Get information from vagrant machines.}
|
|
13
|
+
spec.description = %q{Vagrant plugin to get information from vagrant machines.}
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vagrant-info
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mario Rodas
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: Vagrant plugin to get information from vagrant machines.
|
|
42
|
+
email:
|
|
43
|
+
- marsam@users.noreply.github.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- ".gitignore"
|
|
49
|
+
- ".travis.yml"
|
|
50
|
+
- Gemfile
|
|
51
|
+
- README.md
|
|
52
|
+
- Rakefile
|
|
53
|
+
- lib/vagrant-info.rb
|
|
54
|
+
- lib/vagrant-info/infoindex_command.rb
|
|
55
|
+
- lib/vagrant-info/infossh_command.rb
|
|
56
|
+
- lib/vagrant-info/plugin.rb
|
|
57
|
+
- lib/vagrant-info/version.rb
|
|
58
|
+
- vagrant-info.gemspec
|
|
59
|
+
homepage: https://github.com/marsam/vagrant-info
|
|
60
|
+
licenses:
|
|
61
|
+
- MIT
|
|
62
|
+
metadata: {}
|
|
63
|
+
post_install_message:
|
|
64
|
+
rdoc_options: []
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0'
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
requirements: []
|
|
78
|
+
rubyforge_project:
|
|
79
|
+
rubygems_version: 2.2.2
|
|
80
|
+
signing_key:
|
|
81
|
+
specification_version: 4
|
|
82
|
+
summary: Get information from vagrant machines.
|
|
83
|
+
test_files: []
|