diff --git a/lib/vagrant/actions/vm/start.rb b/lib/vagrant/actions/vm/start.rb index 68c6474a4..8bf4e4229 100644 --- a/lib/vagrant/actions/vm/start.rb +++ b/lib/vagrant/actions/vm/start.rb @@ -6,7 +6,10 @@ module Vagrant # Start is a "meta-action" so it really just queues up a bunch # of other actions in its place: steps = [Boot] - steps.unshift([Customize, ForwardPorts, SharedFolders]) unless @runner.vm.saved? + if !@runner.vm || !@runner.vm.saved? + steps.unshift([Customize, ForwardPorts, SharedFolders]) + steps << Provision if !@runner.env.config.vm.provisioner.nil? + end steps.flatten.each do |action_klass| @runner.add_action(action_klass) diff --git a/lib/vagrant/actions/vm/up.rb b/lib/vagrant/actions/vm/up.rb index 80a62f114..65b8ea6ff 100644 --- a/lib/vagrant/actions/vm/up.rb +++ b/lib/vagrant/actions/vm/up.rb @@ -10,8 +10,7 @@ module Vagrant # Up is a "meta-action" so it really just queues up a bunch # of other actions in its place: - steps = [Import, Customize, ForwardPorts, SharedFolders, Boot] - steps << Provision if !@runner.env.config.vm.provisioner.nil? + steps = [Import, Start] steps.insert(0, MoveHardDrive) if @runner.env.config.vm.hd_location steps.each do |action_klass| diff --git a/test/vagrant/actions/vm/start_test.rb b/test/vagrant/actions/vm/start_test.rb index a64474e09..a7dc8fd24 100644 --- a/test/vagrant/actions/vm/start_test.rb +++ b/test/vagrant/actions/vm/start_test.rb @@ -31,5 +31,22 @@ class StartActionTest < Test::Unit::TestCase setup_action_expectations @action.prepare end + + should "add do additional if VM is not created yet" do + @mock_vm.stubs(:vm).returns(nil) + @default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders]) + setup_action_expectations + @action.prepare + end + + should "add provisioning if its enabled and not saved" do + @vm.env.config.vm.provisioner = :chef_solo + + @mock_vm.stubs(:vm).returns(nil) + @default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders]) + @default_order << Vagrant::Actions::VM::Provision + setup_action_expectations + @action.prepare + end end end diff --git a/test/vagrant/actions/vm/up_test.rb b/test/vagrant/actions/vm/up_test.rb index ff63eabdb..c7fde915d 100644 --- a/test/vagrant/actions/vm/up_test.rb +++ b/test/vagrant/actions/vm/up_test.rb @@ -9,7 +9,7 @@ class UpActionTest < Test::Unit::TestCase setup do File.stubs(:file?).returns(true) File.stubs(:exist?).returns(true) - @default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Boot] + @default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Start] @dotfile_path = "foo" @runner.env.stubs(:dotfile_path).returns(@dotfile_path) @@ -47,19 +47,6 @@ class UpActionTest < Test::Unit::TestCase @action.prepare end - should "add in the provisioning step if enabled" do - env = mock_environment do |config| - config.vm.provisioner = "foo" - end - - @runner.stubs(:env).returns(env) - env.stubs(:dotfile_path).returns(@dotfile_path) - - @default_order.push(Vagrant::Actions::VM::Provision) - setup_action_expectations - @action.prepare - end - should "add in the action to move hard drive if config is set" do env = mock_environment do |config| File.expects(:directory?).with("foo").returns(true)