diff --git a/CHANGELOG.md b/CHANGELOG.md index e59199eb2..28c82987c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ BUG FIXES: doesn't support byte ranges. [GH-4479] - core: Box downloads recognize more complex content types that include "application/json" [GH-4525] + - core: If all sub-machines are `autostart: false`, don't start any. [GH-4552] - commands/box: `--cert` flag works properly. [GH-4691] - command/docker-logs: Won't crash if container is removed. [GH-3990] - command/docker-run: Synced folders will be attached properly. [GH-3873] diff --git a/plugins/commands/up/command.rb b/plugins/commands/up/command.rb index 7fdb6eb3c..d7b3bd7dc 100644 --- a/plugins/commands/up/command.rb +++ b/plugins/commands/up/command.rb @@ -58,24 +58,37 @@ module VagrantPlugins @env.batch(options[:parallel]) do |batch| names = argv if names.empty? + autostart = false @env.vagrantfile.machine_names_and_options.each do |n, o| + autostart = true if o.has_key?(:autostart) o[:autostart] = true if !o.has_key?(:autostart) names << n.to_s if o[:autostart] end + + # If we have an autostart key but no names, it means that + # all machines are autostart: false and we don't start anything. + names = nil if autostart && names.empty? end - with_target_vms(names, provider: options[:provider]) do |machine| - @env.ui.info(I18n.t( - "vagrant.commands.up.upping", - name: machine.name, - provider: machine.provider_name)) + if names + with_target_vms(names, provider: options[:provider]) do |machine| + @env.ui.info(I18n.t( + "vagrant.commands.up.upping", + name: machine.name, + provider: machine.provider_name)) - machines << machine + machines << machine - batch.action(machine, :up, options) + batch.action(machine, :up, options) + end end end + if machines.empty? + @env.ui.info(I18n.t("vagrant.up_no_machines")) + return 0 + end + # Output the post-up messages that we have, if any machines.each do |m| next if !m.config.vm.post_up_message diff --git a/templates/locales/en.yml b/templates/locales/en.yml index f7fe6ac51..6acf81274 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -216,6 +216,10 @@ en: Error! Your console doesn't support hiding input. We'll ask for input again below, but we WILL NOT be able to hide input. If this is a problem for you, ctrl-C to exit and fix your stdin. + up_no_machines: |- + No machines to bring up. This is usually because all machines are + set to `autostart: false`, which means you have to explicitly specify + the name of the machine to bring up. upgrading_home_path_v1_5: |- Vagrant is upgrading some internal state for the latest version. Please do not quit Vagrant at this time. While upgrading, Vagrant