vagrant-shell-local 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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +15 -0
- data/examples/Vagrantfile +11 -0
- data/lib/vagrant-shell-local/config.rb +23 -0
- data/lib/vagrant-shell-local/errors.rb +16 -0
- data/lib/vagrant-shell-local/plugin.rb +25 -0
- data/lib/vagrant-shell-local/provisioner.rb +19 -0
- data/lib/vagrant-shell-local/version.rb +5 -0
- data/lib/vagrant-shell-local.rb +8 -0
- data/vagrant-shell-local.gemspec +24 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a41c5e2aa81787edda86a7facac6d211a6f814a2
|
4
|
+
data.tar.gz: aecf7c6ab317ec1625c522bc364aa998dd4afa19
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2cae36a13e5aa26024ccf2bd42fe6d99637e435b70d9f096f9cbb7bfa552c060684ba1e453766bfedc4a47d7d47623a6c98acd608e7bc022218d42cb03b9322b
|
7
|
+
data.tar.gz: 78d75b244fa798e37c726d0860445cfbda56061213eced50bd9c8158138268828c8b28c43b710e79a8fdee3534c5d601fa9623fb8c69a2fde683ee04132b60a8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in vagrant-host-shell.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# We depend on Vagrant for development, but we don't add it as a
|
7
|
+
# gem dependency because we expect to be installed within the
|
8
|
+
# Vagrant environment itself using `vagrant plugin`.
|
9
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Paul Hinze
|
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,31 @@
|
|
1
|
+
# vagrant-shell-local plugin (inspired by vagrant-host-shell & this thread http://superuser.com/questions/701735/run-script-on-host-machine-during-vagrant-up)
|
2
|
+
|
3
|
+
a vagrant provisioner to run commands on the host when a VM boots.
|
4
|
+
|
5
|
+
## example usage
|
6
|
+
|
7
|
+
Install as a plugin:
|
8
|
+
|
9
|
+
```
|
10
|
+
vagrant plugin install vagrant-host-shell
|
11
|
+
```
|
12
|
+
|
13
|
+
Add this to `Vagrantfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
config.vm.provision :shell_local, command: ['bash', '-c', 'touch /tmp/hostshell-works && echo hello from the host && hostname 1>&2']
|
17
|
+
```
|
18
|
+
|
19
|
+
Run `vagrant up` (or `vagrant provision` if machine is already running.)
|
20
|
+
|
21
|
+
Observe that `/tmp/hostshell-works` is present on your host, and that the provisioner output:
|
22
|
+
|
23
|
+
```
|
24
|
+
[stdout] hello from the host
|
25
|
+
[stderr] (your host's hostname)
|
26
|
+
```
|
27
|
+
|
28
|
+
# motivation
|
29
|
+
|
30
|
+
I decided to create and publish this plug-in because I didn't see activity on `vagrant-host-shell` about two years. It has accepted pull request for PATH fix which I required, but it wasn't published during 7 month (on this plug-in creation moment)
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
# Immediately sync all stdout so that tools like buildbot can
|
5
|
+
# immediately load in the output.
|
6
|
+
$stdout.sync = true
|
7
|
+
$stderr.sync = true
|
8
|
+
|
9
|
+
# Change to the directory of this file.
|
10
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
11
|
+
|
12
|
+
# This installs the tasks that help with gem creation and
|
13
|
+
# publishing.
|
14
|
+
Bundler::GemHelper.install_tasks
|
15
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
5
|
+
require 'vagrant-shell-local'
|
6
|
+
|
7
|
+
Vagrant.configure("2") do |config|
|
8
|
+
config.vm.box = "ubuntu/trusty64"
|
9
|
+
|
10
|
+
config.vm.provision :shell_local, command: ['bash', '-c', 'touch /tmp/hostshell-works && echo hello from the host && hostname 1>&2']
|
11
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module VagrantPlugins::ShellLocal
|
2
|
+
class Config < Vagrant.plugin('2', :config)
|
3
|
+
attr_accessor :command
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@command = UNSET_VALUE
|
7
|
+
end
|
8
|
+
|
9
|
+
def finalize!
|
10
|
+
@command = nil if @inline == UNSET_VALUE
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate(machine)
|
14
|
+
errors = _detected_errors
|
15
|
+
|
16
|
+
unless command.is_a?(Array) || command.is_a?(String)
|
17
|
+
errors << ':shell_local provisioner requires command to be set and be an array or a string'
|
18
|
+
end
|
19
|
+
|
20
|
+
{ 'host shell provisioner' => errors }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins::ShellLocal::Errors
|
2
|
+
|
3
|
+
class VagrantShellLocalError < Vagrant::Errors::VagrantError; end
|
4
|
+
|
5
|
+
class NonZeroStatusError < VagrantShellLocalError
|
6
|
+
def initialize(command, exit_code)
|
7
|
+
@command = command
|
8
|
+
@exit_code = exit_code
|
9
|
+
super nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def error_message
|
13
|
+
"Command [#{@command}] exited with non-zero status [#{@exit_code}]"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
begin
|
2
|
+
require 'vagrant'
|
3
|
+
rescue LoadError
|
4
|
+
raise 'The vagrant-shell-local plugin must be run within Vagrant.'
|
5
|
+
end
|
6
|
+
|
7
|
+
module VagrantPlugins::ShellLocal
|
8
|
+
class Plugin < Vagrant.plugin('2')
|
9
|
+
name 'vagrant-shell-local'
|
10
|
+
description <<-DESC.gsub(/^ +/, '')
|
11
|
+
A simple provisioner to run commands on the host at machine
|
12
|
+
boot, instead of the guest.
|
13
|
+
DESC
|
14
|
+
|
15
|
+
config(:shell_local, :provisioner) do
|
16
|
+
require_relative 'config'
|
17
|
+
Config
|
18
|
+
end
|
19
|
+
|
20
|
+
provisioner(:shell_local) do
|
21
|
+
require_relative 'provisioner'
|
22
|
+
Provisioner
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module VagrantPlugins::ShellLocal
|
4
|
+
class Provisioner < Vagrant.plugin('2', :provisioner)
|
5
|
+
def provision
|
6
|
+
result = Vagrant::Util::Subprocess.execute(
|
7
|
+
*config.command,
|
8
|
+
:notify => [:stdout, :stderr],
|
9
|
+
:env => {PATH: ENV["VAGRANT_OLD_ENV_PATH"]},
|
10
|
+
) do |io_name, data|
|
11
|
+
@machine.env.ui.info "[#{io_name}] #{data}"
|
12
|
+
end
|
13
|
+
|
14
|
+
if !result.exit_code.zero?
|
15
|
+
raise VagrantPlugins::ShellLocal::Errors::NonZeroStatusError.new(config.command, result.exit_code)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'vagrant-shell-local/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "vagrant-shell-local"
|
9
|
+
spec.version = VagrantPlugins::ShellLocal::VERSION
|
10
|
+
spec.authors = ["Alexander Bondarev"]
|
11
|
+
spec.email = ["alexander.i.bondarev@gmail.com"]
|
12
|
+
spec.description = %q{a vagrant provisioner to run commands on the host}
|
13
|
+
spec.summary = %q{a vagrant provisioner to run commands on the host}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-shell-local
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Bondarev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-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.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: a vagrant provisioner to run commands on the host
|
42
|
+
email:
|
43
|
+
- alexander.i.bondarev@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- examples/Vagrantfile
|
54
|
+
- lib/vagrant-shell-local.rb
|
55
|
+
- lib/vagrant-shell-local/config.rb
|
56
|
+
- lib/vagrant-shell-local/errors.rb
|
57
|
+
- lib/vagrant-shell-local/plugin.rb
|
58
|
+
- lib/vagrant-shell-local/provisioner.rb
|
59
|
+
- lib/vagrant-shell-local/version.rb
|
60
|
+
- vagrant-shell-local.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.4.5.1
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: a vagrant provisioner to run commands on the host
|
85
|
+
test_files: []
|