vagrant-yaml 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vagrant-yaml.rb +12 -3
- data/lib/vagrant-yaml/commands/yaml.rb +60 -0
- data/lib/vagrant-yaml/commands/yaml_init.rb +60 -0
- data/lib/vagrant-yaml/{init-yaml.rb → commands/yaml_update.rb} +7 -5
- data/lib/vagrant-yaml/errors.rb +13 -0
- data/lib/vagrant-yaml/version.rb +1 -1
- data/locales/en.yml +13 -50
- data/templates/Vagrantfile.erb +48 -0
- data/templates/default.yml.erb +32 -0
- metadata +7 -2
data/lib/vagrant-yaml.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
require 'vagrant'
|
2
|
-
|
3
|
-
require 'vagrant-yaml/
|
2
|
+
require 'vagrant-yaml/errors'
|
3
|
+
require 'vagrant-yaml/commands/yaml'
|
4
|
+
require 'vagrant-yaml/commands/yaml_init'
|
5
|
+
require 'vagrant-yaml/commands/yaml_update'
|
4
6
|
|
5
|
-
Vagrant.commands.register(:yaml) { VagrantYaml::Command }
|
7
|
+
Vagrant.commands.register(:yaml) { VagrantYaml::Command::Yaml }
|
8
|
+
|
9
|
+
module VagrantYaml
|
10
|
+
# The source root is the path to the root directory of the this gem.
|
11
|
+
def self.source_root
|
12
|
+
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
13
|
+
end
|
14
|
+
end
|
6
15
|
|
7
16
|
# Add our custom translations to the load path
|
8
17
|
I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant/util/template_renderer'
|
3
|
+
require 'vagrant/command/base'
|
4
|
+
|
5
|
+
module VagrantYaml
|
6
|
+
module Command
|
7
|
+
|
8
|
+
class Yaml < Vagrant::Command::Base
|
9
|
+
def initialize(argv, env)
|
10
|
+
super
|
11
|
+
|
12
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
13
|
+
|
14
|
+
@subcommands = Vagrant::Registry.new
|
15
|
+
@subcommands.register(:init) { VagrantYaml::Command::YamlInit }
|
16
|
+
@subcommands.register(:update) { VagrantYaml::Command::YamlUpdate }
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
if @main_args.include?("-h") || @main_args.include?("--help")
|
21
|
+
# Print the help for all the box commands.
|
22
|
+
return help
|
23
|
+
end
|
24
|
+
|
25
|
+
# If we reached this far then we must have a subcommand. If not,
|
26
|
+
# then we also just print the help and exit.
|
27
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
28
|
+
return help if !command_class || !@sub_command
|
29
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
30
|
+
|
31
|
+
# Initialize and execute the command class
|
32
|
+
command_class.new(@sub_args, @env).execute
|
33
|
+
end
|
34
|
+
|
35
|
+
# Prints the help out for this command
|
36
|
+
def help
|
37
|
+
opts = OptionParser.new do |opts|
|
38
|
+
opts.banner = "Usage: vagrant yaml <command> [<args>]"
|
39
|
+
opts.separator ""
|
40
|
+
opts.separator "Available subcommands:"
|
41
|
+
|
42
|
+
# Add the available subcommands as separators in order to print them
|
43
|
+
# out as well.
|
44
|
+
keys = []
|
45
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
46
|
+
|
47
|
+
keys.sort.each do |key|
|
48
|
+
opts.separator " #{key}"
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.separator ""
|
52
|
+
opts.separator "For help on any individual command run `vagrant yaml COMMAND -h`"
|
53
|
+
end
|
54
|
+
|
55
|
+
@env.ui.info(opts.help, :prefix => false)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant/util/template_renderer'
|
3
|
+
require 'vagrant/command/base'
|
4
|
+
|
5
|
+
module VagrantYaml
|
6
|
+
module Command
|
7
|
+
|
8
|
+
class YamlInit < Vagrant::Command::Base
|
9
|
+
def execute
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
opts = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: vagrant yaml init [box-name] [box-url]"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Parse the options
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return if !argv
|
19
|
+
|
20
|
+
# Create our Vagrantfile
|
21
|
+
save_path = @env.cwd.join("Vagrantfile")
|
22
|
+
raise Errors::VagrantfileExistsError if save_path.exist?
|
23
|
+
|
24
|
+
template_path = ::VagrantYaml.source_root.join("templates/Vagrantfile")
|
25
|
+
contents = Vagrant::Util::TemplateRenderer.render(template_path,
|
26
|
+
:box_name => argv[0] || "base",
|
27
|
+
:box_url => argv[1])
|
28
|
+
save_path.open("w+") do |f|
|
29
|
+
f.write(contents)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create our directories
|
33
|
+
Dir.mkdir('vms-available')
|
34
|
+
Dir.mkdir('vms-enabled')
|
35
|
+
|
36
|
+
# Create default.yml
|
37
|
+
save_path = @env.cwd.join("vms-available/default.yml")
|
38
|
+
raise Errors::VagrantfileExistsError if save_path.exist?
|
39
|
+
|
40
|
+
template_path = ::VagrantYaml.source_root.join("templates/default.yml")
|
41
|
+
contents = Vagrant::Util::TemplateRenderer.render(template_path,
|
42
|
+
:box_name => argv[0] || "base",
|
43
|
+
:box_url => argv[1])
|
44
|
+
save_path.open("w+") do |f|
|
45
|
+
f.write(contents)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Create symlink
|
49
|
+
File.symlink("../vms-available/default.yml", "vms-enabled/default.yml")
|
50
|
+
|
51
|
+
@env.ui.info(I18n.t("vagrant.plugins.yaml.commands.init.success"),
|
52
|
+
:prefix => false)
|
53
|
+
|
54
|
+
# Success, exit status 0
|
55
|
+
0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'optparse'
|
2
|
-
|
3
2
|
require 'vagrant/util/template_renderer'
|
3
|
+
require 'vagrant/command/base'
|
4
4
|
|
5
5
|
module VagrantYaml
|
6
6
|
module Command
|
7
|
-
|
7
|
+
|
8
|
+
class YamlUpdate < Vagrant::Command::Base
|
8
9
|
def execute
|
9
10
|
options = {}
|
10
11
|
|
11
12
|
opts = OptionParser.new do |opts|
|
12
|
-
opts.banner = "Usage: vagrant
|
13
|
+
opts.banner = "Usage: vagrant yaml update [box-name] [box-url]"
|
13
14
|
end
|
14
15
|
|
15
16
|
# Parse the options
|
@@ -17,7 +18,7 @@ module VagrantYaml
|
|
17
18
|
return if !argv
|
18
19
|
|
19
20
|
save_path = @env.cwd.join("Vagrantfile")
|
20
|
-
|
21
|
+
# raise Errors::VagrantfileExistsError if save_path.exist?
|
21
22
|
|
22
23
|
template_path = ::Vagrant.source_root.join("templates/commands/init/Vagrantfile")
|
23
24
|
contents = Vagrant::Util::TemplateRenderer.render(template_path,
|
@@ -29,7 +30,7 @@ module VagrantYaml
|
|
29
30
|
f.write(contents)
|
30
31
|
end
|
31
32
|
|
32
|
-
@env.ui.info(I18n.t("vagrant.commands.init.success"),
|
33
|
+
@env.ui.info(I18n.t("vagrant.plugins.yaml.commands.init.success"),
|
33
34
|
:prefix => false)
|
34
35
|
|
35
36
|
# Success, exit status 0
|
@@ -38,3 +39,4 @@ module VagrantYaml
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
42
|
+
|
data/lib/vagrant-yaml/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -1,55 +1,18 @@
|
|
1
1
|
en:
|
2
2
|
vagrant:
|
3
3
|
plugins:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
restart_loop_guard_activated: "Guest Additions will not load, even after reboot."
|
15
|
-
machine_loop_guard: "Could not execute %{command} from current state %{state}. To prevent running in circles, we'll stop."
|
16
|
-
guest_version_reports_differ: |-
|
17
|
-
Got different reports about installed GuestAdditions version:
|
18
|
-
Virtualbox on your host claims: %{driver}
|
19
|
-
VBoxService inside the vm claims: %{service}
|
20
|
-
Going on, assuming VBoxService is correct...
|
21
|
-
unknown: unknown
|
22
|
-
|
23
|
-
status:
|
24
|
-
clean: "No installation found."
|
25
|
-
unmatched: "GuestAdditions versions on your host (%{host_version}) and guest (%{guest_version}) do not match."
|
26
|
-
not_running: "GuestAdditions seems to be installed (%{guest_version}) correctly, but not running."
|
27
|
-
ok: "GuestAdditions %{guest_version} running --- OK."
|
4
|
+
yaml:
|
5
|
+
commands:
|
6
|
+
init:
|
7
|
+
success: |-
|
8
|
+
A `Vagrantfile` has been placed in this directory, a default Yaml VM config file
|
9
|
+
has been placed in /vms-available, and a symlink to it, placed in /vms-enabled.
|
10
|
+
Unlike a regular Vagrantfile, this one parses and applies the configuration in
|
11
|
+
the Yaml files it finds in /vms-enabled. You are now ready to `vagrant up` your
|
12
|
+
first virtual environment! Please read the comments in the default Yaml VM
|
13
|
+
config file to see how it works.
|
28
14
|
|
29
15
|
errors:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
in your Vagrantfile or the `--iso` command line option.
|
34
|
-
If you think this is a bug and vbguest could have guessed the iso_path,
|
35
|
-
please file an issue at: https://github.com/dotless-de/vagrant-vbguest/issues
|
36
|
-
|
37
|
-
downloading_disabled: |-
|
38
|
-
Could not locate a local Virtualbox Guest Additions iso file.
|
39
|
-
However, the no_remote option was set and thus I will not download it from
|
40
|
-
%{from}
|
41
|
-
Please configure a local path to the iso using `config.vbguest.iso_path`
|
42
|
-
in your Vagrantfile or the `--iso` command line option.
|
43
|
-
|
44
|
-
installer:
|
45
|
-
no_installer_for_platform: |-
|
46
|
-
Sorry, don't know how to %{method} Virtualbox Guest Additions on this platform. Stopping installation.
|
47
|
-
generic_linux_installer: |-
|
48
|
-
The guest's platform is currently not supported, will try generic Linux method...
|
49
|
-
do_not_inherit_match_method: |-
|
50
|
-
Installer classes must provide their own `match?` method.
|
51
|
-
|
52
|
-
download:
|
53
|
-
with: "Downloading VirtualBox Guest Additions ISO with %{class}..."
|
54
|
-
cleaning: "Cleaning up downloaded VirtualBox Guest Additions ISO..."
|
55
|
-
unknown_type: "Unknown or unsupported URI type given for VirtualBox Guest Additions ISO download."
|
16
|
+
vagrantfile_exists: |-
|
17
|
+
`Vagrantfile` already exists in this directory. Remove it before running `vagrant
|
18
|
+
yaml init`, or run `vagrant yaml update` to update to the latest version.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
# All paths are relative to the project root
|
7
|
+
current_dir = File.dirname(__FILE__)
|
8
|
+
|
9
|
+
# Scan our vms-enabled/ directory for YAML config files
|
10
|
+
if File.directory?("#{current_dir}/vms-enabled/")
|
11
|
+
Dir.chdir("#{current_dir}/vms-enabled/")
|
12
|
+
config_files = Dir.glob("*.yml")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Build up a list of the VMs we'll provision, and their config_files
|
16
|
+
vms = {}
|
17
|
+
config_files.each do |config_file|
|
18
|
+
vms.update({ config_file.sub('.yml', '') => config_file})
|
19
|
+
end
|
20
|
+
|
21
|
+
## For additional available options, see: http://vagrantup.com/v1/docs/vagrantfile.html
|
22
|
+
Vagrant::Config.run do |config|
|
23
|
+
|
24
|
+
# VM-specific configuration loaded from YAML config files
|
25
|
+
vms.each do |vm,config_file|
|
26
|
+
yml = YAML.load_file "#{current_dir}/vms-enabled/#{config_file}"
|
27
|
+
|
28
|
+
config.vm.define "#{vm}" do |vm_config|
|
29
|
+
vm_config.vm.box = yml['box']
|
30
|
+
vm_config.vm.box_url = yml['box_url']
|
31
|
+
|
32
|
+
|
33
|
+
vm_config.vm.host_name = yml['host_name']
|
34
|
+
vm_config.vm.network :hostonly, yml['ip_address']
|
35
|
+
|
36
|
+
# vm_config.vm.provision :puppet do |puppet|
|
37
|
+
# puppet.manifests_path = "manifests"
|
38
|
+
# puppet.manifest_file = "site.pp"
|
39
|
+
# puppet.module_path = "modules"
|
40
|
+
# # TODO: allow facts to be added dynamically from YAML files
|
41
|
+
# puppet.facter = { "fqdn" => $hostname }
|
42
|
+
# end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
host_name: vagrant.local
|
2
|
+
ip_address: '192.168.33.34'
|
3
|
+
box: "<%= box_name %>"
|
4
|
+
<% if box_url.nil? %># <% end %>box_url: "<%= box_url || "http://domain.com/path/to/above.box" %>"
|
5
|
+
|
6
|
+
# Many configs are not yet supported. For a full list see:
|
7
|
+
# http://docs.vagrantup.com/v1/docs/vagrantfile.html
|
8
|
+
#config.nfs.map_uid
|
9
|
+
#config.nfs.map_gid
|
10
|
+
#config.package.name
|
11
|
+
#config.ssh.username
|
12
|
+
#config.ssh.host
|
13
|
+
#config.ssh.port
|
14
|
+
#config.ssh.guest_port
|
15
|
+
#config.ssh.max_tries
|
16
|
+
#config.ssh.timeout
|
17
|
+
#config.ssh.private_key_path
|
18
|
+
#config.ssh.forward_agent
|
19
|
+
#config.ssh.forward_x11
|
20
|
+
#config.ssh.shell
|
21
|
+
#config.vagrant.dotfile_name
|
22
|
+
#config.vagrant.host
|
23
|
+
#config.vm.auto_port_range
|
24
|
+
#config.vm.base_mac
|
25
|
+
#config.vm.boot_mode
|
26
|
+
#config.vm.customize
|
27
|
+
#config.vm.define
|
28
|
+
#config.vm.forward_port
|
29
|
+
#config.vm.guest
|
30
|
+
#config.vm.network
|
31
|
+
#config.vm.provision
|
32
|
+
#config.vm.share_folder
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -24,10 +24,15 @@ files:
|
|
24
24
|
- LICENSE
|
25
25
|
- Readme.md
|
26
26
|
- lib/vagrant-yaml.rb
|
27
|
-
- lib/vagrant-yaml/
|
27
|
+
- lib/vagrant-yaml/commands/yaml.rb
|
28
|
+
- lib/vagrant-yaml/commands/yaml_init.rb
|
29
|
+
- lib/vagrant-yaml/commands/yaml_update.rb
|
30
|
+
- lib/vagrant-yaml/errors.rb
|
28
31
|
- lib/vagrant-yaml/version.rb
|
29
32
|
- lib/vagrant_init.rb
|
30
33
|
- locales/en.yml
|
34
|
+
- templates/Vagrantfile.erb
|
35
|
+
- templates/default.yml.erb
|
31
36
|
- vagrant-yaml.gemspec
|
32
37
|
homepage: https://github.com/ergonlogic/vagrant-yaml
|
33
38
|
licenses:
|