Skip to content

Commit

Permalink
Merge pull request #161 from atiniir/master
Browse files Browse the repository at this point in the history
Add handling for winrm communicator in username & password handling
  • Loading branch information
fnichol committed May 7, 2015
2 parents 0983ba5 + a879e6d commit 6b3e046
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
16 changes: 16 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 20 additions & 5 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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(", ") %>)
Expand Down

0 comments on commit 6b3e046

Please sign in to comment.