From 3007fdec98e5c60951ade42669b7e31cd1dcb4b9 Mon Sep 17 00:00:00 2001 From: Kristan Stewart Date: Sat, 11 Apr 2015 21:43:38 -0700 Subject: [PATCH 1/4] add handling for winrm communicator in username & password handling --- templates/Vagrantfile.erb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index 86f387fa..daacdb49 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -31,10 +31,10 @@ Vagrant.configure("2") do |c| <% end %> <% if config[:username] %> - c.ssh.username = "<%= config[:username] %>" + c.<%= config[:communicator] %>.username = "<%= config[:username] %>" <% end %> <% if config[:password] %> - c.ssh.password = "<%= config[:password] %>" + c.<%= config[:communicator] %>.password = "<%= config[:password] %>" <% end %> <% if config[:ssh_key] %> c.ssh.private_key_path = "<%= config[:ssh_key] %>" @@ -42,6 +42,11 @@ Vagrant.configure("2") do |c| <% 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(", ") %>) From ce72ca177b81acdef93d37d07807b3f200f22429 Mon Sep 17 00:00:00 2001 From: Kristan Date: Tue, 14 Apr 2015 13:53:37 -0700 Subject: [PATCH 2/4] weak fix for spec failures (bad test on ssh.username and ssh.password because communicator: isn't always set and (apparently) doesn't default to something --- templates/Vagrantfile.erb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index daacdb49..56db968d 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -30,12 +30,26 @@ Vagrant.configure("2") do |c| c.vm.guest = "<%= config[:guest] %>" <% end %> -<% if config[:username] %> - c.<%= config[:communicator] %>.username = "<%= config[:username] %>" -<% end %> -<% if config[:password] %> - c.<%= config[:communicator] %>.password = "<%= config[:password] %>" + + +<% if config[:communicator] == "winrm" %> + <% if config[:username] %> + c.winrm.username = "<%= config[:username] %>" + <% end %> + <% if config[:password] %> + c.winrm.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 %> From 855c1de736741cfde1d690d72374be5ffa05ca39 Mon Sep 17 00:00:00 2001 From: Kristan Date: Tue, 14 Apr 2015 14:14:12 -0700 Subject: [PATCH 3/4] update template to create username and password within communicator scope if a communicator is set., if no communicator is set ssh is assumed add spec test for username and password communicator scope if communicator is set --- spec/kitchen/driver/vagrant_spec.rb | 16 ++++++++++++++++ templates/Vagrantfile.erb | 10 +++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index e994de61..c240444f 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -935,6 +935,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 56db968d..833a93f0 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -30,14 +30,12 @@ Vagrant.configure("2") do |c| c.vm.guest = "<%= config[:guest] %>" <% end %> - - -<% if config[:communicator] == "winrm" %> +<% if config[:communicator] %> <% if config[:username] %> - c.winrm.username = "<%= config[:username] %>" + c.<%= config[:communicator] %>.username = "<%= config[:username] %>" <% end %> <% if config[:password] %> - c.winrm.password = "<%= config[:password] %>" + c.<%= config[:communicator] %>.password = "<%= config[:password] %>" <% end %> <% else %> <% if config[:username] %> @@ -48,8 +46,6 @@ Vagrant.configure("2") do |c| <% end %> <% end %> - - <% if config[:ssh_key] %> c.ssh.private_key_path = "<%= config[:ssh_key] %>" <% end %> From a879e6d98354f8dbaccc8cd92e4f5c8e8ff3234e Mon Sep 17 00:00:00 2001 From: Kristan Date: Tue, 14 Apr 2015 14:42:04 -0700 Subject: [PATCH 4/4] remove trailing space that caused build failure --- spec/kitchen/driver/vagrant_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index c240444f..e8c0608b 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -941,7 +941,7 @@ cmd expect(vagrantfile).to match(regexify(%{c.wat.username = "jdoe"})) - end + end it "sets communicator.password if :communicator and :password are set" do config[:communicator] = "wat" @@ -949,7 +949,7 @@ cmd expect(vagrantfile).to match(regexify(%{c.wat.password = "okay"})) - end + end it "sets no ssh.private_key_path if missing" do config[:ssh_key] = nil