Skip to content

Commit

Permalink
Merge pull request #232 from opscode/adamedx/auth-timeout-windows
Browse files Browse the repository at this point in the history
Enable configurability of timeout for Windows authentication
  • Loading branch information
Adam Edwards committed Aug 25, 2014
2 parents b828fad + 181cfdd commit a9a909f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/chef/knife/ec2_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ class Ec2ServerCreate < Knife
:proc => Proc.new { |key| Chef::Config[:knife][:provisioned_iops] = key },
:default => nil

option :auth_timeout,
:long => "--windows-auth-timeout MINUTES",
:description => "The maximum time in minutes to wait to for authentication over the transport to the node to succeed. The default value is 25 minutes.",
:default => 25

def run
$stdout.sync = true

Expand Down Expand Up @@ -320,7 +325,7 @@ def run
msg_pair("Tags", printed_tags)
msg_pair("SSH Key", @server.key_name)

print "\n#{ui.color("Waiting for instance", :magenta)}"
print "\n#{ui.color("Waiting for EC2 to create the instance", :magenta)}"

# wait for instance to come up before acting against it
@server.wait_for { print "."; ready? }
Expand Down Expand Up @@ -363,13 +368,13 @@ def run
config[:distro] = "windows-chef-client-msi" if (config[:distro].nil? || config[:distro] == "chef-full")
if protocol == 'winrm'
load_winrm_deps
print "\n#{ui.color("Waiting for winrm", :magenta)}"
print "\n#{ui.color("Waiting for winrm access to become available", :magenta)}"
print(".") until tcp_test_winrm(ssh_connect_host, locate_config_value(:winrm_port)) {
sleep 10
puts("done")
}
else
print "\n#{ui.color("Waiting for sshd", :magenta)}"
print "\n#{ui.color("Waiting for sshd access to become available", :magenta)}"
#If FreeSSHd, winsshd etc are available
print(".") until tcp_test_ssh(ssh_connect_host, config[:ssh_port]) {
sleep @initial_sleep_delay ||= (vpc_mode? ? 40 : 10)
Expand All @@ -379,7 +384,7 @@ def run
end
bootstrap_for_windows_node(@server, ssh_connect_host).run
else
print "\n#{ui.color("Waiting for sshd", :magenta)}"
print "\n#{ui.color("Waiting for sshd access to become available", :magenta)}"
wait_for_sshd(ssh_connect_host)
ssh_override_winrm
bootstrap_for_linux_node(@server, ssh_connect_host).run
Expand Down Expand Up @@ -475,6 +480,7 @@ def bootstrap_for_windows_node(server, fqdn)
bootstrap.config[:kerberos_service] = locate_config_value(:kerberos_service)
bootstrap.config[:ca_trust_file] = locate_config_value(:ca_trust_file)
bootstrap.config[:winrm_port] = locate_config_value(:winrm_port)
bootstrap.config[:auth_timeout] = locate_config_value(:auth_timeout)
elsif locate_config_value(:bootstrap_protocol) == 'ssh'
bootstrap = Chef::Knife::BootstrapWindowsSsh.new
bootstrap.config[:ssh_user] = locate_config_value(:ssh_user)
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/ec2_server_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,16 @@
it "configures sets the bootstrap's run_list" do
@bootstrap.config[:run_list].should == ['role[base]']
end

it "configures auth_timeout for bootstrap to default to 25 minutes" do
expect(@knife_ec2_create.options[:auth_timeout][:default]).to eq(25)
end

it "configures auth_timeout for bootstrap according to plugin auth_timeout config" do
@knife_ec2_create.config[:auth_timeout] = 5
bootstrap = @knife_ec2_create.bootstrap_for_windows_node(@new_ec2_server, @new_ec2_server.dns_name)
expect(bootstrap.config[:auth_timeout]).to eq(5)
end
end

describe "when validating the command-line parameters" do
Expand Down

0 comments on commit a9a909f

Please sign in to comment.