Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add handling for winrm communicator in username & password handling #161

Merged
merged 4 commits into from
May 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
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