vagrant-host-route 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +41 -0
- data/Rakefile +4 -0
- data/lib/vagrant-host-route.rb +10 -0
- data/lib/vagrant-host-route/bsd/configure_route.rb +21 -0
- data/lib/vagrant-host-route/bsd/host.rb +17 -0
- data/lib/vagrant-host-route/config.rb +30 -0
- data/lib/vagrant-host-route/plugin.rb +23 -0
- data/lib/vagrant-host-route/provisioner.rb +14 -0
- data/lib/vagrant-host-route/version.rb +5 -0
- data/vagrant-host-route.gemspec +23 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d9c26e9af18432e5cc2f77bad9c4188f46a0703
|
4
|
+
data.tar.gz: c7fee69d902ab026d7c80cacc8741759ca051de7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28f1b21c2a683aba388a82d535610a4a3e1756eed34c1fcf7eb86d733366967ef7e44d1d94231de6a7596b0b768be8c069679bcf7f6c067ad13e28c5f931a75e
|
7
|
+
data.tar.gz: b6cde085704c1fd31ba7c6e8f4d9b3880eeb0d83b252db1fda0e954f195cd4e549673213eb179c008201bfbc98a3c47e83c31f815e04a35bf5230c0b4985bd52
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# OS-specific
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
# editors
|
5
|
+
*.swp
|
6
|
+
|
7
|
+
# Bundler/Rubygems
|
8
|
+
*.gem
|
9
|
+
.bundle
|
10
|
+
pkg/*
|
11
|
+
tags
|
12
|
+
Gemfile.lock
|
13
|
+
|
14
|
+
# Vagrant
|
15
|
+
.vagrant
|
16
|
+
Vagrantfile
|
17
|
+
!example_box/Vagrantfile
|
18
|
+
|
19
|
+
# RVM files for gemset/ruby setting
|
20
|
+
.ruby-*
|
21
|
+
.rvmrc
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in vagrant-host-route.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
|
8
|
+
end
|
9
|
+
|
10
|
+
group :plugins do
|
11
|
+
gem "vagrant-host-route", path: "."
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Arctic Wolf Networks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Vagrant Host Route Provisioner
|
2
|
+
|
3
|
+
A provisioner to configure a route from the host to a particular destination
|
4
|
+
via a particular gateway, with the gateway typically being on a Vagrant-managed
|
5
|
+
guest. The route is deleted if the guest is destroyed.
|
6
|
+
|
7
|
+
The implementation relies on Vagrant's host capabilities. Currently, the plugin
|
8
|
+
supports only BSD hosts and in particular has been tested only on OS X. However,
|
9
|
+
contributions to add support for other hosts are more than welcome.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Use `vagrant plugin install`:
|
14
|
+
|
15
|
+
$ vagrant plugin install vagrant-host-route
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
The provisioner supports two attributes, `destination` and `gateway`, and
|
20
|
+
requires than both be specified.
|
21
|
+
|
22
|
+
### Example
|
23
|
+
|
24
|
+
Create a route to 10.1.1.0/24 via 10.0.5.1. It is assumed that 10.0.5.1 is an
|
25
|
+
address on of the interfaces of the guest being provisioned, although strictly
|
26
|
+
speaking that is not a requirement.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
config.vm.provision :host_route do |host_route|
|
30
|
+
host_route.destination = "10.1.1.0/24"
|
31
|
+
host_route.gateway = "10.0.5.1"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module HostBSD
|
3
|
+
module Cap
|
4
|
+
class HostRoute
|
5
|
+
include Vagrant::Util
|
6
|
+
|
7
|
+
def self.configure_host_route(environment, destination, gateway)
|
8
|
+
r = Vagrant::Util::Subprocess.execute("route", "get", destination)
|
9
|
+
if !r.stdout.include? "gateway: #{gateway}"
|
10
|
+
delete_host_route(environment, destination)
|
11
|
+
Vagrant::Util::Subprocess.execute("sudo", "route", "-q", "add", destination, gateway)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.delete_host_route(environment, destination)
|
16
|
+
Vagrant::Util::Subprocess.execute("sudo", "route", "-q", "delete", destination)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module HostBSD
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
host_capability("bsd", "configure_host_route") do
|
7
|
+
require_relative "configure_route"
|
8
|
+
Cap::HostRoute
|
9
|
+
end
|
10
|
+
|
11
|
+
host_capability("bsd", "delete_host_route") do
|
12
|
+
require_relative "configure_route"
|
13
|
+
Cap::HostRoute
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module HostRoute
|
3
|
+
class Config < Vagrant.plugin("2", :config)
|
4
|
+
attr_accessor :destination
|
5
|
+
attr_accessor :gateway
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@destination = UNSET_VALUE
|
9
|
+
@gateway = UNSET_VALUE
|
10
|
+
end
|
11
|
+
|
12
|
+
def finalize!
|
13
|
+
@destination = nil if @destination == UNSET_VALUE
|
14
|
+
@gateway = nil if @gateway == UNSET_VALUE
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate(machine)
|
18
|
+
errors = _detected_errors
|
19
|
+
|
20
|
+
if !@destination
|
21
|
+
errors << "A destination is required"
|
22
|
+
end
|
23
|
+
if !@gateway
|
24
|
+
errors << "A gateway is required"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module HostRoute
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "host_route"
|
7
|
+
description <<-DESC
|
8
|
+
Provides support for creating host routes.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
config(:host_route, :provisioner) do
|
12
|
+
require_relative "config"
|
13
|
+
Config
|
14
|
+
end
|
15
|
+
|
16
|
+
provisioner(:host_route) do
|
17
|
+
require_relative "provisioner"
|
18
|
+
require_relative "bsd/host"
|
19
|
+
Provisioner
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module HostRoute
|
3
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
4
|
+
def provision
|
5
|
+
@machine.env.host.capability(:configure_host_route,
|
6
|
+
config.destination, config.gateway)
|
7
|
+
end
|
8
|
+
|
9
|
+
def cleanup
|
10
|
+
@machine.env.host.capability(:delete_host_route, config.destination)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
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-host-route/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-host-route"
|
8
|
+
spec.version = VagrantPlugins::HostRoute::VERSION
|
9
|
+
spec.authors = ["Arctic Wolf Networks"]
|
10
|
+
spec.email = ["dev@arcticwolf.com"]
|
11
|
+
spec.summary = %q{Create a route on the host via a Vagrant-managed guest.}
|
12
|
+
spec.description = %q{Create a route on the host via a Vagrant-managed guest.}
|
13
|
+
spec.homepage = ""
|
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,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-host-route
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arctic Wolf Networks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-15 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: Create a route on the host via a Vagrant-managed guest.
|
42
|
+
email:
|
43
|
+
- dev@arcticwolf.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/vagrant-host-route.rb
|
54
|
+
- lib/vagrant-host-route/bsd/configure_route.rb
|
55
|
+
- lib/vagrant-host-route/bsd/host.rb
|
56
|
+
- lib/vagrant-host-route/config.rb
|
57
|
+
- lib/vagrant-host-route/plugin.rb
|
58
|
+
- lib/vagrant-host-route/provisioner.rb
|
59
|
+
- lib/vagrant-host-route/version.rb
|
60
|
+
- vagrant-host-route.gemspec
|
61
|
+
homepage: ''
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.14
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Create a route on the host via a Vagrant-managed guest.
|
85
|
+
test_files: []
|