vagrant-remote-forward 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 017a61fca3a1a151b65627c42261bd495100a13b
4
+ data.tar.gz: 7f7fc0d04ab5139b9cf772c2428b496ea1539c8a
5
+ SHA512:
6
+ metadata.gz: 8a10d55e026f6239c2a6f8b42f9307160ab96067080a23899c4ee78be16999c466f1d401414b9f7042ff9b73c362c1f4915b41e19a016b267b399c39fbe22261
7
+ data.tar.gz: 435c609c81a3f64b05a46605a88e57ed21644f3758984be8abd8c0d5001e6f56668b297442eb90d80c073fbd83942e3c8fa1a8bdaa5f770a6d43a1fbc3fd52b4
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ group :development do
5
+ gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
6
+ end
7
+
8
+ group :plugins do
9
+ gem "vagrant-remote-forward", path: "."
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Patrick Lenz
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,50 @@
1
+ # vagrant-remote-forward
2
+
3
+ As part of a chef-server push-setup, vagrant-remote-forward will, for
4
+ example, give you access to a proxy running on the machine you execute your
5
+ vagrant provisioning commands on, effectively allowing you to firewall off
6
+ permanent access to your chef server.
7
+
8
+ On a more general level, you can forward ports on the remote machine that it,
9
+ in and of itself, would not have access to otherwise.
10
+
11
+ ## Installation
12
+
13
+ vagrant plugin install vagrant-remote-forward
14
+
15
+ ## Usage
16
+
17
+ Add your port forward configuration to your `Vagrantfile`:
18
+
19
+ Vagrant.configure '2' do
20
+ # ..
21
+ config.remote_forward.add 5000, '192.168.1.1', 8000
22
+ end
23
+
24
+ This will forward port `8000` on the VM to the host `192.168.1.1:5000` on
25
+ your local network. (I know the syntax feels backwards, but this is what's
26
+ being used in [OpenSSH][] and I felt it'd be even more confusing to deviate from
27
+ that de-facto stanard.)
28
+
29
+ It will also work in a multi-vm environment:
30
+
31
+ Vagrant.configure '2' do
32
+ # ..
33
+ config.vm.define 'A' do |a|
34
+ a.remote_forward.add 5000, '192.168.1.1', 8000
35
+ end
36
+
37
+ config.vm.define 'B' do |b|
38
+ a.remote_forward.add 6000, '192.168.1.10', 7000
39
+ end
40
+ end
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
49
+
50
+ [OpenSSH]: http://www.openbsd.org/cgi-bin/man.cgi?query=ssh&sektion=1
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require_relative 'vagrant-remote-forward/plugin'
@@ -0,0 +1,22 @@
1
+ module VagrantPlugins
2
+ module RemoteForward
3
+ class Config < Vagrant.plugin(2, :config)
4
+ Forward = Struct.new(:port, :host, :remoteport)
5
+
6
+ attr_accessor :add, :forwards
7
+
8
+ def initialize
9
+ @forwards = []
10
+ # @widgets = UNSET_VALUE
11
+ end
12
+
13
+ def add(port, host, remoteport)
14
+ forwards << Forward.new(port, host, remoteport)
15
+ end
16
+
17
+ def finalize!
18
+ # @widgets = 0 if @widgets == UNSET_VALUE
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module VagrantPlugins
2
+ module RemoteForward
3
+ class Plugin < Vagrant.plugin('2')
4
+ name "Vagrant Remote Forward"
5
+
6
+ config "remote_forward" do
7
+ require_relative "config"
8
+ Config
9
+ end
10
+
11
+ action_hook :setup_remote_forward do |hook|
12
+ require_relative 'setup'
13
+
14
+ if defined?(VagrantPlugins::ProxyConf)
15
+ require 'vagrant-proxyconf/action/configure_env_proxy'
16
+ hook.after VagrantPlugins::ProxyConf::Action::ConfigureEnvProxy,
17
+ VagrantPlugins::RemoteForward::Setup
18
+ else
19
+ hook.before :run_provisioner, VagrantPlugins::RemoteForward::Setup
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module RemoteForward
3
+ class Setup
4
+ def initialize(app, env)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ if forwards = env[:machine].config.remote_forward.forwards
10
+ # TODO: Find a public API for this instead of relying on protected
11
+ # methods
12
+ env[:machine].communicate.send(:connect) do |ssh|
13
+ forwards.each do |f|
14
+ env[:ui].info "Adding remote forward for #{f.remoteport} forwarding to #{f.host}:#{f.port}"
15
+ ssh.forward.remote f.port, f.host, f.remoteport
16
+ end
17
+ end
18
+ end
19
+ @app.call env
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module RemoteForward
3
+ VERSION = "0.0.1"
4
+ end
5
+ 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-remote-forward/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-remote-forward"
8
+ spec.version = VagrantPlugins::RemoteForward::VERSION
9
+ spec.authors = ["Patrick Lenz"]
10
+ spec.email = ["plenz@topmedia.de"]
11
+ spec.description = "Add remote forward ports from the box to the host"
12
+ spec.summary = "Add remote forward ports from the box to the host"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-remote-forward
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Lenz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-13 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Add remote forward ports from the box to the host
42
+ email:
43
+ - plenz@topmedia.de
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-remote-forward.rb
54
+ - lib/vagrant-remote-forward/config.rb
55
+ - lib/vagrant-remote-forward/plugin.rb
56
+ - lib/vagrant-remote-forward/setup.rb
57
+ - lib/vagrant-remote-forward/version.rb
58
+ - vagrant-remote-forward.gemspec
59
+ homepage: ''
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.1.11
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Add remote forward ports from the box to the host
83
+ test_files: []