Allow provisioner instance names to be specified for `up` and `reload` commands and option `--provision-with`
Ref: https://github.com/mitchellh/vagrant/issues/5139
This commit is contained in:
parent
bac5d039db
commit
209556c3cd
|
@ -30,7 +30,7 @@ module VagrantPlugins
|
||||||
return if !argv
|
return if !argv
|
||||||
|
|
||||||
# Validate the provisioners
|
# Validate the provisioners
|
||||||
validate_provisioner_flags!(options)
|
validate_provisioner_flags!(options, argv)
|
||||||
|
|
||||||
@logger.debug("'reload' each target VM...")
|
@logger.debug("'reload' each target VM...")
|
||||||
machines = []
|
machines = []
|
||||||
|
|
|
@ -48,7 +48,7 @@ module VagrantPlugins
|
||||||
return if !argv
|
return if !argv
|
||||||
|
|
||||||
# Validate the provisioners
|
# Validate the provisioners
|
||||||
validate_provisioner_flags!(options)
|
validate_provisioner_flags!(options, argv)
|
||||||
|
|
||||||
# Go over each VM and bring it up
|
# Go over each VM and bring it up
|
||||||
@logger.debug("'Up' each target VM...")
|
@logger.debug("'Up' each target VM...")
|
||||||
|
|
|
@ -26,13 +26,22 @@ module VagrantPlugins
|
||||||
|
|
||||||
# This validates the provisioner flags and raises an exception
|
# This validates the provisioner flags and raises an exception
|
||||||
# if there are invalid ones.
|
# if there are invalid ones.
|
||||||
def validate_provisioner_flags!(options)
|
def validate_provisioner_flags!(options, argv)
|
||||||
(options[:provision_types] || []).each do |type|
|
provisioner_instance_names = []
|
||||||
klass = Vagrant.plugin("2").manager.provisioners[type]
|
with_target_vms(argv) do |machine|
|
||||||
if !klass
|
provisioner_instance_names << machine.config.vm.provisioners.map(&:name)
|
||||||
raise Vagrant::Errors::ProvisionerFlagInvalid,
|
end
|
||||||
name: type.to_s
|
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue