core: allow provisioner cleanup to happen after call
This commit is contained in:
parent
c8be50c69e
commit
0e20c51c7f
|
@ -10,14 +10,23 @@ module Vagrant
|
||||||
class ProvisionerCleanup
|
class ProvisionerCleanup
|
||||||
include MixinProvisioners
|
include MixinProvisioners
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env, place=nil)
|
||||||
@app = app
|
@app = app
|
||||||
@logger = Log4r::Logger.new("vagrant::action::builtin::provision_cleanup")
|
@logger = Log4r::Logger.new("vagrant::action::builtin::provision_cleanup")
|
||||||
|
@place ||= :after
|
||||||
|
@place = @place.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
@env = env
|
do_cleanup(env) if @place == :before
|
||||||
|
|
||||||
|
# Continue, we need the VM to be booted.
|
||||||
|
@app.call(env)
|
||||||
|
|
||||||
|
do_cleanup(env) if @place == :after
|
||||||
|
end
|
||||||
|
|
||||||
|
def do_cleanup(env)
|
||||||
# Ask the provisioners to modify the configuration if needed
|
# Ask the provisioners to modify the configuration if needed
|
||||||
provisioner_instances.each do |p|
|
provisioner_instances.each do |p|
|
||||||
env[:ui].info(I18n.t(
|
env[:ui].info(I18n.t(
|
||||||
|
@ -25,9 +34,6 @@ module Vagrant
|
||||||
name: provisioner_type_map[p].to_s))
|
name: provisioner_type_map[p].to_s))
|
||||||
p.cleanup
|
p.cleanup
|
||||||
end
|
end
|
||||||
|
|
||||||
# Continue, we need the VM to be booted.
|
|
||||||
@app.call(env)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue