vagrant-dotvm 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d053d347689bd9c664cfadddc32887db8998b50
4
+ data.tar.gz: a0a43d35f531de72197855e00bf9234b75467866
5
+ SHA512:
6
+ metadata.gz: bfd4a6f6dc9c0d328901ae395291999f6a6c97db7862443ca33b0c10e6a75ca12dc76b0d4e1512bde619a3b9c03f5dcea031d273e64ffcfe0e67b09b506e4e3c
7
+ data.tar.gz: f2e8bf0a265a3fa3c52b383f4fa272c9585c669766b520d6a4d59ba11fa7b8591c8e2be592e037fb2e88547a8d83dd34f47869d9f76589d70d7eaa2a800c5329
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/bundle/
11
+ /vendor/cache/
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
5
+ end
6
+
7
+ group :plugins do
8
+ gemspec
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Krzysztof Magosa
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/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,44 @@
1
+ module VagrantPlugins
2
+ module Dotvm
3
+ class ConfigInjecter
4
+
5
+ def self.inject(config, vc)
6
+ config[:machines].each do |machine_cfg|
7
+ vc.vm.define machine_cfg[:nick] do |machine|
8
+ machine.vm.box = machine_cfg[:box]
9
+ machine.vm.hostname = machine_cfg[:name]
10
+
11
+ machine.vm.provider "virtualbox" do |vb|
12
+ vb.customize ['modifyvm', :id, '--memory', machine_cfg['memory'] ||= 1024]
13
+ vb.customize ['modifyvm', :id, '--cpus', machine_cfg['cpus'] ||= 1]
14
+ vb.customize ['modifyvm', :id, '--cpuexecutioncap', machine_cfg['cpucap'] ||= 100]
15
+ end
16
+
17
+ machine_cfg[:networks].each do |net|
18
+ if net[:net] == 'private_network'
19
+ machine.vm.network net[:net], type: net[:type] ||= 'static', ip: net[:ip], netmask: net[:mask]
20
+ end
21
+ end
22
+
23
+ machine_cfg[:provision].each do |provision|
24
+ machine.vm.provision provision[:type] do |p|
25
+ if provision[:type] == 'shell'
26
+ p.path = provision[:path]
27
+ p.privileged = provision[:privileged] ||= true
28
+ elsif provision[:type] == 'file'
29
+ p.source = provision[:source]
30
+ p.destination = provision[:destination]
31
+ elsif provision[:type] == 'puppet'
32
+ p.module_path = provision[:module_path]
33
+ p.manifest_file = provision[:manifest_file]
34
+ p.manifests_path = provision[:manifests_path]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ end # ConfigInjecter
43
+ end # Dotvm
44
+ end # VagrantPlugins
@@ -0,0 +1,66 @@
1
+ module VagrantPlugins
2
+ module Dotvm
3
+ class ConfigParser
4
+
5
+ def self.parse_machine(machine)
6
+ return {
7
+ :nick => machine['nick'],
8
+ :name => machine['name'],
9
+ :box => machine['box'],
10
+ :memory => machine['memory'],
11
+ :cpus => machine['cpus'],
12
+ :cpucap => machine['cpucap'],
13
+ :networks => [],
14
+ :provision => [],
15
+ }
16
+ end
17
+
18
+
19
+ def self.parse_net(net)
20
+ return {
21
+ :net => net['net'],
22
+ :type => net['type'],
23
+ :ip => net['ip'],
24
+ :mask => net['mask'],
25
+ }
26
+ end
27
+
28
+
29
+ def self.parse_provision(prv)
30
+ return {
31
+ :type => prv['type'],
32
+ :source => prv['source'],
33
+ :destination => prv['destination'],
34
+ :path => prv['path'],
35
+ :module_path => prv['module_path'],
36
+ :manifests_path => prv['manifests_path'],
37
+ :manifest_file => prv['manifest_file'],
38
+ }
39
+ end
40
+
41
+
42
+ def self.parse(yaml)
43
+ config = {
44
+ :machines => []
45
+ }
46
+
47
+ yaml['machines'].each do |machine|
48
+ item = parse_machine(machine)
49
+
50
+ machine['networks'] and machine['networks'].each do |net|
51
+ item[:networks] << self.parse_net(net)
52
+ end
53
+
54
+ machine['provision'] and machine['provision'].each do |prv|
55
+ item[:provision] << self.parse_provision(prv)
56
+ end
57
+
58
+ config[:machines] << item
59
+ end
60
+
61
+ return config
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ module VagrantPlugins
2
+ module Dotvm
3
+ class Dotvm
4
+
5
+ def initialize(path = nil)
6
+ if not path
7
+ path = Dir.pwd
8
+ end
9
+
10
+ @path = path
11
+ end
12
+
13
+
14
+ def get_configs()
15
+ configs = []
16
+
17
+ Dir[@path + "/projects/*/*.yaml"].each do |fname|
18
+ yaml = YAML::load(File.read(fname))
19
+ configs << ConfigParser.parse(yaml)
20
+ end
21
+
22
+ return configs
23
+ end
24
+
25
+
26
+ def inject(vc)
27
+ configs = self.get_configs()
28
+
29
+ configs.each do |config|
30
+ ConfigInjecter.inject(config, vc)
31
+ end
32
+ end
33
+
34
+ end # DotVm
35
+ end # Dotvm
36
+ end # VagrantPlugins
@@ -0,0 +1,10 @@
1
+ module VagrantPlugins
2
+ module Dotvm
3
+
4
+ class Plugin < Vagrant.plugin(2)
5
+ name 'Dotvm'
6
+ description 'Easy YAML based multi machine config.'
7
+ end # Plugin
8
+
9
+ end # Dotvm
10
+ end # VagrantPlugins
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Dotvm
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'vagrant'
2
+ require 'yaml'
3
+
4
+ require 'vagrant-dotvm/plugin'
5
+ require 'vagrant-dotvm/version'
6
+ require 'vagrant-dotvm/dotvm'
7
+ require 'vagrant-dotvm/configparser'
8
+ require 'vagrant-dotvm/configinjecter'
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-dotvm/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-dotvm"
8
+ spec.version = VagrantPlugins::Dotvm::VERSION
9
+ spec.authors = ["Krzysztof Magosa"]
10
+ spec.email = ["krzysztof@magosa.pl"]
11
+ spec.summary = "Easy YAML based multi machine config approach for Vagrant."
12
+ spec.homepage = "http://github.com/krzysztof-magosa/dotvm"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-dotvm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Magosa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-04 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - krzysztof@magosa.pl
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - Rakefile
52
+ - lib/vagrant-dotvm.rb
53
+ - lib/vagrant-dotvm/configinjecter.rb
54
+ - lib/vagrant-dotvm/configparser.rb
55
+ - lib/vagrant-dotvm/dotvm.rb
56
+ - lib/vagrant-dotvm/plugin.rb
57
+ - lib/vagrant-dotvm/version.rb
58
+ - vagrant-dotvm.gemspec
59
+ homepage: http://github.com/krzysztof-magosa/dotvm
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.14
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Easy YAML based multi machine config approach for Vagrant.
83
+ test_files: []