vagrant-yaml 0.0.3 → 0.0.4

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/Readme.md CHANGED
@@ -0,0 +1,92 @@
1
+ Vagrant-Yaml
2
+ ============
3
+
4
+ Installation
5
+ ------------
6
+
7
+ To install this gem, use the Vagrant 'gem' command:
8
+
9
+ ```
10
+ vagrant gem install vagrant-yaml
11
+ ```
12
+
13
+ This will keep it isolated from system-wide and other gems.
14
+
15
+
16
+ Usage
17
+ -----
18
+
19
+ To initialize a new project:
20
+
21
+ ```
22
+ vagrant yaml init [box-name] [box-url]
23
+ ```
24
+
25
+ To update an existing project with the latest Vagrantfile that Vagrant-Yaml
26
+ provides:
27
+
28
+ ```
29
+ vagrant yaml update
30
+ ```
31
+
32
+
33
+ Vagrantfile
34
+ -----------
35
+
36
+ Vagrant-Yaml provides a custom Vagrantfile. This Vagrantfile parses the Yaml
37
+ config files in the 'vms-enabled' directory, and applies any settings found
38
+ there. The Vagrant name for the VM is the name of the file (without the '.yaml'
39
+ extension, obviously). Multi-VM environments are supported by adding additional
40
+ Yaml config files.
41
+
42
+ As with a standard Vagrantfile, the one this gem provides can be altered to
43
+ suit the needs of your project. However, be aware that running the 'vagrant
44
+ yaml update' command will overwrite any changes you make. Of course, this
45
+ should not be a problem, since you are keeping your project directory under
46
+ some form of version control, right?
47
+
48
+
49
+ Config files
50
+ ------------
51
+
52
+ All Vagrant VM configuration can be done from Yaml config files. Only config
53
+ files in the 'vms-enabled' directory are interpreted. You can copy from, or
54
+ symlink to, files in the 'vms-available' directory. This allows you to have a
55
+ library of config files that could, for example, be updated by an external
56
+ application.
57
+
58
+
59
+ Yaml
60
+ ----
61
+
62
+ To see what you can do with Yaml, check out this handy reference card:
63
+ http://www.yaml.org/refcard.html. To see how Yaml is interpreted in Ruby, see
64
+ this guide: http://yaml.org/YAML_for_ruby.html. For further details, refer to
65
+ the full Yaml specification: http://www.yaml.org/spec/1.2/spec.html
66
+
67
+
68
+ Vagrant Options
69
+ ---------------
70
+
71
+ For all available Vagrant options, see the docs on Vagrantfile settings:
72
+ http://vagrantup.com/v1/docs/vagrantfile.html. While we have provided some
73
+ example below, it is far from exhaustive. If you cannot figure out how to apply
74
+ a particular setting, please file a support request at:
75
+ https://github.com/ergonlogic/vagrant-yaml.
76
+
77
+
78
+ Free Software
79
+ -------------
80
+
81
+ This gem is published under the GNU GPLv3 (General Public License, Version 3),
82
+ and as such is, and will always remain, free software. Engagement in the
83
+ development process by users and other developers is strongly encouraged. So,
84
+ please feel free to post to the project wiki, and submit feature and pull
85
+ requests.
86
+
87
+
88
+ CREDITS
89
+ -------
90
+
91
+ Developed and maintained by Christopher Gervais <http://ergonlogic.com/>
92
+
@@ -34,10 +34,10 @@ module VagrantYaml
34
34
  Dir.mkdir('vms-enabled')
35
35
 
36
36
  # Create default.yml
37
- save_path = @env.cwd.join("vms-available/default.yml")
37
+ save_path = @env.cwd.join("vms-available/default.yaml")
38
38
  raise Errors::VagrantfileExistsError if save_path.exist?
39
39
 
40
- template_path = ::VagrantYaml.source_root.join("templates/default.yml")
40
+ template_path = ::VagrantYaml.source_root.join("templates/default.yaml")
41
41
  contents = Vagrant::Util::TemplateRenderer.render(template_path,
42
42
  :box_name => argv[0] || "base",
43
43
  :box_url => argv[1])
@@ -46,7 +46,7 @@ module VagrantYaml
46
46
  end
47
47
 
48
48
  # Create symlink
49
- File.symlink("../vms-available/default.yml", "vms-enabled/default.yml")
49
+ File.symlink("../vms-available/default.yaml", "vms-enabled/default.yaml")
50
50
 
51
51
  @env.ui.info(I18n.t("vagrant.plugins.yaml.commands.init.success"),
52
52
  :prefix => false)
@@ -1,3 +1,3 @@
1
1
  module VagrantYaml
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -9,38 +9,38 @@ current_dir = File.dirname(__FILE__)
9
9
  # Scan our vms-enabled/ directory for YAML config files
10
10
  if File.directory?("#{current_dir}/vms-enabled/")
11
11
  Dir.chdir("#{current_dir}/vms-enabled/")
12
- config_files = Dir.glob("*.yml")
12
+ config_files = Dir.glob("*.yaml")
13
13
  end
14
14
 
15
15
  # Build up a list of the VMs we'll provision, and their config_files
16
16
  vms = {}
17
17
  config_files.each do |config_file|
18
- vms.update({ config_file.sub('.yml', '') => config_file})
18
+ vms.update({ config_file.sub('.yaml', '') => config_file})
19
19
  end
20
20
 
21
- ## For additional available options, see: http://vagrantup.com/v1/docs/vagrantfile.html
22
21
  Vagrant::Config.run do |config|
23
-
24
22
  # VM-specific configuration loaded from YAML config files
25
23
  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
24
 
25
+ yml = YAML.load_file "#{current_dir}/vms-enabled/#{config_file}"
32
26
 
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
27
+ def apply_settings(vm,yml)
28
+ yml.each do |key0,value0|
29
+ if !value0.is_a?(Hash) # If it's a setting,
30
+ vm.send("#{key0}=".to_sym, value0) # we set it directly.
31
+ else # Otherwise,
32
+ method_object = vm.method("#{key0}".to_sym) # we're invoking a method
33
+ value0.each do |key1,value1| # and each setting
34
+ method_object.call("#{key1}".to_sym, value1) # needs to be passed to the method.
35
+ end
36
+ end
37
+ end
38
+ end
43
39
 
40
+ config.vm.define "#{vm}" do |vm_config|
41
+ apply_settings(vm_config.vm, yml)
42
+ # We may need some project-wide config file to handle things like:
43
+ #vm_config.vbguest.auto_update = false
44
44
  end
45
45
 
46
46
  end
@@ -0,0 +1,33 @@
1
+ # All Vagrant VM configuration can be done from Yaml config files such as this
2
+ # one. Only config files in the 'vms-enabled' directory are interpreted. You
3
+ # can copy from, or symlink to, files in the 'vms-available' directory. This
4
+ # allows you to have a library of config files that could, for example, be
5
+ # updated by an external application.
6
+
7
+ # To see what you can do with Yaml can do, check out this handy reference card:
8
+ # http://www.yaml.org/refcard.html. To see how Yaml is interpreted in Ruby, see
9
+ # this guide: http://yaml.org/YAML_for_ruby.html. For further details, refer to
10
+ # the full Yaml specification: http://www.yaml.org/spec/1.2/spec.html
11
+
12
+ # For all available Vagrant options, see the docs on Vagrantfile settings:
13
+ # http://vagrantup.com/v1/docs/vagrantfile.html. While we've provided some
14
+ # example below, it's far from exhaustive. If you can't figure out how to apply
15
+ # a particular setting, please file a support request at:
16
+ # https://github.com/ergonlogic/vagrant-yaml. Also, feel free to post to the
17
+ # project's wiki, or submit pull requests.
18
+
19
+ box: "<%= box_name %>"
20
+ <% if box_url.nil? %># <% end %>box_url: "<%= box_url || "http://domain.com/path/to/above.box" %>"
21
+ # host_name: &id001 vagrant.local
22
+ # network:
23
+ # hostonly: '192.168.33.34'
24
+ # provision:
25
+ # puppet:
26
+ # module_path: 'modules'
27
+ # manifests_path: 'manifests'
28
+ # manifest_file: site.pp
29
+ # options:
30
+ # - --verbose
31
+ # - --debug
32
+ # facter:
33
+ # fqdn: *id001
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A Vagrant plugin that provides a Vagrantfile that looks in YAML files
15
15
  for project and VM settings
@@ -32,7 +32,7 @@ files:
32
32
  - lib/vagrant_init.rb
33
33
  - locales/en.yml
34
34
  - templates/Vagrantfile.erb
35
- - templates/default.yml.erb
35
+ - templates/default.yaml.erb
36
36
  - vagrant-yaml.gemspec
37
37
  homepage: https://github.com/ergonlogic/vagrant-yaml
38
38
  licenses:
@@ -1,32 +0,0 @@
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