Hi all, I am trying to build an AMI for bamboo elastic agents using packer. But it is stuck in "Waiting for WinRM to become available". I am using user data scripts and that works perfectly ok with other images.
Kindly assist what is missing in my scripts. Thanks Kishore -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/packer/issues IRC: #packer-tool on Freenode --- You received this message because you are subscribed to the Google Groups "Packer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/5f1ba574-92b1-491e-a6b2-842afaa957e4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
win2016-dotnet.json
Description: application/json
<powershell>
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore
# Don't set this before Set-ExecutionPolicy as it throws an error
$ErrorActionPreference = "Stop"
# Remove HTTP listener
Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse
$HostName = $env:computername
$cert = Get-ChildItem -Path cert:\LocalMachine\My\* -DnsName $HostName
-ErrorAction SilentlyContinue
if ($cert -eq $null)
{
$cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My
-DnsName $HostName
}
$thumbprint = $cert.Thumbprint
# Create the hashtables of settings to be used.
$valueset = @{}
$valueset.Add('Hostname', $env:COMPUTERNAME)
$valueset.Add('CertificateThumbprint', $thumbprint)
$selectorset = @{}
$selectorset.Add('Transport', 'HTTPS')
$selectorset.Add('Address', '*')
Write-Verbose "Enabling SSL listener."
New-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet
$selectorset -ValueSet $valueset | Out-Null
New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Name
'Windows Remote Management (HTTPS-In)' -Profile Any -LocalPort 5986 -Protocol
TCP | Out-Null
# Configure WinRM
Set-WSManInstance WinRM/Config -ValueSet @{MaxTimeoutms = 1800000} | Out-Null
Set-WSManInstance WinRM/Config/Service/Auth -ValueSet @{Basic = $true} |
Out-Null
Set-WSManInstance WinRM/Config/Service -ValueSet @{AllowUnencrypted = $true} |
Out-Null
Set-WSManInstance WinRM/Config/WinRS -ValueSet @{MaxMemoryPerShellMB = 1024} |
Out-Null
Set-WSManInstance WinRM/Config/Client -ValueSet @{TrustedHosts = "*"} | Out-Null
# Find and start the WinRM service.
Write-Verbose "Verifying WinRM service."
If (!(Get-Service "WinRM"))
{
Throw "Unable to find the WinRM service."
}
Else
{
Write-Verbose "Restarting WinRM service."
Restart-Service -Name "WinRM" -ErrorAction Stop
}
</powershell>
