diff --git a/lib/vagrant/action/builtin/provision.rb b/lib/vagrant/action/builtin/provision.rb index 007625510..b0e08ece6 100644 --- a/lib/vagrant/action/builtin/provision.rb +++ b/lib/vagrant/action/builtin/provision.rb @@ -62,10 +62,11 @@ module Vagrant if enabled type_map = provisioner_type_map(env) provisioner_instances(env).each do |p| + type_name = type_map[p] next if env[:provision_types] && \ - !env[:provision_types].include?(type_map[p]) + !env[:provision_types].include?(type_name) - run_provisioner(env, type_map[p].to_s, p) + run_provisioner(env, type_name.to_s, p) end end end diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 53ed9d06a..1f15b6c62 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -275,12 +275,12 @@ module Vagrant # @param [Action::Runner] action_runner A custom action runner for running hooks. def hook(name, opts=nil) @logger.info("Running hook: #{name}") - callable = Action::Builder.new opts ||= {} + opts[:callable] ||= Action::Builder.new opts[:runner] ||= action_runner opts[:action_name] = name opts[:env] = self - opts.delete(:runner).run(callable, opts) + opts.delete(:runner).run(opts.delete(:callable), opts) end # This returns a machine with the proper provider for this environment. diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb index 13ba2c9a3..d2b520a19 100644 --- a/test/unit/vagrant/environment_test.rb +++ b/test/unit/vagrant/environment_test.rb @@ -324,6 +324,14 @@ describe Vagrant::Environment do instance.hook(:foo, foo: :bar) end + + it "should allow passing a custom callable" do + instance.action_runner.should_receive(:run).with do |callable, env| + callable.should == :what + end + + instance.hook(:foo, callable: :what) + end end describe "primary machine name" do