Track raw actions as they are applied to prevent multiple insertions

The raw actions are used for applying the original trigger behavior
which can insert before and/or after the entire set of actions. When
processing the stack items, mark when the raw action has been applied
to prevent it from being applied again. Triggers around the raw actions
should only ever be applied _once_.

Fixes #12034
This commit is contained in:
Chris Roberts 2020-11-11 09:39:07 -08:00
parent f36ece40e2
commit 30f8e7944d

View File

@ -265,6 +265,7 @@ module Vagrant
# @param [Hash] env Call environment
# @return [Builder]
def apply_action_name(env)
env[:builder_raw_applied] ||= []
return self if !env[:action_name]
hook = Hook.new
@ -293,7 +294,9 @@ module Vagrant
# are the originally implemented trigger style. They run before
# and after specific provider actions (like :up, :halt, etc) and
# are different from true action triggers
if env[:triggers]
if env[:triggers] && !env[:builder_raw_applied].include?(env[:raw_action_name])
env[:builder_raw_applied] << env[:raw_action_name]
if !env[:triggers].find(env[:raw_action_name], :before, machine_name, :action, all: true).empty?
hook.prepend(Vagrant::Action::Builtin::Trigger,
env[:raw_action_name], env[:triggers], :before, :action, all: true)