vagrant-startcloud 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -443
- data/README.md +109 -112
- data/lib/vagrant-startcloud/action/configure_disks.rb +78 -0
- data/lib/vagrant-startcloud/action/configure_networks.rb +51 -45
- data/lib/vagrant-startcloud/action/configure_providers.rb +47 -51
- data/lib/vagrant-startcloud/action/configure_shared_folders.rb +57 -40
- data/lib/vagrant-startcloud/action/is_created.rb +2 -14
- data/lib/vagrant-startcloud/action/is_virtualbox.rb +3 -14
- data/lib/vagrant-startcloud/action.rb +94 -50
- data/lib/vagrant-startcloud/config.rb +83 -19
- data/lib/vagrant-startcloud/plugin.rb +30 -15
- data/lib/vagrant-startcloud/version.rb +1 -1
- data/lib/vagrant-startcloud.rb +53 -1
- metadata +2 -1
@@ -4,20 +4,19 @@ module VagrantPlugins
|
|
4
4
|
module StartCloud
|
5
5
|
module Action
|
6
6
|
class ConfigureSharedFolders
|
7
|
-
def initialize(app,
|
7
|
+
def initialize(app, env)
|
8
8
|
@app = app
|
9
|
+
@env = env
|
10
|
+
@machine = env[:machine]
|
9
11
|
end
|
10
12
|
|
11
13
|
def call(env)
|
12
|
-
|
13
|
-
|
14
|
+
config = @machine.config.startcloud
|
15
|
+
folders = config.folders
|
14
16
|
|
15
|
-
if
|
16
|
-
|
17
|
-
|
18
|
-
config.folders.each do |folder|
|
19
|
-
configure_folder(machine, folder)
|
20
|
-
end
|
17
|
+
if folders && !folders.empty?
|
18
|
+
@machine.ui.info I18n.t('vagrant_startcloud.configuring.folders')
|
19
|
+
configure_folders(folders)
|
21
20
|
end
|
22
21
|
|
23
22
|
@app.call(env)
|
@@ -25,45 +24,63 @@ module VagrantPlugins
|
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
|
-
def
|
29
|
-
|
27
|
+
def configure_folders(folders)
|
28
|
+
folders.each do |folder|
|
29
|
+
next if folder['disabled']
|
30
|
+
|
31
|
+
options = build_folder_options(folder)
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
begin
|
34
|
+
@machine.config.vm.synced_folder(
|
35
|
+
folder['map'],
|
36
|
+
folder['to'],
|
37
|
+
**options
|
38
|
+
)
|
39
|
+
rescue StandardError => e
|
40
|
+
@machine.ui.error I18n.t('vagrant_startcloud.errors.folder_error',
|
41
|
+
error: e.message)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def build_folder_options(folder)
|
47
|
+
options = {
|
34
48
|
type: folder['type'],
|
35
|
-
owner: folder['owner']
|
36
|
-
group: folder['group']
|
37
|
-
mount_options:
|
38
|
-
automount:
|
39
|
-
|
40
|
-
rsync__args: folder['args'] || ['--verbose', '--archive', '-z', '--copy-links'],
|
41
|
-
rsync__chown: folder['chown'] || false,
|
42
|
-
create: folder['create'] || false,
|
43
|
-
rsync__rsync_ownership: folder['rsync_ownership'] || true,
|
44
|
-
disabled: folder['disabled'] || false
|
45
|
-
)
|
49
|
+
owner: folder['owner'],
|
50
|
+
group: folder['group'],
|
51
|
+
mount_options: get_mount_options(folder),
|
52
|
+
automount: true
|
53
|
+
}
|
46
54
|
|
47
|
-
#
|
48
|
-
|
55
|
+
# Add type-specific options
|
56
|
+
case folder['type']
|
57
|
+
when 'rsync'
|
58
|
+
options.merge!(
|
59
|
+
rsync__args: folder['args'] || ['--verbose', '--archive', '-z', '--copy-links'],
|
60
|
+
rsync__chown: folder['chown'] || false,
|
61
|
+
rsync__rsync_ownership: folder['rsync_ownership'] || true
|
62
|
+
)
|
63
|
+
when 'nfs'
|
64
|
+
options[:mount_options] = ['actimeo=1'] if options[:mount_options].empty?
|
65
|
+
end
|
49
66
|
|
50
|
-
|
67
|
+
# Remove nil values
|
68
|
+
options.compact
|
51
69
|
end
|
52
70
|
|
53
|
-
def
|
54
|
-
|
55
|
-
prefix = "==> #{settings['server_id']}--#{settings['hostname']}.#{settings['domain']}:"
|
71
|
+
def get_mount_options(folder)
|
72
|
+
mount_opts = []
|
56
73
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
host_path = folder['map'].split(%r{(?<=/)[^/]*$}).last
|
62
|
-
transfer_cmd = "vagrant scp :#{guest_path} #{host_path}"
|
63
|
-
puts "#{prefix} #{transfer_cmd}"
|
64
|
-
system(transfer_cmd)
|
65
|
-
end
|
74
|
+
# Add type-specific mount options
|
75
|
+
case folder['type']
|
76
|
+
when 'nfs'
|
77
|
+
mount_opts << 'actimeo=1'
|
66
78
|
end
|
79
|
+
|
80
|
+
# Add custom mount options if specified
|
81
|
+
mount_opts.concat(Array(folder['mount_options'])) if folder['mount_options']
|
82
|
+
|
83
|
+
mount_opts
|
67
84
|
end
|
68
85
|
end
|
69
86
|
end
|
@@ -6,26 +6,14 @@ module VagrantPlugins
|
|
6
6
|
class IsCreated
|
7
7
|
def initialize(app, _env)
|
8
8
|
@app = app
|
9
|
-
@logger = Log4r::Logger.new('vagrant_startcloud::action::is_created')
|
10
9
|
end
|
11
10
|
|
12
11
|
def call(env)
|
13
|
-
machine
|
14
|
-
|
15
|
-
|
16
|
-
@logger.debug("Checking if machine '#{machine.name}' is created (state: #{state_id})")
|
17
|
-
|
18
|
-
# Consider the machine created if it's in any state other than :not_created
|
19
|
-
env[:result] = state_id != :not_created
|
20
|
-
|
21
|
-
@logger.info("Machine '#{machine.name}' is #{env[:result] ? '' : 'not '}created")
|
12
|
+
# Set the result to be true if the machine is created
|
13
|
+
env[:result] = env[:machine].state.id != :not_created
|
22
14
|
|
23
15
|
# Call the next middleware
|
24
16
|
@app.call(env)
|
25
|
-
rescue StandardError => e
|
26
|
-
@logger.error("Error checking machine state: #{e.message}")
|
27
|
-
@logger.error(e.backtrace.join("\n"))
|
28
|
-
raise Errors::VMConfigurationError, error: e.message
|
29
17
|
end
|
30
18
|
end
|
31
19
|
end
|
@@ -6,26 +6,15 @@ module VagrantPlugins
|
|
6
6
|
class IsVirtualBox
|
7
7
|
def initialize(app, _env)
|
8
8
|
@app = app
|
9
|
-
@logger = Log4r::Logger.new('vagrant_startcloud::action::is_virtualbox')
|
10
9
|
end
|
11
10
|
|
12
11
|
def call(env)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@logger.debug("Checking if machine '#{machine.name}' uses VirtualBox provider (current: #{provider_name})")
|
17
|
-
|
18
|
-
# Check if the provider is VirtualBox
|
19
|
-
env[:result] = provider_name == :virtualbox
|
20
|
-
|
21
|
-
@logger.info("Machine '#{machine.name}' is #{env[:result] ? '' : 'not '}using VirtualBox provider")
|
12
|
+
# Set the result to be true if the provider is VirtualBox
|
13
|
+
provider = env[:machine].provider_name
|
14
|
+
env[:result] = provider == :virtualbox
|
22
15
|
|
23
16
|
# Call the next middleware
|
24
17
|
@app.call(env)
|
25
|
-
rescue StandardError => e
|
26
|
-
@logger.error("Error checking provider: #{e.message}")
|
27
|
-
@logger.error(e.backtrace.join("\n"))
|
28
|
-
raise Errors::ProviderConfigurationError, error: e.message
|
29
18
|
end
|
30
19
|
end
|
31
20
|
end
|
@@ -7,61 +7,114 @@ module VagrantPlugins
|
|
7
7
|
module Action
|
8
8
|
include Vagrant::Action::Builtin
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
class << self
|
11
|
+
def configure_machine
|
12
|
+
@configure_machine ||= Vagrant::Action::Builder.new.tap do |b|
|
13
|
+
b.use ConfigValidate
|
14
|
+
b.use Call, IsCreated do |env, b2|
|
15
|
+
unless env[:result]
|
16
|
+
b2.use HandleBox
|
17
|
+
b2.use Import
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure_networks
|
24
|
+
@configure_networks ||= Vagrant::Action::Builder.new.tap do |b|
|
25
|
+
b.use Call, IsVirtualBox do |env, b2|
|
26
|
+
if env[:result]
|
27
|
+
b2.use ConfigureNetworks, provider: :virtualbox
|
28
|
+
else
|
29
|
+
b2.use ConfigureNetworks, provider: :zones
|
30
|
+
end
|
17
31
|
end
|
32
|
+
end
|
33
|
+
end
|
18
34
|
|
19
|
-
|
20
|
-
|
21
|
-
|
35
|
+
def configure_providers
|
36
|
+
@configure_providers ||= Vagrant::Action::Builder.new.tap do |b|
|
37
|
+
b.use Call, IsVirtualBox do |env, b2|
|
38
|
+
if env[:result]
|
39
|
+
b2.use ConfigureProviders, provider: :virtualbox
|
22
40
|
else
|
23
|
-
|
41
|
+
b2.use ConfigureProviders, provider: :zones
|
24
42
|
end
|
25
43
|
end
|
44
|
+
end
|
45
|
+
end
|
26
46
|
|
27
|
-
|
47
|
+
def configure_shared_folders
|
48
|
+
@configure_shared_folders ||= Vagrant::Action::Builder.new.tap do |b|
|
49
|
+
b.use ConfigureSharedFolders
|
28
50
|
end
|
29
51
|
end
|
30
|
-
end
|
31
52
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
53
|
+
def action_up
|
54
|
+
Vagrant::Action::Builder.new.tap do |b|
|
55
|
+
b.use configure_machine
|
56
|
+
b.use configure_providers
|
57
|
+
b.use Call, IsVirtualBox do |env, b2|
|
58
|
+
if env[:result]
|
59
|
+
b2.use ConfigureDisks, provider: :virtualbox
|
60
|
+
else
|
61
|
+
b2.use ConfigureDisks, provider: :zones
|
62
|
+
end
|
63
|
+
end
|
64
|
+
b.use configure_networks
|
65
|
+
b.use configure_shared_folders
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def action_reload
|
70
|
+
action_up
|
71
|
+
end
|
72
|
+
|
73
|
+
def action_halt
|
74
|
+
Vagrant::Action::Builder.new.tap do |b|
|
75
|
+
b.use ConfigValidate
|
76
|
+
b.use Call, IsCreated do |env, b2|
|
77
|
+
if env[:result]
|
78
|
+
b2.use Call, IsVirtualBox do |env2, b3|
|
79
|
+
if env2[:result]
|
80
|
+
b3.use VagrantPlugins::ProviderVirtualBox::Action::GracefulHalt
|
81
|
+
else
|
82
|
+
b3.use VagrantPlugins::ProviderZone::Action::GracefulHalt
|
83
|
+
end
|
42
84
|
end
|
85
|
+
b2.use PowerOff
|
43
86
|
end
|
44
|
-
b2.use PowerOff
|
45
87
|
end
|
46
88
|
end
|
47
89
|
end
|
48
|
-
end
|
49
90
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
91
|
+
def action_destroy
|
92
|
+
Vagrant::Action::Builder.new.tap do |b|
|
93
|
+
b.use ConfigValidate
|
94
|
+
b.use Call, IsCreated do |env, b2|
|
95
|
+
if env[:result]
|
96
|
+
b2.use action_halt
|
97
|
+
b2.use Call, IsVirtualBox do |env2, b3|
|
98
|
+
if env2[:result]
|
99
|
+
b3.use VagrantPlugins::ProviderVirtualBox::Action::Destroy
|
100
|
+
else
|
101
|
+
b3.use VagrantPlugins::ProviderZone::Action::Destroy
|
102
|
+
end
|
61
103
|
end
|
104
|
+
b2.use CleanupNetworks
|
105
|
+
b2.use ProvisionerCleanup
|
62
106
|
end
|
63
|
-
|
64
|
-
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def with_target_vms(machine_name = nil, **opts, &block)
|
112
|
+
env = opts.fetch(:env, Vagrant::Environment.new)
|
113
|
+
env.machine_names = [machine_name] if machine_name
|
114
|
+
|
115
|
+
env.batch(parallel: true) do |batch|
|
116
|
+
env.active_machines.each do |name, provider|
|
117
|
+
batch.action(env.machine(name, provider), :up, &block)
|
65
118
|
end
|
66
119
|
end
|
67
120
|
end
|
@@ -70,20 +123,11 @@ module VagrantPlugins
|
|
70
123
|
# Load middleware classes
|
71
124
|
action_root = Pathname.new(File.expand_path('action', __dir__))
|
72
125
|
autoload :ConfigureNetworks, action_root.join('configure_networks')
|
126
|
+
autoload :ConfigureProviders, action_root.join('configure_providers')
|
127
|
+
autoload :ConfigureSharedFolders, action_root.join('configure_shared_folders')
|
128
|
+
autoload :ConfigureDisks, action_root.join('configure_disks')
|
73
129
|
autoload :IsCreated, action_root.join('is_created')
|
74
130
|
autoload :IsVirtualBox, action_root.join('is_virtualbox')
|
75
|
-
|
76
|
-
# Helper methods
|
77
|
-
def self.with_target_vms(machine_name = nil, **opts, &block)
|
78
|
-
env = opts.fetch(:env, Vagrant::Environment.new)
|
79
|
-
env.machine_names = [machine_name] if machine_name
|
80
|
-
|
81
|
-
env.batch(parallel: true) do |batch|
|
82
|
-
env.active_machines.each do |name, provider|
|
83
|
-
batch.action(env.machine(name, provider), :up, &block)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
131
|
end
|
88
132
|
end
|
89
133
|
end
|
@@ -26,17 +26,16 @@ module VagrantPlugins
|
|
26
26
|
def validate(_machine)
|
27
27
|
errors = _detected_errors
|
28
28
|
|
29
|
-
errors <<
|
29
|
+
errors << "Configuration file '#{@config_path}' does not exist" if @config_path && !File.exist?(@config_path)
|
30
30
|
|
31
31
|
if @settings.empty?
|
32
|
-
errors <<
|
32
|
+
errors << 'No settings defined in configuration'
|
33
33
|
return { 'StartCloud configuration' => errors }
|
34
34
|
end
|
35
35
|
|
36
36
|
required_settings = %w[hostname domain server_id box]
|
37
37
|
missing_settings = required_settings - @settings.keys
|
38
|
-
|
39
|
-
errors << I18n.t('vagrant_startcloud.config.missing_required', fields: missing_settings.join(', ')) unless missing_settings.empty?
|
38
|
+
errors << "Missing required settings: #{missing_settings.join(', ')}" unless missing_settings.empty?
|
40
39
|
|
41
40
|
{ 'StartCloud configuration' => errors }
|
42
41
|
end
|
@@ -44,21 +43,86 @@ module VagrantPlugins
|
|
44
43
|
def load_config(machine)
|
45
44
|
return unless @config_path && File.exist?(@config_path)
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
46
|
+
begin
|
47
|
+
yaml_config = YAML.load_file(@config_path)
|
48
|
+
return unless yaml_config && yaml_config['hosts']
|
49
|
+
|
50
|
+
host = yaml_config['hosts'].first
|
51
|
+
|
52
|
+
# Load all configuration sections
|
53
|
+
@settings = host['settings'] || {}
|
54
|
+
@networks = host['networks'] || []
|
55
|
+
@disks = host['disks'] || {}
|
56
|
+
@provisioning = host['provisioning'] || {}
|
57
|
+
@folders = host['folders'] || []
|
58
|
+
@roles = host['roles'] || []
|
59
|
+
@vars = host['vars'] || {}
|
60
|
+
@plugins = host['plugins'] || {}
|
61
|
+
@zones = host['zones'] || {}
|
62
|
+
|
63
|
+
# Configure plugins if specified
|
64
|
+
configure_plugins(host['plugins']) if host['plugins']
|
65
|
+
|
66
|
+
# Configure provider-specific settings
|
67
|
+
configure_provider(machine, host) if @settings['provider_type']
|
68
|
+
rescue StandardError => e
|
69
|
+
raise Errors::YAMLParseError, _key: :yaml_error, error: e.message
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def configure_provider(machine, host)
|
76
|
+
provider_type = @settings['provider_type'].to_sym
|
77
|
+
|
78
|
+
machine.vm.provider provider_type do |provider|
|
79
|
+
case provider_type
|
80
|
+
when :virtualbox
|
81
|
+
configure_virtualbox(provider, host)
|
82
|
+
when :zones
|
83
|
+
configure_zones(provider, host)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def configure_virtualbox(provider, host)
|
89
|
+
settings = host['settings']
|
90
|
+
memory = if settings['memory'].to_s =~ /gb|g/i
|
91
|
+
1024 * settings['memory'].to_s.tr('^0-9', '').to_i
|
92
|
+
else
|
93
|
+
settings['memory'].to_s.tr('^0-9', '').to_i
|
94
|
+
end
|
95
|
+
|
96
|
+
provider.name = "#{settings['server_id']}--#{settings['hostname']}.#{settings['domain']}"
|
97
|
+
provider.gui = settings['show_console']
|
98
|
+
provider.memory = memory if memory.positive?
|
99
|
+
provider.cpus = settings['vcpus']
|
100
|
+
end
|
101
|
+
|
102
|
+
def configure_zones(provider, host)
|
103
|
+
settings = host['settings']
|
104
|
+
zones = host['zones']
|
105
|
+
|
106
|
+
provider.hostname = "#{settings['hostname']}.#{settings['domain']}"
|
107
|
+
provider.brand = zones['brand']
|
108
|
+
provider.memory = settings['memory']
|
109
|
+
provider.cpus = settings['vcpus']
|
110
|
+
end
|
111
|
+
|
112
|
+
def configure_plugins(plugins)
|
113
|
+
return unless plugins
|
114
|
+
|
115
|
+
plugins['install']&.each do |plugin|
|
116
|
+
unless Vagrant.has_plugin?(plugin['name'])
|
117
|
+
system("vagrant plugin install #{plugin['name']}" + (plugin['version'] == 'latest' ? '' : " --plugin-version #{plugin['version']}"))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
return unless plugins['remove']
|
122
|
+
|
123
|
+
plugins['remove'].each do |plugin|
|
124
|
+
system("vagrant plugin uninstall #{plugin['name']}") if Vagrant.has_plugin?(plugin['name'])
|
125
|
+
end
|
62
126
|
end
|
63
127
|
end
|
64
128
|
end
|
@@ -27,27 +27,43 @@ module VagrantPlugins
|
|
27
27
|
Provisioner
|
28
28
|
end
|
29
29
|
|
30
|
-
# Register
|
31
|
-
|
32
|
-
require_relative '
|
33
|
-
|
30
|
+
# Register action hooks
|
31
|
+
action_hook(:startcloud_up, :machine_action_up) do |hook|
|
32
|
+
require_relative 'action'
|
33
|
+
hook.after(Vagrant::Action::Builtin::Provision, Action.action_up)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
action_hook(:startcloud_configure, :machine_action_up) do |hook|
|
36
|
+
action_hook(:startcloud_reload, :machine_action_reload) do |hook|
|
38
37
|
require_relative 'action'
|
39
|
-
hook.
|
38
|
+
hook.after(Vagrant::Action::Builtin::Provision, Action.action_reload)
|
40
39
|
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
action_hook(:startcloud_halt, :machine_action_halt) do |hook|
|
42
|
+
require_relative 'action'
|
43
|
+
hook.after(Vagrant::Action::Builtin::GracefulHalt, Action.action_halt)
|
44
|
+
end
|
45
|
+
|
46
|
+
action_hook(:startcloud_destroy, :machine_action_destroy) do |hook|
|
47
|
+
require_relative 'action'
|
48
|
+
hook.after(Vagrant::Action::Builtin::DestroyConfirm, Action.action_destroy)
|
46
49
|
end
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
# Register provider capabilities
|
52
|
+
%i[virtualbox zones].each do |provider|
|
53
|
+
provider_capability(provider, :configure_networks) do
|
54
|
+
require_relative 'action/configure_networks'
|
55
|
+
Action::ConfigureNetworks
|
56
|
+
end
|
57
|
+
|
58
|
+
provider_capability(provider, :configure_disks) do
|
59
|
+
require_relative 'action/configure_disks'
|
60
|
+
Action::ConfigureDisks
|
61
|
+
end
|
62
|
+
|
63
|
+
provider_capability(provider, :configure_provider) do
|
64
|
+
require_relative 'action/configure_providers'
|
65
|
+
Action::ConfigureProviders
|
66
|
+
end
|
51
67
|
end
|
52
68
|
|
53
69
|
# Plugin registration
|
@@ -73,7 +89,6 @@ module VagrantPlugins
|
|
73
89
|
c = Vagrant::Plugin::V2::Components.new
|
74
90
|
c.configs[:top].register(:startcloud) { Config }
|
75
91
|
c.configs[:provisioner].register(:startcloud) { Config }
|
76
|
-
c.commands.register(:startcloud) { [Command, { primary: true }] }
|
77
92
|
c.provisioners.register(:startcloud) { Provisioner }
|
78
93
|
c
|
79
94
|
end
|
data/lib/vagrant-startcloud.rb
CHANGED
@@ -3,6 +3,59 @@
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'i18n'
|
5
5
|
require 'vagrant'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
# Top-level module for the plugin
|
9
|
+
module StartCloud
|
10
|
+
def self.configure(config, settings_file = 'Hosts.yml')
|
11
|
+
unless File.exist?(settings_file)
|
12
|
+
raise Vagrant::Errors::VagrantError.new(
|
13
|
+
error_message: "StartCloud configuration file not found: #{settings_file}"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
yaml_config = YAML.load_file(settings_file)
|
18
|
+
return unless yaml_config && yaml_config['hosts']
|
19
|
+
|
20
|
+
# Configure each VM defined in hosts
|
21
|
+
yaml_config['hosts'].each do |host|
|
22
|
+
settings = host['settings']
|
23
|
+
hostname = "#{settings['hostname']}.#{settings['domain']}"
|
24
|
+
vm_name = "#{settings['server_id']}--#{hostname}"
|
25
|
+
|
26
|
+
config.vm.define vm_name do |machine|
|
27
|
+
# Configure the StartCloud plugin first
|
28
|
+
machine.startcloud.config_path = settings_file
|
29
|
+
machine.startcloud.settings = settings
|
30
|
+
machine.startcloud.networks = host['networks'] || []
|
31
|
+
machine.startcloud.disks = host['disks'] || {}
|
32
|
+
machine.startcloud.folders = host['folders'] || []
|
33
|
+
machine.startcloud.roles = host['roles'] || []
|
34
|
+
machine.startcloud.vars = host['vars'] || {}
|
35
|
+
machine.startcloud.plugins = host['plugins'] || {}
|
36
|
+
machine.startcloud.zones = host['zones'] || {}
|
37
|
+
|
38
|
+
# Set basic VM settings
|
39
|
+
machine.vm.box = settings['box']
|
40
|
+
machine.vm.hostname = hostname
|
41
|
+
machine.vm.boot_timeout = settings['setup_wait'] if settings['setup_wait']
|
42
|
+
|
43
|
+
# Configure SSH settings
|
44
|
+
if settings['vagrant_user']
|
45
|
+
machine.ssh.username = settings['vagrant_user']
|
46
|
+
machine.ssh.private_key_path = settings['vagrant_user_private_key_path'] if settings['vagrant_user_private_key_path']
|
47
|
+
end
|
48
|
+
machine.ssh.insert_key = false
|
49
|
+
machine.ssh.forward_agent = true
|
50
|
+
|
51
|
+
# Set provider
|
52
|
+
machine.vm.provider settings['provider_type'].to_sym do |provider|
|
53
|
+
provider.name = vm_name if provider.respond_to?(:name=)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
6
59
|
|
7
60
|
module VagrantPlugins
|
8
61
|
module StartCloud
|
@@ -12,7 +65,6 @@ module VagrantPlugins
|
|
12
65
|
require lib_path.join('version')
|
13
66
|
require lib_path.join('errors')
|
14
67
|
require lib_path.join('config')
|
15
|
-
require lib_path.join('command')
|
16
68
|
require lib_path.join('provisioner')
|
17
69
|
require lib_path.join('config_builder')
|
18
70
|
require lib_path.join('action')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-startcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Gilbert
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- README.md
|
202
202
|
- lib/vagrant-startcloud.rb
|
203
203
|
- lib/vagrant-startcloud/action.rb
|
204
|
+
- lib/vagrant-startcloud/action/configure_disks.rb
|
204
205
|
- lib/vagrant-startcloud/action/configure_networks.rb
|
205
206
|
- lib/vagrant-startcloud/action/configure_providers.rb
|
206
207
|
- lib/vagrant-startcloud/action/configure_provisioners.rb
|