Skip to content

Instantly share code, notes, and snippets.

@GloverChris
Created January 24, 2020 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GloverChris/d28280d41278d4a7753b77cc248ec2ac to your computer and use it in GitHub Desktop.
Save GloverChris/d28280d41278d4a7753b77cc248ec2ac to your computer and use it in GitHub Desktop.
Complete Debug log
{
"builders": [
{
"type": "amazon-ebs",
"region": "us-west-2",
"vpc_id": "redacted",
"subnet_id": "redacted",
"security_group_id": "redacted",
"instance_type": "t3a.large",
"ami_name": "tester {{timestamp}}",
"user_data_file": "./SetUpWinRM.ps1",
"communicator": "winrm",
"winrm_username": "twper",
"winrm_password": "SuperS3cr3t!!!!",
"winrm_insecure": true,
"associate_public_ip_address": true,
"winrm_port": 5985,
"winrm_timeout": "15m",
"source_ami_filter": {
"filters": {
"name": "Windows_Server-2016-English-Full-Base-*"
},
"owners": ["801119661308"],
"most_recent": true
}
}
]
}
2020/01/23 21:09:40 [INFO] Packer version: 1.5.1 [go1.13.5 windows amd64]
2020/01/23 21:09:40 Attempting to open config file: C:\Users\cglover\packer.config
2020/01/23 21:09:40 [WARN] Config file doesn't exist: C:\Users\cglover\packer.config
2020/01/23 21:09:40 Setting cache directory: C:\Users\cglover\workspace\follow_me\eIT-CSE_FollowMePrint\src\Packer\appserver\packer_cache
cannot determine if process is in background: Process background check error: not implemented yet
2020/01/23 21:09:40 Plugin could not be found at C:\ProgramData\chocolatey\lib\packer\tools\packer.exe-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebs (exec: "C:\\ProgramData\\chocolatey\\lib\\packer\\tools\\packer.exe-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebs": file does not exist). Checking same directory as executable.
2020/01/23 21:09:40 Current exe path: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe
2020/01/23 21:09:40 Creating plugin client for path: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe
2020/01/23 21:09:40 Starting plugin: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe []string{"C:\\ProgramData\\chocolatey\\lib\\packer\\tools\\packer.exe", "plugin", "packer-builder-amazon-ebs"}
2020/01/23 21:09:40 Waiting for RPC address for: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe
2020/01/23 21:09:40 packer.exe plugin: [INFO] Packer version: 1.5.1 [go1.13.5 windows amd64]
2020/01/23 21:09:40 packer.exe plugin: Attempting to open config file: C:\Users\cglover\packer.config
2020/01/23 21:09:40 packer.exe plugin: [WARN] Config file doesn't exist: C:\Users\cglover\packer.config
2020/01/23 21:09:40 packer.exe plugin: Setting cache directory: C:\Users\cglover\workspace\follow_me\eIT-CSE_FollowMePrint\src\Packer\appserver\packer_cache
2020/01/23 21:09:40 packer.exe plugin: args: []string{"packer-builder-amazon-ebs"}
2020/01/23 21:09:40 packer.exe plugin: Plugin port range: [10000,25000]
2020/01/23 21:09:40 packer.exe plugin: Plugin address: tcp 127.0.0.1:10000
2020/01/23 21:09:40 packer.exe plugin: Waiting for connection...
2020/01/23 21:09:40 Received tcp RPC address for C:\ProgramData\chocolatey\lib\packer\tools\packer.exe: addr is 127.0.0.1:10000
2020/01/23 21:09:40 packer.exe plugin: Serving a plugin connection...
2020/01/23 21:09:40 ui: Debug mode enabled. Builds will not be parallelized.
2020/01/23 21:09:40 ui: amazon-ebs: output will be in this color.
2020/01/23 21:09:40 ui:
2020/01/23 21:09:40 Build debug mode: true
2020/01/23 21:09:40 Force build: false
2020/01/23 21:09:40 On error:
2020/01/23 21:09:40 Preparing build: amazon-ebs
2020/01/23 21:09:40 Debug enabled, so waiting for build to finish: amazon-ebs
2020/01/23 21:09:40 Starting build run: amazon-ebs
2020/01/23 21:09:40 Running builder: amazon-ebs
2020/01/23 21:09:40 [INFO] (telemetry) Starting builder amazon-ebs
2020/01/23 21:09:40 packer.exe plugin: Found region us-west-2
2020/01/23 21:09:40 packer.exe plugin: [INFO] AWS Auth provider used: "SharedConfigCredentials: C:\\Users\\cglover\\.aws\\credentials"
2020/01/23 21:09:40 packer.exe plugin: [INFO] (aws): No AWS timeout and polling overrides have been set. Packer will default to waiter-specific delays and timeouts. If you would like to customize the length of time between retries and max number of retries you may do so by setting the environment variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS to your desired values.
2020/01/23 21:09:40 ui: ==> amazon-ebs: Prevalidating any provided VPC information
2020/01/23 21:09:40 ui: ==> amazon-ebs: Prevalidating AMI Name: tester 1579842580
2020/01/23 21:09:41 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue.
2020/01/23 21:09:42 packer.exe plugin: Using AMI Filters {
2020/01/23 21:09:42 packer.exe plugin: Filters: [{
2020/01/23 21:09:42 packer.exe plugin: Name: "name",
2020/01/23 21:09:42 packer.exe plugin: Values: ["Windows_Server-2016-English-Full-Base-*"]
2020/01/23 21:09:42 packer.exe plugin: }],
2020/01/23 21:09:42 packer.exe plugin: Owners: ["801119661308"]
2020/01/23 21:09:42 packer.exe plugin: }
2020/01/23 21:09:42 ui: amazon-ebs: Found Image ID: ami-09e71fb1baf16d0cd
2020/01/23 21:09:42 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
2020/01/23 21:09:43 packer.exe plugin: [INFO] Finding AZ and VpcId for the given subnet 'subnet-0e641265d0b299137'
2020/01/23 21:09:44 packer.exe plugin: [INFO] AvailabilityZone found: 'us-west-2a'
2020/01/23 21:09:44 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepNetworkInfo'. Press enter to continue.
2020/01/23 21:09:44 ui: ==> amazon-ebs: Creating temporary keypair: packer_5e2a7c14-13a7-146a-f9f6-696be127e8e8
2020/01/23 21:09:44 ui: amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
2020/01/23 21:09:44 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
2020/01/23 21:09:45 packer.exe plugin: Using specified security groups: [sg-07d3a5488a7afd978]
2020/01/23 21:09:45 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
2020/01/23 21:09:46 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepIamInstanceProfile'. Press enter to continue.
2020/01/23 21:09:46 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepCleanupVolumes'. Press enter to continue.
2020/01/23 21:09:47 packer.exe plugin: [DEBUG] base64 encoding user data...
2020/01/23 21:09:47 ui: ==> amazon-ebs: Launching a source AWS instance...
2020/01/23 21:09:47 ui: ==> amazon-ebs: Adding tags to source instance
2020/01/23 21:09:47 ui: amazon-ebs: Adding tag: "Name": "Packer Builder"
2020/01/23 21:09:48 ui: amazon-ebs: Instance ID: i-0a5de7ea9669d45b3
2020/01/23 21:09:48 ui: ==> amazon-ebs: Waiting for instance (i-0a5de7ea9669d45b3) to become ready...
2020/01/23 21:10:03 ui: amazon-ebs: Public DNS: ec2-34-211-35-242.us-west-2.compute.amazonaws.com
2020/01/23 21:10:03 ui: amazon-ebs: Public IP: 34.211.35.242
2020/01/23 21:10:03 ui: amazon-ebs: Private IP: 10.0.0.51
2020/01/23 21:10:03 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue.
2020/01/23 21:10:03 ui: ==> amazon-ebs: Skipping waiting for password since WinRM password set...
2020/01/23 21:10:03 ui: ask: ==> amazon-ebs: Pausing after run of step 'StepGetPassword'. Press enter to continue.
2020/01/23 21:10:03 ui: ==> amazon-ebs: Using winrm communicator to connect: 34.211.35.242
2020/01/23 21:10:03 packer.exe plugin: Waiting for WinRM, up to timeout: 15m0s
2020/01/23 21:10:03 ui: ==> amazon-ebs: Waiting for WinRM to become available...
2020/01/23 21:10:03 packer.exe plugin: Using ssh_host value: 34.211.35.242
2020/01/23 21:10:03 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/01/23 21:10:03 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/01/23 21:10:24 packer.exe plugin: [ERROR] connection error: unknown error Post http://34.211.35.242:5985/wsman: dial tcp 34.211.35.242:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2020/01/23 21:10:24 packer.exe plugin: [ERROR] WinRM connection err: unknown error Post http://34.211.35.242:5985/wsman: dial tcp 34.211.35.242:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2020/01/23 21:10:29 packer.exe plugin: Using ssh_host value: 34.211.35.242
2020/01/23 21:10:29 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/01/23 21:10:29 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/01/23 21:10:50 packer.exe plugin: [ERROR] connection error: unknown error Post http://34.211.35.242:5985/wsman: dial tcp 34.211.35.242:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2020/01/23 21:10:50 packer.exe plugin: [ERROR] WinRM connection err: unknown error Post http://34.211.35.242:5985/wsman: dial tcp 34.211.35.242:5985: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2020/01/23 21:10:55 packer.exe plugin: Using ssh_host value: 34.211.35.242
2020/01/23 21:10:55 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/01/23 21:10:55 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
# Install Chocolatey
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Globally Auto confirm every action
choco feature enable -n allowGlobalConfirmation
# Install .net 4.5.2
choco install netfx-4.5.2-devpack
# Install build tools 2015
choco install microsoft-build-tools --version 14.0.25420.1
choco install nuget.commandline
choco install nunit-console-runner
# Extension for generating results readable by Bamboo
choco install nunit-extension-nunit-v2-result-writer
choco install git
<powershell>
# Set administrator password
net user twper SuperS3cr3t!!!!
wmic useraccount where "name='twper'" set PasswordExpires=FALSE
# First, make sure WinRM can't be connected to
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=block
# Delete any existing WinRM listeners
winrm delete winrm/config/listener?Address=*+Transport=HTTP 2>$Null
winrm delete winrm/config/listener?Address=*+Transport=HTTPS 2>$Null
# Disable group policies which block basic authentication and unencrypted login
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WinRM\Client -Name AllowBasic -Value 1
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WinRM\Client -Name AllowUnencryptedTraffic -Value 1
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WinRM\Service -Name AllowBasic -Value 1
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WinRM\Service -Name AllowUnencryptedTraffic -Value 1
# Create a new WinRM listener and configure
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig '-transport:http'
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
write-output "Setting up WinRM"
write-host "(host) setting up WinRM"
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig '-transport:http'
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
# Configure UAC to allow privilege elevation in remote shells
$Key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
$Setting = 'LocalAccountTokenFilterPolicy'
Set-ItemProperty -Path $Key -Name $Setting -Value 1 -Force
# Configure and restart the WinRM Service; Enable the required firewall exception
Stop-Service -Name WinRM
Set-Service -Name WinRM -StartupType Automatic
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new action=allow localip=any remoteip=any
Start-Service -Name WinRM
</powershell>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment