vagrant-dotvm 0.34.0 → 0.35.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +9 -0
- data/Gemfile +4 -2
- data/README.md +3 -22
- data/Rakefile +1 -2
- data/lib/vagrant-dotvm/config/abstractconfig.rb +9 -2
- data/lib/vagrant-dotvm/config/host.rb +1 -0
- data/lib/vagrant-dotvm/config/instance.rb +1 -1
- data/lib/vagrant-dotvm/config/invalidconfigerror.rb +1 -0
- data/lib/vagrant-dotvm/config/machine.rb +5 -4
- data/lib/vagrant-dotvm/config/network.rb +3 -2
- data/lib/vagrant-dotvm/config/option.rb +1 -0
- data/lib/vagrant-dotvm/config/optionssetter.rb +2 -2
- data/lib/vagrant-dotvm/config/project.rb +1 -1
- data/lib/vagrant-dotvm/config/route.rb +1 -0
- data/lib/vagrant-dotvm/dotvm.rb +17 -21
- data/lib/vagrant-dotvm/injector/abstractinjector.rb +7 -4
- data/lib/vagrant-dotvm/injector/authorizedkey.rb +7 -2
- data/lib/vagrant-dotvm/injector/host.rb +7 -2
- data/lib/vagrant-dotvm/injector/instance.rb +7 -2
- data/lib/vagrant-dotvm/injector/machine.rb +64 -32
- data/lib/vagrant-dotvm/injector/network.rb +7 -2
- data/lib/vagrant-dotvm/injector/project.rb +7 -2
- data/lib/vagrant-dotvm/injector/provision.rb +9 -5
- data/lib/vagrant-dotvm/injector/route.rb +7 -2
- data/lib/vagrant-dotvm/injector/sharedfolder.rb +13 -4
- data/lib/vagrant-dotvm/paths.rb +1 -0
- data/lib/vagrant-dotvm/plugin.rb +0 -2
- data/lib/vagrant-dotvm/replacer.rb +14 -12
- data/lib/vagrant-dotvm/version.rb +1 -1
- data/vagrant-dotvm.gemspec +9 -9
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dab3eb77f8227efb87c30af0591e3e7013bbaa1
|
4
|
+
data.tar.gz: 9cd913f4d0d329db63f9c903972e472676d23e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc0a27d27b0d5e01e875546b4151d0046e0419849271b143edc30953b36560f6ad0045dcdbadbe12857af84a762434631ba36b804d33e425c74ff05b906e1e6
|
7
|
+
data.tar.gz: a13b24e90c97ae5025752107696636a4e8f8a2a2b52f3030f9b6d348bb4f73780e087fec28c765a3eedbaab18b1fb0f9bbee9c045bcb4ae1f17d7aff12859b5c
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Contribution rules
|
2
|
+
|
3
|
+
* Follow [Community-driven Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide)
|
4
|
+
* Check style using [Rubocop](https://github.com/bbatsov/rubocop) before sending pull request
|
5
|
+
* Don't send multiple unrelated functionalities in one pull request
|
6
|
+
* Don't use micro optimisations which are hard to read
|
7
|
+
* Your code will be published under [MIT license](LICENSE.txt)
|
8
|
+
|
9
|
+
By sending pull request you confirm that you agree with above rules.
|
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'vagrant',
|
4
|
+
gem 'vagrant',
|
5
|
+
git: 'git://github.com/mitchellh/vagrant.git'
|
5
6
|
end
|
6
7
|
|
7
8
|
group :plugins do
|
8
9
|
gemspec
|
9
|
-
gem 'vagrant-group',
|
10
|
+
gem 'vagrant-group',
|
11
|
+
git: 'git://github.com/krzysztof-magosa/vagrant-group.git'
|
10
12
|
end
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# DotVm
|
2
2
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/vagrant-dotvm/vagrant-dotvm/badges/gpa.svg)](https://codeclimate.com/github/vagrant-dotvm/vagrant-dotvm)
|
4
|
-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/krzysztof-magosa/vagrant-dotvm/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/krzysztof-magosa/vagrant-dotvm/?branch=master)
|
5
4
|
[![Gem Version](https://badge.fury.io/rb/vagrant-dotvm.svg)](http://badge.fury.io/rb/vagrant-dotvm)
|
6
5
|
|
7
6
|
## What is that?
|
@@ -25,33 +24,15 @@ Then create Vagrantfile like that:
|
|
25
24
|
require 'vagrant-dotvm'
|
26
25
|
|
27
26
|
Vagrant.configure(2) do |config|
|
28
|
-
|
29
|
-
# directory as Vagrantfile.
|
30
|
-
config_path = File.dirname(File.expand_path(__FILE__)) + "/config"
|
31
|
-
dotvm = VagrantPlugins::Dotvm::Dotvm.new config_path
|
27
|
+
dotvm = VagrantPlugins::Dotvm::Dotvm.new __dir__
|
32
28
|
dotvm.inject(config)
|
33
29
|
end
|
34
30
|
```
|
35
31
|
|
36
32
|
Prepare directory for storing your projects:
|
37
33
|
```
|
38
|
-
$ mkdir
|
34
|
+
$ mkdir projects
|
39
35
|
```
|
40
36
|
|
41
|
-
## How to configure machine
|
42
|
-
You need to create folder named after your project in `config/projects`.
|
43
|
-
In this folder you can create as many YAML files as you want.
|
44
|
-
In each one you are able to define multiple machines.
|
45
|
-
|
46
|
-
Please refer to [example](/examples) to see possible options.
|
47
|
-
|
48
|
-
## Available variables
|
49
|
-
You can use variables inside of config values.
|
50
|
-
Environment variables are accessible by using env prefix, e.g. `%env.LOGNAME%`.
|
51
|
-
|
52
|
-
Predefined variables:
|
53
|
-
* `%project.host%` - points to project directory on host
|
54
|
-
* `%project.guest%` - points to project directory on guest
|
55
|
-
|
56
37
|
## More information
|
57
|
-
For more information please follow to [wiki](https://github.com/
|
38
|
+
For more information please follow to [wiki](https://github.com/vagrant-dotvm/vagrant-dotvm/wiki/Getting-started).
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -7,13 +7,20 @@ module VagrantPlugins
|
|
7
7
|
# @param data [Hash] Hash with data
|
8
8
|
def populate(data)
|
9
9
|
data.each do |key, value|
|
10
|
-
|
10
|
+
unless respond_to? "#{key}="
|
11
|
+
fail(
|
12
|
+
InvalidConfigError.new,
|
13
|
+
"Invalid configuration option: #{key}."
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
11
17
|
send("#{key}=", value)
|
12
18
|
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def ensure_type(value, type, name = '')
|
16
|
-
|
22
|
+
return true if value.is_a?(type) || value.is_a?(NilClass)
|
23
|
+
fail InvalidConfigError.new, "'#{name}' must be #{type.name}."
|
17
24
|
end
|
18
25
|
|
19
26
|
# Converts array of hashes into array of specialized objects.
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Config
|
4
|
+
# Stores machine configuration
|
4
5
|
class Machine < AbstractConfig
|
5
6
|
include OptionsSetter
|
6
7
|
|
7
8
|
OPTIONS_CATEGORIES = [
|
8
|
-
:virtualbox
|
9
|
+
:virtualbox
|
9
10
|
]
|
10
11
|
|
11
12
|
attr_reader :parent
|
@@ -53,7 +54,7 @@ module VagrantPlugins
|
|
53
54
|
|
54
55
|
def usable_port_range=(value)
|
55
56
|
m = value.scan(/^(\d+)\.\.(\d+)$/)
|
56
|
-
|
57
|
+
fail InvalidConfigError.new, 'Invalid usable_port_range, it must be in A..B format.' if m.length == 0
|
57
58
|
@usable_port_range = Range.new(m[0][0].to_i, m[0][1].to_i)
|
58
59
|
end
|
59
60
|
|
@@ -95,18 +96,18 @@ module VagrantPlugins
|
|
95
96
|
ensure_type shared_folders, Array, 'shared_folders'
|
96
97
|
@shared_folders = convert_array(shared_folders, SharedFolder.name)
|
97
98
|
|
99
|
+
# Mount DotVM project directory
|
98
100
|
settings = {
|
99
101
|
'host' => @parent.variables['host.project_dir'],
|
100
102
|
'guest' => @parent.variables['guest.project_dir'],
|
101
103
|
'disabled' => false,
|
102
104
|
'create' => false,
|
103
|
-
'type' => nil
|
105
|
+
'type' => nil
|
104
106
|
}
|
105
107
|
item = SharedFolder.new
|
106
108
|
item.populate settings
|
107
109
|
@shared_folders << item
|
108
110
|
end
|
109
|
-
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Config
|
4
|
+
# Stores network configuration
|
4
5
|
class Network < AbstractConfig
|
5
6
|
attr_reader :net
|
6
7
|
attr_accessor :type
|
@@ -17,7 +18,7 @@ module VagrantPlugins
|
|
17
18
|
attr_accessor :auto_config
|
18
19
|
|
19
20
|
def initialize
|
20
|
-
@net
|
21
|
+
@net = :private_network
|
21
22
|
end
|
22
23
|
|
23
24
|
def net=(value)
|
@@ -27,7 +28,7 @@ module VagrantPlugins
|
|
27
28
|
'public_network' => :public_network,
|
28
29
|
'public' => :public_network,
|
29
30
|
'forwarded_port' => :forwarded_port,
|
30
|
-
'port' => :forwarded_port
|
31
|
+
'port' => :forwarded_port
|
31
32
|
}
|
32
33
|
|
33
34
|
@net = nets[value]
|
@@ -5,14 +5,14 @@ module VagrantPlugins
|
|
5
5
|
def options=(options)
|
6
6
|
ensure_type options, Hash, 'options'
|
7
7
|
|
8
|
-
@options
|
8
|
+
@options = {}
|
9
9
|
self.class::OPTIONS_CATEGORIES.each do |cat|
|
10
10
|
@options[cat] = []
|
11
11
|
end
|
12
12
|
|
13
13
|
options.to_h.each do |key, confs|
|
14
14
|
key = key.to_sym
|
15
|
-
|
15
|
+
fail InvalidConfigError.new, "Invalid options category: #{key}." unless @options.key?(key)
|
16
16
|
ensure_type confs, Array, "options.#{key}"
|
17
17
|
|
18
18
|
confs.to_a.each do |conf|
|
data/lib/vagrant-dotvm/dotvm.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
class Dotvm
|
4
|
-
|
5
4
|
def initialize(path = nil)
|
6
|
-
|
5
|
+
fail 'path must be set.' until path
|
7
6
|
@path = path
|
8
7
|
end
|
9
8
|
|
9
|
+
def inject(vc)
|
10
|
+
init_instance
|
11
|
+
load_options
|
12
|
+
load_projects
|
13
|
+
Injector::Instance.inject @instance, vc
|
14
|
+
end
|
15
|
+
|
10
16
|
private
|
17
|
+
|
11
18
|
def parse_variables(path)
|
12
19
|
result = {}
|
13
20
|
|
14
21
|
Dir[path].each do |fname|
|
15
|
-
yaml = YAML
|
22
|
+
yaml = YAML.load(File.read(fname)) || {}
|
16
23
|
yaml.each do |name, value|
|
17
|
-
|
24
|
+
fail "Variable #{name} already exists." if result.key? name
|
18
25
|
result[name] = value
|
19
26
|
end
|
20
27
|
end
|
@@ -22,24 +29,21 @@ module VagrantPlugins
|
|
22
29
|
result
|
23
30
|
end
|
24
31
|
|
25
|
-
private
|
26
32
|
def init_instance
|
27
33
|
@instance = Config::Instance.new
|
28
34
|
@instance.variables.append_group 'env', ENV
|
29
35
|
@instance.variables.append_group 'global', (parse_variables "#{@path}/variables/*.yaml")
|
30
36
|
end
|
31
37
|
|
32
|
-
private
|
33
38
|
def load_options
|
34
39
|
Dir["#{@path}/options/*.yaml"].each do |file|
|
35
40
|
@instance.options = Replacer.new
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
.on(YAML.load(File.read(file)) || {})
|
42
|
+
.using(@instance.variables)
|
43
|
+
.result
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
|
-
private
|
43
47
|
def load_projects
|
44
48
|
Dir["#{@path}/projects/*"].each do |dir|
|
45
49
|
project = @instance.new_project
|
@@ -48,21 +52,21 @@ module VagrantPlugins
|
|
48
52
|
'host',
|
49
53
|
{
|
50
54
|
'project_dir' => dir,
|
51
|
-
'files_dir' => "#{dir}/files"
|
55
|
+
'files_dir' => "#{dir}/files"
|
52
56
|
}
|
53
57
|
)
|
54
58
|
project.variables.append_group(
|
55
59
|
'guest',
|
56
60
|
{
|
57
61
|
'project_dir' => DOTVM_PROJECT_PATH,
|
58
|
-
'files_dir' =>
|
62
|
+
'files_dir' => DOTVM_FILES_PATH
|
59
63
|
}
|
60
64
|
)
|
61
65
|
|
62
66
|
Dir["#{dir}/machines/*.yaml"].each do |file|
|
63
67
|
begin
|
64
68
|
yaml = Replacer.new
|
65
|
-
.on(YAML
|
69
|
+
.on(YAML.load(File.read(file)) || [])
|
66
70
|
.using(@instance.variables.merge(project.variables))
|
67
71
|
.result
|
68
72
|
|
@@ -77,14 +81,6 @@ module VagrantPlugins
|
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
80
|
-
public
|
81
|
-
def inject(vc)
|
82
|
-
init_instance
|
83
|
-
load_options
|
84
|
-
load_projects
|
85
|
-
Injector::Instance.inject @instance, vc
|
86
|
-
end
|
87
|
-
|
88
84
|
end # DotVm
|
89
85
|
end # Dotvm
|
90
86
|
end # VagrantPlugins
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
4
|
+
# Helper functions used by injectors
|
5
|
+
module AbstractInjector
|
6
|
+
module_function
|
7
|
+
|
5
8
|
# Extracts specified `options` from `source` and return them as hash.
|
6
9
|
#
|
7
10
|
# @param source [Object] Object to extract data from
|
8
11
|
# @param options [Array] List of options to be extraced
|
9
12
|
# @return [Hash] Extracted data
|
10
|
-
def
|
13
|
+
def generate_hash(source, options)
|
11
14
|
hash = {}
|
12
15
|
|
13
16
|
options.each do |opt|
|
@@ -15,7 +18,7 @@ module VagrantPlugins
|
|
15
18
|
hash[opt] = val unless val.nil?
|
16
19
|
end
|
17
20
|
|
18
|
-
|
21
|
+
hash
|
19
22
|
end
|
20
23
|
|
21
24
|
# Rewrite `options` from `source` to `target`.
|
@@ -23,7 +26,7 @@ module VagrantPlugins
|
|
23
26
|
# @param source [Object] Object to rewrite data from
|
24
27
|
# @param target [Object] Object to rewrite data to
|
25
28
|
# @param options [Array] List of options to be rewritten
|
26
|
-
def
|
29
|
+
def rewrite_options(source, target, options)
|
27
30
|
options.each do |opt|
|
28
31
|
val = source.send(opt)
|
29
32
|
target.send("#{opt}=", val) unless val.nil?
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
5
|
-
|
4
|
+
# Injects DotVm authorized key configuration into Vagrant
|
5
|
+
module AuthorizedKey
|
6
|
+
extend AbstractInjector
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def inject(key: nil, machine: nil)
|
6
11
|
if key.type == 'file'
|
7
12
|
pubkey = File.readlines(File.expand_path(key.path)).first.strip
|
8
13
|
elsif key.type == 'static'
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
5
|
-
|
4
|
+
# Injects DotVm host configuration into Vagrant
|
5
|
+
module Host
|
6
|
+
extend AbstractInjector
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def inject(host: nil, machine: nil)
|
6
11
|
machine.vm.provision 'shell', run: 'always' do |s|
|
7
12
|
s.path = "#{UTILS_PATH}/add_host.sh"
|
8
13
|
s.args = [host.ip, host.host]
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
5
|
-
|
4
|
+
# Injects DotVm instance configuration into Vagrant
|
5
|
+
module Instance
|
6
|
+
extend AbstractInjector
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def inject(instance, vc)
|
6
11
|
instance.options.to_h.each do |category, options|
|
7
12
|
options.to_a.each do |option|
|
8
13
|
vc.send(category).send("#{option.name}=", option.value)
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
4
|
+
# Injects DotVm machine configuration into Vagrant
|
5
|
+
module Machine
|
6
|
+
extend AbstractInjector
|
7
|
+
|
5
8
|
BOX_OPTIONS = [
|
6
9
|
:box,
|
7
10
|
:hostname,
|
@@ -20,35 +23,73 @@ module VagrantPlugins
|
|
20
23
|
:box_url,
|
21
24
|
:communicator,
|
22
25
|
:guest,
|
23
|
-
:usable_port_range
|
26
|
+
:usable_port_range
|
24
27
|
]
|
25
28
|
|
26
|
-
|
27
|
-
define_opts = {}
|
28
|
-
define_opts[:primary] = machine_cfg.primary unless machine_cfg.primary.nil?
|
29
|
-
define_opts[:autostart] = machine_cfg.autostart unless machine_cfg.autostart.nil?
|
29
|
+
module_function
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
def inject_options(machine_cfg, machine)
|
32
|
+
BOX_OPTIONS.each do |opt|
|
33
|
+
val = machine_cfg.send(opt)
|
34
|
+
machine.vm.send("#{opt}=", val) unless val.nil?
|
35
|
+
end
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def inject_vbox(machine_cfg, machine)
|
39
|
+
mapping = [
|
40
|
+
['--memory', :memory],
|
41
|
+
['--cpus', :cpus],
|
42
|
+
['--cpuexecutioncap', :cpucap],
|
43
|
+
['--natnet1', :natnet]
|
44
|
+
]
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
machine.vm.provider 'virtualbox' do |vb|
|
47
|
+
mapping.each do |item|
|
48
|
+
value = machine_cfg.send(item[1])
|
49
|
+
vb.customize ['modifyvm', :id, item[0], value] unless value.nil?
|
46
50
|
end
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
vf.vmx['numvcpus'] = machine_cfg.cpus unless machine_cfg.cpus.nil?
|
52
|
+
machine_cfg.options.to_h[:virtualbox].to_a.each do |option|
|
53
|
+
vb.customize ['modifyvm', :id, option.name, option.value]
|
51
54
|
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def inject_vmware(machine_cfg, machine)
|
59
|
+
mapping = [
|
60
|
+
['memsize', :memory],
|
61
|
+
['numvcpus', :cpus]
|
62
|
+
]
|
63
|
+
|
64
|
+
machine.vm.provider 'vmware_fusion' do |vf|
|
65
|
+
mapping.each do |item|
|
66
|
+
value = machine_cfg.send(item[1])
|
67
|
+
vf.vmx[item[1]] = value unless value.nil?
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def inject_groups(machine_cfg, vc)
|
73
|
+
return false unless Vagrant.has_plugin?('vagrant-group')
|
74
|
+
|
75
|
+
vc.group.groups = {} unless vc.group.groups.is_a?(Hash)
|
76
|
+
|
77
|
+
machine_cfg.groups.to_a.each do |group|
|
78
|
+
vc.group.groups[group] = [] unless vc.group.groups.key?(group)
|
79
|
+
vc.group.groups[group] << machine_cfg.nick
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def inject(machine_cfg: nil, vc: nil)
|
84
|
+
define_opts = {}
|
85
|
+
define_opts[:primary] = machine_cfg.primary unless machine_cfg.primary.nil?
|
86
|
+
define_opts[:autostart] = machine_cfg.autostart unless machine_cfg.autostart.nil?
|
87
|
+
|
88
|
+
vc.vm.define machine_cfg.nick, **define_opts do |machine|
|
89
|
+
inject_options machine_cfg, machine
|
90
|
+
inject_vbox machine_cfg, machine
|
91
|
+
inject_vmware machine_cfg, vc
|
92
|
+
inject_groups machine_cfg, vc
|
52
93
|
|
53
94
|
machine_cfg.networks.to_a.each do |net|
|
54
95
|
Network.inject net: net,
|
@@ -62,7 +103,7 @@ module VagrantPlugins
|
|
62
103
|
|
63
104
|
machine_cfg.hosts.to_a.each do |host|
|
64
105
|
Host.inject host: host,
|
65
|
-
|
106
|
+
machine: machine
|
66
107
|
end
|
67
108
|
|
68
109
|
machine_cfg.provision.to_a.each do |provision|
|
@@ -79,15 +120,6 @@ module VagrantPlugins
|
|
79
120
|
AuthorizedKey.inject key: key,
|
80
121
|
machine: machine
|
81
122
|
end
|
82
|
-
|
83
|
-
if Vagrant.has_plugin?('vagrant-group')
|
84
|
-
vc.group.groups = {} unless vc.group.groups.kind_of?(Hash)
|
85
|
-
|
86
|
-
machine_cfg.groups.to_a.each do |group|
|
87
|
-
vc.group.groups[group] = [] unless vc.group.groups.has_key?(group)
|
88
|
-
vc.group.groups[group] << machine_cfg.nick
|
89
|
-
end
|
90
|
-
end
|
91
123
|
end
|
92
124
|
end
|
93
125
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
4
|
+
# Injects DotVm network configuration into Vagrant
|
5
|
+
module Network
|
6
|
+
extend AbstractInjector
|
7
|
+
|
5
8
|
OPTIONS = [
|
6
9
|
:type,
|
7
10
|
:ip,
|
@@ -17,7 +20,9 @@ module VagrantPlugins
|
|
17
20
|
:auto_config,
|
18
21
|
]
|
19
22
|
|
20
|
-
|
23
|
+
module_function
|
24
|
+
|
25
|
+
def inject(net: nil, machine: nil)
|
21
26
|
machine.vm.network net.net, **generate_hash(net, OPTIONS)
|
22
27
|
end
|
23
28
|
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
5
|
-
|
4
|
+
# Injects DotVm project configuration into Vagrant
|
5
|
+
module Project
|
6
|
+
extend AbstractInjector
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def inject(project, vc)
|
6
11
|
project.machines.to_a.each do |machine_cfg|
|
7
12
|
Machine.inject machine_cfg: machine_cfg, vc: vc
|
8
13
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
4
|
+
# Injects DotVm provision configuration into Vagrant
|
5
|
+
module Provision
|
6
|
+
extend AbstractInjector
|
7
|
+
|
5
8
|
OPTIONS = [
|
6
9
|
:path,
|
7
10
|
:inline,
|
@@ -119,7 +122,7 @@ module VagrantPlugins
|
|
119
122
|
:delete_node,
|
120
123
|
:delete_client,
|
121
124
|
:recipe,
|
122
|
-
:images
|
125
|
+
:images
|
123
126
|
]
|
124
127
|
|
125
128
|
RUNS_OPTIONS = [
|
@@ -128,11 +131,12 @@ module VagrantPlugins
|
|
128
131
|
:args,
|
129
132
|
:auto_assign_name,
|
130
133
|
:daemonize,
|
131
|
-
:restart
|
134
|
+
:restart
|
132
135
|
]
|
133
136
|
|
134
|
-
|
135
|
-
|
137
|
+
module_function
|
138
|
+
|
139
|
+
def inject(provision_cfg: nil, machine: nil)
|
136
140
|
machine.vm.provision provision_cfg.type, run: provision_cfg.run do |p|
|
137
141
|
rewrite_options(provision_cfg, p, OPTIONS)
|
138
142
|
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
5
|
-
|
4
|
+
# Injects DotVm route configuration into Vagrant
|
5
|
+
module Route
|
6
|
+
extend AbstractInjector
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def inject(route: nil, machine: nil)
|
6
11
|
machine.vm.provision 'shell', run: 'always' do |s|
|
7
12
|
s.path = "#{UTILS_PATH}/setup_route.sh"
|
8
13
|
s.args = [route.destination, route.gateway]
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Dotvm
|
3
3
|
module Injector
|
4
|
-
|
4
|
+
# Injects DotVm shared folder configuration into Vagrant
|
5
|
+
module SharedFolder
|
6
|
+
extend AbstractInjector
|
7
|
+
|
5
8
|
OPTIONS = [
|
6
9
|
:disabled,
|
7
10
|
:create,
|
@@ -20,11 +23,17 @@ module VagrantPlugins
|
|
20
23
|
:rsync__verbose,
|
21
24
|
:smb_host,
|
22
25
|
:smb_password,
|
23
|
-
:smb_username
|
26
|
+
:smb_username
|
24
27
|
]
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
module_function
|
30
|
+
|
31
|
+
def inject(folder: nil, machine: nil)
|
32
|
+
machine.vm.synced_folder(
|
33
|
+
folder.host,
|
34
|
+
folder.guest,
|
35
|
+
**generate_hash(folder, OPTIONS)
|
36
|
+
)
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
data/lib/vagrant-dotvm/paths.rb
CHANGED
data/lib/vagrant-dotvm/plugin.rb
CHANGED
@@ -27,34 +27,36 @@ module VagrantPlugins
|
|
27
27
|
return target if @replaced == 0
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
fail 'Too deep variables relations, possible recurrence.'
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
+
|
34
35
|
def process_string(target)
|
35
36
|
@vars.each do |k, v|
|
36
37
|
pattern = "%#{k}%"
|
38
|
+
next unless target.include? pattern
|
37
39
|
|
38
|
-
|
39
|
-
@replaced += 1
|
40
|
+
@replaced += 1
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
break unless v.is_a? String # value is no longer string, so replace cannot be performed
|
44
|
-
else
|
45
|
-
unless v.respond_to? :to_s
|
46
|
-
raise 'Non-string values cannot be joined together.'
|
47
|
-
end
|
42
|
+
if target == pattern
|
43
|
+
target = v
|
48
44
|
|
49
|
-
|
45
|
+
# value is no longer string, so
|
46
|
+
# replace cannot be performed
|
47
|
+
break unless v.is_a? String
|
48
|
+
else
|
49
|
+
unless v.respond_to? :to_s
|
50
|
+
fail 'Non-string values cannot be joined together.'
|
50
51
|
end
|
52
|
+
|
53
|
+
target = target.gsub pattern, v.to_s
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
target
|
55
58
|
end
|
56
59
|
|
57
|
-
private
|
58
60
|
def _replace_vars(target)
|
59
61
|
case target
|
60
62
|
when Hash
|
data/vagrant-dotvm.gemspec
CHANGED
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'vagrant-dotvm/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'vagrant-dotvm'
|
8
8
|
spec.version = VagrantPlugins::Dotvm::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
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/vagrant-dotvm/vagrant-dotvm'
|
13
|
+
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-dotvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.35.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Magosa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
49
|
- CHANGELOG.md
|
50
|
+
- CONTRIBUTING.md
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
@@ -102,12 +103,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
103
|
version: '0'
|
103
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
105
|
requirements:
|
105
|
-
- - '
|
106
|
+
- - '>'
|
106
107
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
108
|
+
version: 1.3.1
|
108
109
|
requirements: []
|
109
110
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.0.14
|
111
|
+
rubygems_version: 2.0.14.1
|
111
112
|
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: Easy YAML based multi machine config approach for Vagrant.
|