diff --git a/lib/vagrant/action/builtin/provision.rb b/lib/vagrant/action/builtin/provision.rb index cb3caaae0..c13198e12 100644 --- a/lib/vagrant/action/builtin/provision.rb +++ b/lib/vagrant/action/builtin/provision.rb @@ -20,10 +20,20 @@ module Vagrant enabled = true enabled = env[:provision_enabled] if env.has_key?(:provision_enabled) + # This keeps track of a mapping between provisioner and type + type_map = {} + # Get all the configured provisioners provisioners = env[:machine].config.vm.provisioners.map do |provisioner| - klass = Vagrant.plugin("2").manager.provisioners[provisioner.name] - klass.new(env[:machine], provisioner.config) + # Instantiate the provisioner + klass = Vagrant.plugin("2").manager.provisioners[provisioner.name] + result = klass.new(env[:machine], provisioner.config) + + # Store in the type map so that --provision-with works properly + type_map[result] = provisioner.name + + # Return the result + result end # Ask the provisioners to modify the configuration if needed @@ -37,6 +47,9 @@ module Vagrant # Actually provision if we enabled it if enabled provisioners.each do |p| + next if env[:provision_types] && \ + !env[:provision_types].include?(type_map[p]) + env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning", :provisioner => p.class)) diff --git a/plugins/commands/up/start_mixins.rb b/plugins/commands/up/start_mixins.rb index d4a2ed0ee..289a9e950 100644 --- a/plugins/commands/up/start_mixins.rb +++ b/plugins/commands/up/start_mixins.rb @@ -9,7 +9,7 @@ module VagrantPlugins def build_start_options(parser, options) # Setup the defaults options[:provision_enabled] = true - options["provision.types"] = nil + options[:provision_types] = nil # Add the options parser.on("--[no-]provision", "Enable or disable provisioning") do |p| @@ -18,7 +18,7 @@ module VagrantPlugins parser.on("--provision-with x,y,z", Array, "Enable only certain provisioners, by type.") do |list| - options["provision.types"] = list + options[:provision_types] = list end end end