corl 0.4.16 → 0.4.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -8
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/01_git.sh +3 -5
- data/bootstrap/os/ubuntu/05_ruby.sh +4 -4
- data/bootstrap/os/ubuntu/06_puppet.sh +1 -1
- data/corl.gemspec +9 -3
- data/lib/CORL/action/reboot.rb +59 -0
- data/lib/CORL/configuration/file.rb +3 -1
- data/lib/CORL/machine/vagrant.rb +56 -40
- data/lib/CORL/node/vagrant.rb +3 -0
- data/lib/CORL/provisioner/puppetnode.rb +43 -44
- data/lib/core/facade.rb +2 -2
- data/lib/core/mixin/lookup.rb +6 -6
- data/lib/core/mod/facter_loader.rb +15 -0
- data/lib/core/mod/hiera_backend.rb +7 -3
- data/lib/core/plugin/action.rb +2 -7
- data/lib/core/plugin/configuration.rb +6 -0
- data/lib/core/plugin/network.rb +84 -42
- data/lib/core/plugin/node.rb +12 -8
- data/lib/core/plugin/provisioner.rb +11 -18
- data/lib/core/util/puppet.rb +3 -3
- data/lib/core/vagrant/action.rb +39 -0
- data/lib/core/vagrant/actions/create_shares.rb +28 -0
- data/lib/core/vagrant/actions/delete_cache.rb +18 -0
- data/lib/core/vagrant/actions/init_keys.rb +28 -0
- data/lib/core/vagrant/commands/launcher.rb +2 -2
- data/lib/core/vagrant/config.rb +7 -11
- data/lib/core/vagrant/plugins.rb +27 -5
- data/lib/core/vagrant/provisioner/config.rb +45 -6
- data/lib/core/vagrant/provisioner/provisioner.rb +41 -15
- data/lib/corl.rb +6 -4
- data/lib/facter/custom_facts.rb +2 -2
- data/lib/puppet/parser/functions/render.rb +4 -1
- data/locales/en.yml +15 -0
- metadata +8 -2
data/lib/core/facade.rb
CHANGED
@@ -22,9 +22,9 @@ module Facade
|
|
22
22
|
|
23
23
|
#---
|
24
24
|
|
25
|
-
def vagrant_config(directory, config)
|
25
|
+
def vagrant_config(directory, config, &code)
|
26
26
|
require File.join(File.dirname(__FILE__), 'vagrant', 'config.rb')
|
27
|
-
Vagrant::Config.register(directory, config)
|
27
|
+
Vagrant::Config.register(directory, config, &code)
|
28
28
|
end
|
29
29
|
|
30
30
|
#-----------------------------------------------------------------------------
|
data/lib/core/mixin/lookup.rb
CHANGED
@@ -110,7 +110,7 @@ module Lookup
|
|
110
110
|
debug_lookup(config, property, value, "Hiera lookup")
|
111
111
|
end
|
112
112
|
|
113
|
-
if provisioner &&
|
113
|
+
if provisioner && value.nil?
|
114
114
|
# Search the provisioner scope (only admins can provision a machine)
|
115
115
|
value = CORL.provisioner({ :name => :lookup }, provisioner).lookup(property, default, config)
|
116
116
|
debug_lookup(config, property, value, "Provisioner lookup")
|
@@ -118,14 +118,14 @@ module Lookup
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
|
-
if
|
121
|
+
if value.nil? # Resort to default
|
122
122
|
value = default
|
123
123
|
debug_lookup(config, first_property, value, "Default value")
|
124
124
|
end
|
125
125
|
value = Util::Data.value(value, config.get(:undefined_value, :undefined))
|
126
126
|
|
127
|
-
if
|
128
|
-
Config.set_property(first_property
|
127
|
+
if Config.get_property(first_property).nil? || value
|
128
|
+
Config.set_property(first_property, value)
|
129
129
|
end
|
130
130
|
|
131
131
|
debug_lookup(config, first_property, value, 'Internalized value')
|
@@ -161,7 +161,7 @@ module Lookup
|
|
161
161
|
value = Util::Data.value(value, config.get(:undefined_value, :undefined))
|
162
162
|
debug_lookup(config, property, value, "Final array value")
|
163
163
|
|
164
|
-
Config.set_property(property
|
164
|
+
Config.set_property(property, value)
|
165
165
|
CORL.ui.info("\n", { :prefix => false }) if config.get(:debug, false)
|
166
166
|
value
|
167
167
|
end
|
@@ -190,7 +190,7 @@ module Lookup
|
|
190
190
|
value = Util::Data.value(value, config.get(:undefined_value, :undefined))
|
191
191
|
debug_lookup(config, property, value, "Final hash value")
|
192
192
|
|
193
|
-
Config.set_property(property
|
193
|
+
Config.set_property(property, value)
|
194
194
|
CORL.ui.info("\n", { :prefix => false }) if config.get(:debug, false)
|
195
195
|
value
|
196
196
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module Facter
|
3
|
+
module Util
|
4
|
+
class Loader
|
5
|
+
def load_dir(dir)
|
6
|
+
# TODO: If this works submit a patch to Facter project
|
7
|
+
return if dir =~ /\/\.+$/ or dir =~ /\/util$/ or dir =~ /\/core$/ or dir =~ /\/lib$/
|
8
|
+
|
9
|
+
Dir.entries(dir).find_all { |f| f =~ /\.rb$/ }.sort.each do |file|
|
10
|
+
load_file(File.join(dir, file))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,7 +3,7 @@ class Hiera
|
|
3
3
|
module Backend
|
4
4
|
class << self
|
5
5
|
#
|
6
|
-
# NOTE: This
|
6
|
+
# NOTE: This method is overridden so we can collect accumulated hiera
|
7
7
|
# parameters and their values on a particular provisioning run for reporting
|
8
8
|
# purposes.
|
9
9
|
#
|
@@ -37,8 +37,12 @@ class << self
|
|
37
37
|
answer = resolve_answer(answer, resolution_type) unless answer.nil?
|
38
38
|
answer = parse_string(default, scope) if answer.nil? and default.is_a?(String)
|
39
39
|
answer = default if answer.nil?
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
# This is why we override this method!!
|
42
|
+
# TODO: Submit a patch that allows for some kind of hook into the process.
|
43
|
+
if CORL::Config.get_property(key).nil? || answer
|
44
|
+
CORL::Config.set_property(key, answer)
|
45
|
+
end
|
42
46
|
return answer
|
43
47
|
end
|
44
48
|
end
|
data/lib/core/plugin/action.rb
CHANGED
@@ -159,13 +159,8 @@ class CloudAction < CORL.plugin_class(:action)
|
|
159
159
|
end
|
160
160
|
|
161
161
|
# Load network if it exists
|
162
|
-
network_config = extended_config(:network, { :directory => network_path
|
163
|
-
|
164
|
-
network = CORL.network(
|
165
|
-
CORL.sha1(network_config),
|
166
|
-
network_config,
|
167
|
-
settings[:net_provider]
|
168
|
-
)
|
162
|
+
network_config = extended_config(:network, { :directory => network_path })
|
163
|
+
network = CORL.network(network_path, network_config, settings[:net_provider])
|
169
164
|
network
|
170
165
|
end
|
171
166
|
|
@@ -32,6 +32,12 @@ class Configuration < CORL.plugin_class(:base)
|
|
32
32
|
|
33
33
|
set_location(@project)
|
34
34
|
end
|
35
|
+
|
36
|
+
#---
|
37
|
+
|
38
|
+
def remove_plugin
|
39
|
+
CORL.remove_plugin(@project)
|
40
|
+
end
|
35
41
|
|
36
42
|
#-----------------------------------------------------------------------------
|
37
43
|
# Checks
|
data/lib/core/plugin/network.rb
CHANGED
@@ -3,7 +3,7 @@ module Nucleon
|
|
3
3
|
module Plugin
|
4
4
|
class Network < CORL.plugin_class(:base)
|
5
5
|
|
6
|
-
init_plugin_collection
|
6
|
+
init_plugin_collection(:add_node, :batch)
|
7
7
|
|
8
8
|
#-----------------------------------------------------------------------------
|
9
9
|
# Cloud plugin interface
|
@@ -17,6 +17,16 @@ class Network < CORL.plugin_class(:base)
|
|
17
17
|
ignore('build')
|
18
18
|
end
|
19
19
|
|
20
|
+
#---
|
21
|
+
|
22
|
+
def remove_plugin
|
23
|
+
CORL.remove_plugin(config)
|
24
|
+
|
25
|
+
each_plugin do |type, provider, name, plugin|
|
26
|
+
CORL.remove_plugin(plugin)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
20
30
|
#-----------------------------------------------------------------------------
|
21
31
|
# Checks
|
22
32
|
|
@@ -226,8 +236,6 @@ class Network < CORL.plugin_class(:base)
|
|
226
236
|
|
227
237
|
#---
|
228
238
|
|
229
|
-
execute_block_on_receiver :add_node
|
230
|
-
|
231
239
|
def add_node(provider, name, options = {})
|
232
240
|
config = Config.ensure(options)
|
233
241
|
|
@@ -247,7 +255,7 @@ class Network < CORL.plugin_class(:base)
|
|
247
255
|
})
|
248
256
|
|
249
257
|
# Set node data
|
250
|
-
node
|
258
|
+
node = set_node(provider, name, node_options)
|
251
259
|
hook_config = { :node => node, :remote => remote_name, :config => config }
|
252
260
|
success = true
|
253
261
|
|
@@ -260,50 +268,86 @@ class Network < CORL.plugin_class(:base)
|
|
260
268
|
end
|
261
269
|
|
262
270
|
if success && node.save({ :remote => remote_name, :message => "Created machine #{name} on #{provider}" })
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
271
|
+
success = init_node(node, config.defaults({ :bootstrap => true, :seed => true })) do |op, data|
|
272
|
+
block_given? ? yield(op, data) : data
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
success
|
277
|
+
end
|
278
|
+
|
279
|
+
#---
|
280
|
+
|
281
|
+
def init_node(node, options = {})
|
282
|
+
config = Config.ensure(options)
|
283
|
+
success = true
|
284
|
+
|
285
|
+
bootstrap = config.delete(:bootstrap, false)
|
286
|
+
seed = config.delete(:seed, false)
|
287
|
+
|
288
|
+
unless node.cache_setting(:initialized)
|
289
|
+
bootstrap = true
|
290
|
+
seed = true
|
291
|
+
end
|
292
|
+
|
293
|
+
provision = config.delete(:provision, true)
|
294
|
+
|
295
|
+
if bootstrap
|
296
|
+
# Bootstrap machine
|
297
|
+
success = node.bootstrap(home, extended_config(:bootstrap, config)) do |op, data|
|
298
|
+
block_given? ? yield("bootstrap_#{op}".to_sym, data) : data
|
299
|
+
end
|
300
|
+
end
|
267
301
|
|
268
|
-
|
269
|
-
|
270
|
-
|
302
|
+
if success
|
303
|
+
if seed
|
304
|
+
seed_project = config.get(:project_reference, nil)
|
305
|
+
save_config = { :commit => true, :remote => remote_name, :push => true }
|
271
306
|
|
272
|
-
|
273
|
-
|
274
|
-
|
307
|
+
if seed_project && remote_name
|
308
|
+
# Reset project remote
|
309
|
+
seed_info = Plugin::Project.translate_reference(seed_project)
|
275
310
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
end
|
282
|
-
set_remote(:origin, seed_url) if remote_name.to_sym == :edit
|
283
|
-
set_remote(remote_name, seed_url)
|
284
|
-
save_config[:pull] = false
|
311
|
+
if seed_info
|
312
|
+
seed_url = seed_info[:url]
|
313
|
+
seed_branch = seed_info[:revision] if seed_info[:revision]
|
314
|
+
else
|
315
|
+
seed_url = seed_project
|
285
316
|
end
|
317
|
+
set_remote(:origin, seed_url) if remote_name.to_sym == :edit
|
318
|
+
set_remote(remote_name, seed_url)
|
319
|
+
save_config[:pull] = false
|
320
|
+
end
|
286
321
|
|
287
|
-
|
288
|
-
|
322
|
+
# Save network changes (preliminary)
|
323
|
+
success = node.save(extended_config(:node_save, save_config))
|
289
324
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
end
|
298
|
-
success = result.status == code.success
|
325
|
+
if success && seed_project
|
326
|
+
# Seed machine with remote project reference
|
327
|
+
result = node.seed({
|
328
|
+
:project_reference => seed_project,
|
329
|
+
:project_branch => seed_branch
|
330
|
+
}) do |op, data|
|
331
|
+
yield("seed_#{op}".to_sym, data)
|
299
332
|
end
|
300
|
-
|
301
|
-
# Update local network project
|
302
|
-
success = load({ :remote => remote_name, :pull => true }) if success
|
333
|
+
success = result.status == code.success
|
303
334
|
end
|
304
335
|
end
|
305
|
-
|
306
|
-
|
336
|
+
|
337
|
+
node.set_cache_setting(:initialized, true) if success
|
338
|
+
|
339
|
+
if success && provision
|
340
|
+
# Run configured provisioners on machine
|
341
|
+
result = node.provision(config) do |op, data|
|
342
|
+
yield("provision_#{op}".to_sym, data)
|
343
|
+
end
|
344
|
+
success = result.status == code.success
|
345
|
+
end
|
346
|
+
|
347
|
+
# Update local network project
|
348
|
+
success = load({ :remote => remote_name, :pull => true }) if success
|
349
|
+
end
|
350
|
+
success
|
307
351
|
end
|
308
352
|
|
309
353
|
#-----------------------------------------------------------------------------
|
@@ -321,8 +365,6 @@ class Network < CORL.plugin_class(:base)
|
|
321
365
|
|
322
366
|
#---
|
323
367
|
|
324
|
-
execute_block_on_receiver :batch
|
325
|
-
|
326
368
|
def batch(node_references, default_provider = nil, parallel = true, &code)
|
327
369
|
success = true
|
328
370
|
|
@@ -330,7 +372,7 @@ class Network < CORL.plugin_class(:base)
|
|
330
372
|
# Execute action on selected nodes
|
331
373
|
nodes = nodes_by_reference(node_references, default_provider)
|
332
374
|
|
333
|
-
if parallel
|
375
|
+
if CORL.parallel? && parallel
|
334
376
|
values = []
|
335
377
|
nodes.each do |node|
|
336
378
|
values << Celluloid::Future.new(node, &code)
|
data/lib/core/plugin/node.rb
CHANGED
@@ -3,7 +3,8 @@ module Nucleon
|
|
3
3
|
module Plugin
|
4
4
|
class Node < CORL.plugin_class(:base)
|
5
5
|
|
6
|
-
include
|
6
|
+
include Parallel
|
7
|
+
external_block_exec :exec, :command, :action
|
7
8
|
|
8
9
|
#-----------------------------------------------------------------------------
|
9
10
|
# Node plugin interface
|
@@ -56,6 +57,13 @@ class Node < CORL.plugin_class(:base)
|
|
56
57
|
@local_context = true
|
57
58
|
myself.local_machine = create_machine(:local_machine, :physical)
|
58
59
|
end
|
60
|
+
|
61
|
+
#---
|
62
|
+
|
63
|
+
def remove_plugin
|
64
|
+
CORL.remove_plugin(local_machine) if local_machine
|
65
|
+
CORL.remove_plugin(machine) if machine
|
66
|
+
end
|
59
67
|
|
60
68
|
#-----------------------------------------------------------------------------
|
61
69
|
# Checks
|
@@ -567,8 +575,6 @@ class Node < CORL.plugin_class(:base)
|
|
567
575
|
|
568
576
|
#---
|
569
577
|
|
570
|
-
execute_block_on_receiver :exec
|
571
|
-
|
572
578
|
def exec(options = {})
|
573
579
|
default_error = Util::Shell::Result.new(:error, 255)
|
574
580
|
results = [ default_error ]
|
@@ -636,8 +642,6 @@ class Node < CORL.plugin_class(:base)
|
|
636
642
|
|
637
643
|
#---
|
638
644
|
|
639
|
-
execute_block_on_receiver :command
|
640
|
-
|
641
645
|
def command(command, options = {})
|
642
646
|
config = Config.ensure(options)
|
643
647
|
as_admin = config.delete(:as_admin, false)
|
@@ -654,14 +658,14 @@ class Node < CORL.plugin_class(:base)
|
|
654
658
|
|
655
659
|
results = exec({ :commands => [ "#{admin_command} #{command.to_s}".strip ] }) do |op, data|
|
656
660
|
yield(op, data) if block_given?
|
657
|
-
end
|
661
|
+
end
|
662
|
+
|
663
|
+
CORL.remove_plugin(command)
|
658
664
|
results.first
|
659
665
|
end
|
660
666
|
|
661
667
|
#---
|
662
668
|
|
663
|
-
execute_block_on_receiver :action
|
664
|
-
|
665
669
|
def action(provider, options = {})
|
666
670
|
codes :network_load_error
|
667
671
|
|
@@ -3,7 +3,7 @@ module Nucleon
|
|
3
3
|
module Plugin
|
4
4
|
class Provisioner < CORL.plugin_class(:base)
|
5
5
|
|
6
|
-
include
|
6
|
+
include Parallel
|
7
7
|
|
8
8
|
#-----------------------------------------------------------------------------
|
9
9
|
# Provisioner plugin interface
|
@@ -105,25 +105,25 @@ class Provisioner < CORL.plugin_class(:base)
|
|
105
105
|
#---
|
106
106
|
|
107
107
|
def build_locations(reset = false)
|
108
|
-
locations =
|
108
|
+
locations = cache_setting(:build_locations, {}, :hash)
|
109
109
|
build if reset || locations.empty?
|
110
|
-
|
110
|
+
cache_setting(:build_locations, {}, :hash)
|
111
111
|
end
|
112
112
|
|
113
113
|
#---
|
114
114
|
|
115
115
|
def build_info(reset = false)
|
116
|
-
info =
|
116
|
+
info = cache_setting(:build_info, {}, :hash)
|
117
117
|
build if reset || info.empty?
|
118
|
-
|
118
|
+
cache_setting(:build_info, {}, :hash)
|
119
119
|
end
|
120
120
|
|
121
121
|
#---
|
122
122
|
|
123
123
|
def build_profiles(reset = false)
|
124
|
-
profiles =
|
124
|
+
profiles = cache_setting(:build_profiles, [], :array)
|
125
125
|
build if reset || profiles.empty?
|
126
|
-
|
126
|
+
cache_setting(:build_profiles, [], :array)
|
127
127
|
end
|
128
128
|
|
129
129
|
#-----------------------------------------------------------------------------
|
@@ -196,17 +196,10 @@ class Provisioner < CORL.plugin_class(:base)
|
|
196
196
|
success = yield(locations, package_info) if block_given?
|
197
197
|
|
198
198
|
if success
|
199
|
-
# Save the updates
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
success = network.save(config.import({
|
205
|
-
:commit => true,
|
206
|
-
:allow_empty => true,
|
207
|
-
:message => config.get(:message, "Built #{plugin_provider} provisioner #{plugin_name}"),
|
208
|
-
:remote => config.get(:remote, :edit)
|
209
|
-
}))
|
199
|
+
# Save the updates in the local project cache
|
200
|
+
set_cache_setting(:build_locations, locations.export)
|
201
|
+
set_cache_setting(:build_info, package_info.get([ :provisioners, plugin_provider ]))
|
202
|
+
set_cache_setting(:build_profiles, find_profiles)
|
210
203
|
end
|
211
204
|
end
|
212
205
|
success
|
data/lib/core/util/puppet.rb
CHANGED
@@ -270,10 +270,10 @@ module Puppet
|
|
270
270
|
value = puppet_scope.lookupvar("::#{search_property_name}")
|
271
271
|
Config.debug_lookup(config, search_property_name, value, "Puppet override lookup")
|
272
272
|
|
273
|
-
break unless
|
273
|
+
break unless value.nil?
|
274
274
|
end
|
275
275
|
end
|
276
|
-
if
|
276
|
+
if value.nil?
|
277
277
|
components = property.to_s.split('::')
|
278
278
|
|
279
279
|
if components.length > 1
|
@@ -284,7 +284,7 @@ module Puppet
|
|
284
284
|
Config.debug_lookup(config, search_property_name, value, "Puppet default lookup")
|
285
285
|
end
|
286
286
|
end
|
287
|
-
if
|
287
|
+
if value.nil? && search_name
|
288
288
|
value = puppet_scope.lookupvar("::#{property}")
|
289
289
|
Config.debug_lookup(config, property, value, "Puppet name lookup")
|
290
290
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module CORL
|
4
|
+
class BaseAction
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Constructor / Destructor
|
8
|
+
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@env = env[:machine].env
|
12
|
+
|
13
|
+
@network = nil
|
14
|
+
@node = nil
|
15
|
+
@vm = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
#-----------------------------------------------------------------------------
|
19
|
+
# Property accessor / modifiers
|
20
|
+
|
21
|
+
attr_reader :network, :node, :vm
|
22
|
+
|
23
|
+
#-----------------------------------------------------------------------------
|
24
|
+
# Action execution
|
25
|
+
|
26
|
+
def call(env)
|
27
|
+
# Hackish solution to ensure our code has access to Vagrant machines.
|
28
|
+
# This serves as a Vagrant VM manager.
|
29
|
+
::CORL::Vagrant.command = Command::Launcher.new([], @env)
|
30
|
+
|
31
|
+
if @network = ::CORL::Vagrant::Config.load_network(env[:root_path])
|
32
|
+
@vm = env[:machine]
|
33
|
+
@node = network.node(:vagrant, @vm.name) if @vm
|
34
|
+
yield if block_given? && @node
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module CORL
|
4
|
+
module Action
|
5
|
+
class CreateShares < BaseAction
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
super do
|
9
|
+
env[:ui].info I18n.t("corl.vagrant.actions.create_shares.start")
|
10
|
+
|
11
|
+
vm.communicate.tap do |comm|
|
12
|
+
# TODO: Figure out a better solution for remote network path.
|
13
|
+
# Needs to work before facter and corl are installed
|
14
|
+
# Local searches of remote configurations in the project perhaps?
|
15
|
+
network_path = ::CORL::Config.fact(:corl_network)
|
16
|
+
|
17
|
+
# Make sure the CORL network directory is properly set up
|
18
|
+
# Vagrant root (project) directory is shared by default
|
19
|
+
comm.sudo("rm -Rf #{network_path}")
|
20
|
+
comm.sudo("ln -s /vagrant #{network_path}")
|
21
|
+
end
|
22
|
+
@app.call env
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module CORL
|
4
|
+
module Action
|
5
|
+
class DeleteCache < BaseAction
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
super do
|
9
|
+
@app.call env
|
10
|
+
|
11
|
+
env[:ui].info I18n.t("corl.vagrant.actions.delete_cache.start")
|
12
|
+
node.clear_cache
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module VagrantPlugins
|
3
|
+
module CORL
|
4
|
+
module Action
|
5
|
+
class InitKeys < BaseAction
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
super do
|
9
|
+
env[:ui].info I18n.t("corl.vagrant.actions.init_keys.start")
|
10
|
+
|
11
|
+
if node.public_key
|
12
|
+
ssh_key = ::CORL::Util::Disk.read(node.public_key)
|
13
|
+
|
14
|
+
if ssh_key && ! ssh_key.empty?
|
15
|
+
vm.communicate.tap do |comm|
|
16
|
+
comm.execute("echo '#{ssh_key}' > \$HOME/.ssh/authorized_keys")
|
17
|
+
end
|
18
|
+
node.set_cache_setting(:use_private_key, true)
|
19
|
+
node.machine.load
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@app.call env
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -4,7 +4,7 @@ module CORL
|
|
4
4
|
module Command
|
5
5
|
class Launcher < ::Vagrant.plugin("2", :command)
|
6
6
|
|
7
|
-
include
|
7
|
+
include ::CORL::Parallel # Mainly for auto locking of resources
|
8
8
|
|
9
9
|
#-----------------------------------------------------------------------------
|
10
10
|
|
@@ -24,7 +24,7 @@ class Launcher < ::Vagrant.plugin("2", :command)
|
|
24
24
|
|
25
25
|
def execute
|
26
26
|
# Set the base command so we can access in any actions executed
|
27
|
-
::CORL::Vagrant.command =
|
27
|
+
::CORL::Vagrant.command = ::CORL.handle(self)
|
28
28
|
::CORL.executable(@argv - [ "--" ], "vagrant corl")
|
29
29
|
end
|
30
30
|
|
data/lib/core/vagrant/config.rb
CHANGED
@@ -81,11 +81,9 @@ module Config
|
|
81
81
|
end
|
82
82
|
|
83
83
|
# Provisioner configuration
|
84
|
-
unless configure_provisioner(network, node, machine)
|
84
|
+
unless configure_provisioner(network, node, machine, &code)
|
85
85
|
raise "Configuration of Vagrant provisioner failed: #{node_name}"
|
86
86
|
end
|
87
|
-
|
88
|
-
code.call(network, node, machine) if code
|
89
87
|
end
|
90
88
|
end
|
91
89
|
end
|
@@ -95,10 +93,7 @@ module Config
|
|
95
93
|
|
96
94
|
def self.load_network(directory)
|
97
95
|
# Load network if it exists
|
98
|
-
CORL.network(
|
99
|
-
:vagrant,
|
100
|
-
CORL.config(:vagrant_network, { :directory => directory, :name => directory })
|
101
|
-
)
|
96
|
+
@@network = CORL.network(directory, CORL.config(:vagrant_network, { :directory => directory }))
|
102
97
|
end
|
103
98
|
|
104
99
|
#---
|
@@ -272,14 +267,15 @@ module Config
|
|
272
267
|
|
273
268
|
#---
|
274
269
|
|
275
|
-
def self.configure_provisioner(network, node, machine)
|
270
|
+
def self.configure_provisioner(network, node, machine, &code)
|
276
271
|
success = true
|
277
272
|
|
278
273
|
# CORL provisioning
|
279
274
|
machine.vm.provision :corl do |provisioner|
|
280
|
-
provisioner.
|
281
|
-
provisioner.
|
282
|
-
|
275
|
+
provisioner.network = network
|
276
|
+
provisioner.node = node
|
277
|
+
|
278
|
+
code.call(node, machine, provisioner) if code
|
283
279
|
end
|
284
280
|
success
|
285
281
|
end
|