diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index eb268857..4970f900 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -938,6 +938,22 @@ expect(vagrantfile).to match(regexify(%{c.ssh.password = "okay"})) end + it "sets communicator.username if :communicator and :username are set" do + config[:communicator] = "wat" + config[:username] = "jdoe" + cmd + + expect(vagrantfile).to match(regexify(%{c.wat.username = "jdoe"})) + end + + it "sets communicator.password if :communicator and :password are set" do + config[:communicator] = "wat" + config[:password] = "okay" + cmd + + expect(vagrantfile).to match(regexify(%{c.wat.password = "okay"})) + end + it "sets no ssh.private_key_path if missing" do config[:ssh_key] = nil cmd diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index 86f387fa..833a93f0 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -30,18 +30,33 @@ Vagrant.configure("2") do |c| c.vm.guest = "<%= config[:guest] %>" <% end %> -<% if config[:username] %> - c.ssh.username = "<%= config[:username] %>" -<% end %> -<% if config[:password] %> - c.ssh.password = "<%= config[:password] %>" +<% if config[:communicator] %> + <% if config[:username] %> + c.<%= config[:communicator] %>.username = "<%= config[:username] %>" + <% end %> + <% if config[:password] %> + c.<%= config[:communicator] %>.password = "<%= config[:password] %>" + <% end %> +<% else %> + <% if config[:username] %> + c.ssh.username = "<%= config[:username] %>" + <% end %> + <% if config[:password] %> + c.ssh.password = "<%= config[:password] %>" + <% end %> <% end %> + <% if config[:ssh_key] %> c.ssh.private_key_path = "<%= config[:ssh_key] %>" <% end %> <% config[:ssh].each do |key, value| %> c.ssh.<%= key %> = <%= value %> <% end %> +<% if config[:winrm] %> + <% config[:winrm].each do |key, value| %> + c.winrm.<%= key %> = <%= value %> + <% end %> +<% end %> <% Array(config[:network]).each do |opts| %> c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)