vagrant_bootstrap 0.1.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.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +47 -0
- data/Rakefile +2 -0
- data/bin/vgbs +5 -0
- data/lib/vagrant_bootstrap/bootstrap.rb +34 -0
- data/lib/vagrant_bootstrap/cli.rb +39 -0
- data/lib/vagrant_bootstrap/version.rb +3 -0
- data/lib/vagrant_bootstrap.rb +11 -0
- data/templates/Vagrantfile.erb +59 -0
- data/vagrant_bootstrap.gemspec +18 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Justin Force
|
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,47 @@
|
|
1
|
+
vagrant\_bootstrap
|
2
|
+
=================
|
3
|
+
|
4
|
+
Easily create directories with Vagrantfiles to ease creation and collaboration
|
5
|
+
of namespaced Vagrant virtual machines and avoid namespace collisions.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'vagrant_bootstrap'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install vagrant_bootstrap
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
$ vgbs [name] [-b adapter]
|
24
|
+
|
25
|
+
Create a Vagrantfile in a directory. Optionally, supply a name and/or bridge
|
26
|
+
adapter. If no name or bridge adapter is specified, sane defaults are used.
|
27
|
+
|
28
|
+
### Defaults
|
29
|
+
|
30
|
+
#### Name
|
31
|
+
|
32
|
+
The default name is `vagrant-yourname` where "yourname" is determined by a
|
33
|
+
`whoami`. If you specify a name, it will be appended, e.g. a name argument of
|
34
|
+
"potato" will produce `vagrant-yourname-potato`.
|
35
|
+
|
36
|
+
#### Bridge Adapter
|
37
|
+
|
38
|
+
The default bridge adapter is the commonly used `br0`. No smarts here. It's
|
39
|
+
just hard-coded.
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/vgbs
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module VagrantBootstrap
|
6
|
+
class Bootstrap
|
7
|
+
def initialize(opts)
|
8
|
+
dir = opts.name
|
9
|
+
begin
|
10
|
+
puts "Making directory #{dir}..." if opts.verbose
|
11
|
+
FileUtils.mkdir_p dir
|
12
|
+
rescue
|
13
|
+
STDERR.puts "FATAL: #{dir} already exists!"
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
render "Vagrantfile.erb", "#{dir}/Vagrantfile", opts
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def render(template_file, target, opts)
|
22
|
+
puts "Rendering #{target} from #{template_file}..." if opts.verbose
|
23
|
+
file = "#{template_path}/#{template_file}"
|
24
|
+
template = open(file, 'r') {|f| f.read}
|
25
|
+
render = ERB.new(template).result(opts.instance_eval {binding})
|
26
|
+
open(target, 'w') {|f| f.write render}
|
27
|
+
puts "Done rendering #{target}." if opts.verbose
|
28
|
+
end
|
29
|
+
|
30
|
+
def template_path
|
31
|
+
@template_path ||= File.expand_path "#{File.dirname __FILE__}/../../templates/"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'vagrant_bootstrap'
|
2
|
+
require 'vagrant_bootstrap/bootstrap'
|
3
|
+
require 'trollop'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module VagrantBootstrap
|
7
|
+
class CLI
|
8
|
+
|
9
|
+
DEFAULT_BRIDGE = 'br0'
|
10
|
+
BANNER = <<-EOS
|
11
|
+
Easily generate a Vagrantfile in a namespaced directory
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
vgbs [name] [-b adapter]
|
15
|
+
|
16
|
+
If specified, the name will be used to calculate the directory name and
|
17
|
+
hostname of the VM, e.g. 'vgbs taco' will yield a directory and hostname of
|
18
|
+
'%{name}')
|
19
|
+
EOS
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def start
|
23
|
+
trollopts = Trollop::options do
|
24
|
+
version VagrantBootstrap::VERSION
|
25
|
+
banner BANNER % {:name => VagrantBootstrap.vm_name('taco')}
|
26
|
+
opt :bridge, 'The bridge to attach the VM to', :default => DEFAULT_BRIDGE
|
27
|
+
opt :quiet, "Don't output anything unless there's a problem", :default => false
|
28
|
+
opt :verbose, "More verbose output", :default => false
|
29
|
+
end
|
30
|
+
opts = OpenStruct.new(trollopts)
|
31
|
+
|
32
|
+
# normalize name
|
33
|
+
opts.name = VagrantBootstrap.vm_name(ARGV[0])
|
34
|
+
puts "Your vagrant is called #{opts.name}" unless opts.quiet
|
35
|
+
VagrantBootstrap::Bootstrap.new opts
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant::Config.run do |config|
|
5
|
+
|
6
|
+
config.vm.define "<%= name %>" do |config|
|
7
|
+
|
8
|
+
# Every Vagrant virtual environment requires a box to build off of.
|
9
|
+
config.vm.box = "maverick64"
|
10
|
+
|
11
|
+
# The url from where the 'config.vm.box' box will be fetched if it
|
12
|
+
# doesn't already exist on the user's system.
|
13
|
+
# config.vm.box_url = "http://domain.com/path/to/above.box"
|
14
|
+
|
15
|
+
# Assign this VM to a bridged network, allowing you to connect directly to a
|
16
|
+
# network using the host's network device. This makes the VM appear as another
|
17
|
+
# physical device on your network.
|
18
|
+
# config.vm.network :bridged
|
19
|
+
config.vm.network :bridged, :bridge => "<%= bridge %>"
|
20
|
+
|
21
|
+
config.vm.host_name = "<%= name %>"
|
22
|
+
|
23
|
+
# Forward a port from the guest to the host, which allows for outside
|
24
|
+
# computers to access the VM, whereas host only networking does not.
|
25
|
+
# config.vm.forward_port 80, 8080
|
26
|
+
|
27
|
+
# Share an additional folder to the guest VM. The first argument is
|
28
|
+
# an identifier, the second is the path on the guest to mount the
|
29
|
+
# folder, and the third is the path on the host to the actual folder.
|
30
|
+
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
|
31
|
+
|
32
|
+
# Enable provisioning with chef server, specifying the chef server URL,
|
33
|
+
# and the path to the validation key (relative to this Vagrantfile).
|
34
|
+
#
|
35
|
+
# The Opscode Platform uses HTTPS. Substitute your organization for
|
36
|
+
# ORGNAME in the URL and validation key.
|
37
|
+
#
|
38
|
+
# If you have your own Chef Server, use the appropriate URL, which may be
|
39
|
+
# HTTP instead of HTTPS depending on your configuration. Also change the
|
40
|
+
# validation key to validation.pem.
|
41
|
+
#
|
42
|
+
# config.vm.provision :chef_client do |chef|
|
43
|
+
# chef.chef_server_url = "https://cfg.rs.receipt.com:4000"
|
44
|
+
# chef.validation_key_path = "~/chef/validation.pem"
|
45
|
+
# chef.validation_client_name = "chef-validator"
|
46
|
+
# chef.environment = "development"
|
47
|
+
# chef.run_list = []
|
48
|
+
# end
|
49
|
+
|
50
|
+
#
|
51
|
+
# If you're using the Opscode platform, your validator client is
|
52
|
+
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
53
|
+
#
|
54
|
+
# IF you have your own Chef Server, the default validation client name is
|
55
|
+
# chef-validator, unless you changed the configuration.
|
56
|
+
#
|
57
|
+
# chef.validation_client_name = "ORGNAME-validator"
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../lib/vagrant_bootstrap/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Justin Force"]
|
5
|
+
gem.email = ["justin.force@gmail.com"]
|
6
|
+
gem.description = %q{Easily generate a Vagrantfile in a namespaced directory}
|
7
|
+
gem.summary = %q{You get a binary that you run to build a Vagrant file from a template then place it in a directory, ready to use.}
|
8
|
+
gem.homepage = "https://github.com/SmartReceipt/vagrant_bootstrap"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "vagrant_bootstrap"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = VagrantBootstrap::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency 'trollop'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant_bootstrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Justin Force
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: trollop
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Easily generate a Vagrantfile in a namespaced directory
|
31
|
+
email:
|
32
|
+
- justin.force@gmail.com
|
33
|
+
executables:
|
34
|
+
- vgbs
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/vgbs
|
44
|
+
- lib/vagrant_bootstrap.rb
|
45
|
+
- lib/vagrant_bootstrap/bootstrap.rb
|
46
|
+
- lib/vagrant_bootstrap/cli.rb
|
47
|
+
- lib/vagrant_bootstrap/version.rb
|
48
|
+
- templates/Vagrantfile.erb
|
49
|
+
- vagrant_bootstrap.gemspec
|
50
|
+
homepage: https://github.com/SmartReceipt/vagrant_bootstrap
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.24
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: You get a binary that you run to build a Vagrant file from a template then
|
74
|
+
place it in a directory, ready to use.
|
75
|
+
test_files: []
|