You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
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:
|