modules/mu/groomers/chef.rb in cloud-mu-3.1.4 vs modules/mu/groomers/chef.rb in cloud-mu-3.1.5
- old
+ new
@@ -327,11 +327,11 @@
end
}
}
else
MU.log "Invoking Chef over WinRM on #{@server.mu_name}: #{purpose}"
- winrm = @server.getWinRMSession(haveBootstrapped? ? 1 : max_retries)
+ winrm = @server.getWinRMSession(haveBootstrapped? ? 2 : max_retries)
if @server.windows? and @server.windowsRebootPending?(winrm)
# Windows frequently gets stuck here
if retries > 5
@server.reboot(true)
elsif retries > 3
@@ -413,13 +413,13 @@
end
if retries < max_retries
retries += 1
MU.log "#{@server.mu_name}: Chef run '#{purpose}' failed after #{Time.new - runstart} seconds, retrying (#{retries}/#{max_retries})", MU::WARN, details: e.message.dup
- if purpose != "Base Windows configuration"
- windows_try_ssh = !windows_try_ssh
- end
+# if purpose != "Base Windows configuration"
+# windows_try_ssh = !windows_try_ssh
+# end
if e.is_a?(WinRM::WinRMError)
if @server.windows? and retries >= 3 and retries % 3 == 0
# Mix in a hard reboot if WinRM isn't answering
@server.reboot(true)
end
@@ -621,12 +621,18 @@
kb.config[:winrm_transport] = :ssl
kb.config[:host] = @server.mu_name
kb.config[:winrm_port] = 5986
kb.config[:session_timeout] = timeout
kb.config[:operation_timeout] = timeout
- kb.config[:winrm_authentication_protocol] = :cert
- kb.config[:winrm_client_cert] = "#{MU.mySSLDir}/#{@server.mu_name}-winrm.crt"
- kb.config[:winrm_client_key] = "#{MU.mySSLDir}/#{@server.mu_name}-winrm.key"
+ if retries % 2 == 0
+ kb.config[:winrm_authentication_protocol] = :basic
+ kb.config[:winrm_user] = @server.config['windows_admin_username']
+ kb.config[:winrm_password] = @server.getWindowsAdminPassword
+ else
+ kb.config[:winrm_authentication_protocol] = :cert
+ kb.config[:winrm_client_cert] = "#{MU.mySSLDir}/#{@server.mu_name}-winrm.crt"
+ kb.config[:winrm_client_key] = "#{MU.mySSLDir}/#{@server.mu_name}-winrm.key"
+ end
# kb.config[:ca_trust_file] = "#{MU.mySSLDir}/Mu_CA.pem"
# XXX ca_trust_file doesn't work for some reason, so we have to set the below for now
kb.config[:winrm_ssl_verify_mode] = :verify_none
kb.config[:msi_url] = "https://www.chef.io/chef/download?p=windows&pv=2012&m=x86_64&v=#{MU.chefVersion}"
end