Skip to content

Commit

Permalink
Destroy vagrant hosts only if Vagrantfile exists
Browse files Browse the repository at this point in the history
The new `vagrant destroy --force` run during the vagrant hypervisors
`provision` method added in voxpupuli#48 seems to fail if no `Vagrantfile` has
ever been created for a nodeset. This fixes that.
  • Loading branch information
hunner committed Nov 21, 2013
1 parent 8d3fcbb commit f0c298f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/beaker/hypervisor/vagrant.rb
Expand Up @@ -98,7 +98,7 @@ def provision
if @options[:provision]
#setting up new vagrant hosts
#make sure that any old boxes are dead dead dead
vagrant_cmd("destroy --force")
vagrant_cmd("destroy --force") if File.file?(@vagrant_file)

make_vfile @vagrant_hosts

Expand Down
12 changes: 9 additions & 3 deletions spec/beaker/hypervisor/vagrant_spec.rb
Expand Up @@ -89,9 +89,7 @@ module Beaker
describe "provisioning and cleanup" do

before :each do
vagrant.should_receive( :make_vfile ).with( @hosts ).once

vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).once
FakeFS.activate!
vagrant.should_receive( :vagrant_cmd ).with( "up" ).once
@hosts.each do |host|
host_prev_name = host['user']
Expand All @@ -103,6 +101,14 @@ module Beaker
end

it "can provision a set of hosts" do
vagrant.should_receive( :make_vfile ).with( @hosts ).once
vagrant.should_receive( :vagrant_cmd ).with( "destroy --force" ).never
vagrant.provision
end

it "destroys an existing set of hosts before provisioning" do
vagrant.make_vfile(@hosts)
vagrant.should_receive(:vagrant_cmd).with("destroy --force").once
vagrant.provision
end

Expand Down

0 comments on commit f0c298f

Please sign in to comment.