bootstrap.rb
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'erb'
module Vagrant
module Lxd
module Action
class Bootstrap
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::lxd::action::bootstrap")
end
def call(env)
driver = env[:machine].provider.driver
bs_data = env[:machine].box.metadata["bootstrap"]
bs_data.each do |name, actions|
env[:ui].info "--- Bootstrap #{name} ---", :prefix => false
actions.each do |action, data|
# right now I do not handle differnet actions just return if
# action is not "exec".
next if action != "exec"
container = driver.name
hostname = env[:machine].name
data.each do |d|
d.collect! { |element| ERB.new(element).result(binding) }
env[:ui].info "--- #{action}: #{d.inspect} ---",
:prefix => false
driver.exec(*d, :retryable => true)
end
end
end
driver.restart
@app.call(env)
end
end
end
end
end
# vim: set et ts=2 sw=2: