diff --git a/plugins/commands/reload/command.rb b/plugins/commands/reload/command.rb index 33a6f8e5e..1d43d13b7 100644 --- a/plugins/commands/reload/command.rb +++ b/plugins/commands/reload/command.rb @@ -30,7 +30,7 @@ module VagrantPlugins return if !argv # Validate the provisioners - validate_provisioner_flags!(options) + validate_provisioner_flags!(options, argv) @logger.debug("'reload' each target VM...") machines = [] diff --git a/plugins/commands/up/command.rb b/plugins/commands/up/command.rb index 826bea0ae..e340dad96 100644 --- a/plugins/commands/up/command.rb +++ b/plugins/commands/up/command.rb @@ -48,7 +48,7 @@ module VagrantPlugins return if !argv # Validate the provisioners - validate_provisioner_flags!(options) + validate_provisioner_flags!(options, argv) # Go over each VM and bring it up @logger.debug("'Up' each target VM...") diff --git a/plugins/commands/up/start_mixins.rb b/plugins/commands/up/start_mixins.rb index 548d889ca..8be96c68a 100644 --- a/plugins/commands/up/start_mixins.rb +++ b/plugins/commands/up/start_mixins.rb @@ -26,13 +26,22 @@ module VagrantPlugins # This validates the provisioner flags and raises an exception # if there are invalid ones. - def validate_provisioner_flags!(options) - (options[:provision_types] || []).each do |type| - klass = Vagrant.plugin("2").manager.provisioners[type] - if !klass - raise Vagrant::Errors::ProvisionerFlagInvalid, - name: type.to_s - end + def validate_provisioner_flags!(options, argv) + provisioner_instance_names = [] + with_target_vms(argv) do |machine| + provisioner_instance_names << machine.config.vm.provisioners.map(&:name) + end + + provisioner_instance_names.flatten!.uniq! + + if (provisioner_instance_names & options[:provision_types]).empty? + (options[:provision_types] || []).each do |type| + klass = Vagrant.plugin("2").manager.provisioners[type] + if !klass + raise Vagrant::Errors::ProvisionerFlagInvalid, + name: type.to_s + end + end end end end