diff --git a/lib/kitchen/driver/vagrant.rb b/lib/kitchen/driver/vagrant.rb index e849300d..3b2fb5bd 100644 --- a/lib/kitchen/driver/vagrant.rb +++ b/lib/kitchen/driver/vagrant.rb @@ -47,6 +47,8 @@ class Vagrant < Kitchen::Driver::Base default_config :box_version, nil + default_config :boot_timeout, nil + default_config :customize, {} default_config :gui, nil diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index b97fc009..cfe66a7c 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -210,6 +210,16 @@ def run_command(_cmd, options = {}) expect(driver[:box_version]).to eq("1.2.3") end + it "sets :boot_timeout to nil by default" do + expect(driver[:boot_timeout]).to eq(nil) + end + + it "sets :boot_timeout to a custom value" do + config[:boot_timeout] = 600 + + expect(driver[:boot_timeout]).to eq(600) + end + it "sets :customize to an empty hash by default" do expect(driver[:customize]).to eq({}) end @@ -918,6 +928,22 @@ def run_command(_cmd, options = {}) expect(vagrantfile).to match(regexify(%{c.vm.box_version = "a.b.c"})) end + it "sets no vm.boot_timeout if missing" do + config[:boot_timeout] = nil + cmd + + expect(vagrantfile).to_not match(regexify(%{c.vm.boot_timeout}, :partial)) + end + + it "sets no vm.boot_timeout if :boot_timeout is set" do + config[:boot_timeout] = 600 + cmd + + expect(vagrantfile).to match( + regexify(%{c.vm.boot_timeout = 600}, :partial) + ) + end + it "sets no vm.box_check_update if missing" do config[:box_check_update] = nil cmd diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index 6dc94431..f744a379 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -58,6 +58,10 @@ Vagrant.configure("2") do |c| <% end %> <% end %> +<% if config[:boot_timeout] %> + c.vm.boot_timeout = <%= config[:boot_timeout] %> +<% end %> + <% Array(config[:network]).each do |opts| %> c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>) <% end %>