vagrant-bundlewrap 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +3 -0
- data/lib/vagrant-bundlewrap.rb +1 -0
- data/lib/vagrant-bundlewrap/bwmanage.rb +43 -0
- data/lib/vagrant-bundlewrap/config.rb +46 -0
- data/lib/vagrant-bundlewrap/plugin.rb +19 -0
- data/lib/vagrant-bundlewrap/provisioner.rb +32 -0
- data/lib/vagrant-bundlewrap/sshconf.rb +63 -0
- data/lib/vagrant-bundlewrap/version.rb +5 -0
- data/vagrant-bundlewrap.gemspec +24 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ceccbb76b8d6d70c162bbd80250c0157421e2a1
|
4
|
+
data.tar.gz: a7152342522a917c8ce94802dfaf00ed253d14d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2ee2767d405e021bf41c7eeefe76822707c7e31cbaa320ee04e369b14f7a032c1e48267dfac66509c5ef9761fc85e52bcd91b8f8c87ad10f8dfe332db5bb4a7
|
7
|
+
data.tar.gz: 9468ff014844a38afa436f5ccbf62a8292257faec2a7fa36f709b019faaa8464264e65817cb333cff77d7a0b030e69adb5268b2ba0666cb516cfecd2a8ecf1a8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Benjamin Kendinibilir
|
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,21 @@
|
|
1
|
+
# Vagrant BundleWrap Provisioner
|
2
|
+
|
3
|
+
This is a [Vagrant](http://www.vagrantup.com) plugin that adds an [BundleWrap](http://bundlewrap.org) provisioner to Vagrant, supporting to provision your virtual machines with a local BundleWrap repository.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First [install BundleWrap](http://docs.bundlewrap.org/en/latest/installation.html):
|
8
|
+
|
9
|
+
pip install bundlewrap
|
10
|
+
|
11
|
+
Then just type it on your vagrant environment:
|
12
|
+
|
13
|
+
vagrant plugin install vagrant-bundlewrap
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it ( http://github.com/bkendinibilir/vagrant-bundlewrap/fork )
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "vagrant-bundlewrap/plugin"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module BundleWrap
|
3
|
+
class BwManage
|
4
|
+
|
5
|
+
def initialize(repo_path)
|
6
|
+
@repo_path = repo_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def bw_cli(params, ret_stdout=true)
|
10
|
+
params = params.gsub(/[^a-zA-Z0-9\-\_\.\s]/,'')
|
11
|
+
old_path = Dir.pwd
|
12
|
+
Dir.chdir(@repo_path)
|
13
|
+
if ret_stdout
|
14
|
+
result = `bw #{params}`
|
15
|
+
else
|
16
|
+
result = system("bw #{params}")
|
17
|
+
end
|
18
|
+
Dir.chdir(old_path)
|
19
|
+
return result
|
20
|
+
end
|
21
|
+
|
22
|
+
def nodes()
|
23
|
+
nodes = bw_cli("nodes")
|
24
|
+
return nodes.split("\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
def node_hosts()
|
28
|
+
nodes = bw_cli("nodes --hostname")
|
29
|
+
return nodes.split("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
def apply(node, interactive=false)
|
33
|
+
node = node.gsub(/[^a-zA-Z0-9\-\_\.]/,'')
|
34
|
+
if interactive
|
35
|
+
return bw_cli("apply #{node} -i", ret_stdout=false)
|
36
|
+
else
|
37
|
+
return bw_cli("apply #{node}", ret_stdout=false)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module BundleWrap
|
3
|
+
class Config < Vagrant.plugin("2", :config)
|
4
|
+
attr_accessor :repo_path
|
5
|
+
attr_accessor :node_name
|
6
|
+
attr_accessor :node_host
|
7
|
+
attr_accessor :interactive
|
8
|
+
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@repo_path = UNSET_VALUE
|
12
|
+
@node_name = UNSET_VALUE
|
13
|
+
@node_host = UNSET_VALUE
|
14
|
+
@interactive = UNSET_VALUE
|
15
|
+
end
|
16
|
+
|
17
|
+
def finalize!
|
18
|
+
@repo_path = "bundlewrap/" if @repo_path == UNSET_VALUE
|
19
|
+
@node_name = nil if @node_name == UNSET_VALUE
|
20
|
+
@node_host = nil if @node_host == UNSET_VALUE
|
21
|
+
@interactive = false if @interactive == UNSET_VALUE
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate(machine)
|
25
|
+
errors = _detected_errors
|
26
|
+
|
27
|
+
unless File.directory?(repo_path) and File.exist?("#{repo_path}/nodes.py") and File.exist?("#{repo_path}/groups.py")
|
28
|
+
errors << "BundleWrap repository is missing in repo_path='#{repo_path}'.\n" +
|
29
|
+
" Create a new one with 'bw repo create'."
|
30
|
+
end
|
31
|
+
|
32
|
+
unless @node_name
|
33
|
+
errors << "BundleWrap config 'node_name' is not set. Use the node name from your BundleWrap nodes.py."
|
34
|
+
end
|
35
|
+
|
36
|
+
unless @node_host
|
37
|
+
errors << "BundleWrap config 'node_host' is not set. Use the node host from your BundleWrap nodes.py.\n" +
|
38
|
+
" This does not have to be a valid host name (e.g. 'node1.vm'), but it should be a unique one,\n" +
|
39
|
+
" because it will be written in your ssh config file."
|
40
|
+
end
|
41
|
+
|
42
|
+
{ "vagrant-bundlewrap" => errors }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module BundleWrap
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "vagrant-bundlewrap"
|
7
|
+
|
8
|
+
config(:bundlewrap, :provisioner) do
|
9
|
+
require_relative "config"
|
10
|
+
Config
|
11
|
+
end
|
12
|
+
|
13
|
+
provisioner(:bundlewrap) do
|
14
|
+
require_relative "provisioner"
|
15
|
+
Provisioner
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require_relative "bwmanage"
|
3
|
+
require_relative "sshconf"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module BundleWrap
|
7
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
8
|
+
|
9
|
+
def initialize(machine, config)
|
10
|
+
super(machine, config)
|
11
|
+
@logger = Log4r::Logger.new("vagrant::provisioners::bundlewrap")
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(root_config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def provision
|
18
|
+
ssh = SshConf.new
|
19
|
+
ssh.update(config.node_host, @machine.ssh_info)
|
20
|
+
bw = BwManage.new(config.repo_path)
|
21
|
+
bw.apply(config.node_name, config.interactive)
|
22
|
+
end
|
23
|
+
|
24
|
+
def cleanup
|
25
|
+
bw = BwManage.new(config.repo_path)
|
26
|
+
ssh = SshConf.new
|
27
|
+
ssh.remove_hosts(bw.node_hosts)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "ssh-config"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module BundleWrap
|
5
|
+
class SshConf
|
6
|
+
|
7
|
+
def initialize()
|
8
|
+
touch()
|
9
|
+
@ssh_config = ConfigFile.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def touch()
|
13
|
+
unless File.directory?(ENV['HOME'] + "/.ssh")
|
14
|
+
FileUtils.mkdir_p(ENV['HOME'] + "/.ssh")
|
15
|
+
end
|
16
|
+
FileUtils.touch(ENV['HOME'] + "/.ssh/config")
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(host, ssh_info)
|
20
|
+
@ssh_config.set(host, 'HostName', ssh_info[:host])
|
21
|
+
@ssh_config.set(host, 'Port', ssh_info[:port])
|
22
|
+
@ssh_config.set(host, 'User', ssh_info[:username])
|
23
|
+
|
24
|
+
ssh_keys = ssh_info[:private_key_path]
|
25
|
+
ssh_keys.each do |ssh_key|
|
26
|
+
@ssh_config.set(host, 'IdentityFile', ssh_key)
|
27
|
+
end
|
28
|
+
|
29
|
+
if ssh_info[:forward_agent]
|
30
|
+
@ssh_config.set(host, 'ForwardAgent', 'yes')
|
31
|
+
end
|
32
|
+
|
33
|
+
if ssh_info[:forward_x11]
|
34
|
+
@ssh_config.set(host, 'ForwardX11', 'yes')
|
35
|
+
end
|
36
|
+
|
37
|
+
if ssh_info[:proxy_command]
|
38
|
+
@ssh_config.set(host, 'ProxyCommand', ssh_info[:proxy_command])
|
39
|
+
end
|
40
|
+
|
41
|
+
@ssh_config.set(host, 'UserKnownHostsFile', '/dev/null')
|
42
|
+
@ssh_config.set(host, 'StrictHostKeyChecking', 'no')
|
43
|
+
@ssh_config.set(host, 'PasswordAuthentication', 'no')
|
44
|
+
@ssh_config.set(host, 'IdentitiesOnly', 'yes')
|
45
|
+
@ssh_config.set(host, 'LogLevel', 'FATAL')
|
46
|
+
|
47
|
+
@ssh_config.save()
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_host(host)
|
51
|
+
@ssh_config.rm!(host)
|
52
|
+
end
|
53
|
+
|
54
|
+
def remove_hosts(hosts)
|
55
|
+
hosts.each do |host|
|
56
|
+
@ssh_config.rm(host)
|
57
|
+
end
|
58
|
+
@ssh_config.save()
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
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
|
+
require 'vagrant-bundlewrap/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-bundlewrap"
|
8
|
+
spec.version = Vagrant::BundleWrap::VERSION
|
9
|
+
spec.authors = ["Benjamin Kendinibilir"]
|
10
|
+
spec.email = ["bkendinibilir@seibert-media.net"]
|
11
|
+
spec.summary = "Vagrant BundleWrap provisioner."
|
12
|
+
spec.description = "Enables Vagrant to provision machines with BundleWrap. This Plugin is formerly known as 'vagrant-blockwart'."
|
13
|
+
spec.homepage = "https://github.com/bkendinibilir/vagrant-bundlewrap"
|
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.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_runtime_dependency "ssh-config", "~> 0.1.3"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-bundlewrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Kendinibilir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-22 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ssh-config
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.3
|
55
|
+
description: Enables Vagrant to provision machines with BundleWrap. This Plugin is
|
56
|
+
formerly known as 'vagrant-blockwart'.
|
57
|
+
email:
|
58
|
+
- bkendinibilir@seibert-media.net
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/vagrant-bundlewrap.rb
|
69
|
+
- lib/vagrant-bundlewrap/bwmanage.rb
|
70
|
+
- lib/vagrant-bundlewrap/config.rb
|
71
|
+
- lib/vagrant-bundlewrap/plugin.rb
|
72
|
+
- lib/vagrant-bundlewrap/provisioner.rb
|
73
|
+
- lib/vagrant-bundlewrap/sshconf.rb
|
74
|
+
- lib/vagrant-bundlewrap/version.rb
|
75
|
+
- vagrant-bundlewrap.gemspec
|
76
|
+
homepage: https://github.com/bkendinibilir/vagrant-bundlewrap
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.0.14
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Vagrant BundleWrap provisioner.
|
100
|
+
test_files: []
|