From 30f8e7944ddb21ebbb17313912fd8db39aefa2f1 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 11 Nov 2020 09:39:07 -0800 Subject: [PATCH] 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 --- lib/vagrant/action/builder.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/builder.rb b/lib/vagrant/action/builder.rb index 76c21eeed..1c5ba8592 100644 --- a/lib/vagrant/action/builder.rb +++ b/lib/vagrant/action/builder.rb @@ -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)