{ "variables": { "aws_region": "us-west-2", "vpc_id": "vpc-xxx", "subnet_id": "subnet-xxx" },
"builders": [{ "type": "amazon-ebs", "ami_name": "windows-jenkins-agent-with-docker {{isotime | clean_ami_name}}", "region": "{{user `aws_region`}}", "instance_type": "t2.medium",
"vpc_id": "{{user `vpc_id`}}", "subnet_id": "{{user `subnet_id`}}", "ssh_keypair_name": "key_pair_name_here", "ssh_private_key_file": "/full/path/to/file.pem",
"communicator": "winrm", "winrm_username": "Administrator", "winrm_use_ssl": true,
"source_ami_filter": { "owners": ["801119661308"], "most_recent": true,
"filters": { "virtualization-type": "hvm", "name": "*Windows_Server-2016-English-Full-Base*", "root-device-type": "ebs" } },
"run_tags": { "Name": "Packer-Temporary-Intance" },
"run_volume_tags": { "Name": "Packer-Temporary-Volume" },
"tags": { "OS_Version": "Windows", "Release": "2016 Base", "Source_AMI": "{{.SourceAMI}}", "Build_Region": "{{.BuildRegion}}" } }],
"provisioners": [ { "type": "file", "source": "files/chocolatey-install.ps1", "destination": "C:\\chocolatey-install.ps1" }, { "type": "file", "source": "files/init.ps1", "destination": "C:\\init.ps1" }, { "type": "file", "source": "files/WinSW.NET4.xml", "destination": "C:\\WinSW.NET4.xml" }, { "type": "windows-restart" } ]}
<powershell>
# This setup to get running via Powerhsell is taken from https://github.com/PeteGoo/packer-win-aws
write-output "Running User Data Script"write-host "(host) Running User Data Script"
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore
# Don't set this before Set-ExecutionPolicy as it throws an error$ErrorActionPreference = "stop"
# Remove HTTP listenerRemove-Item -Path WSMan:\Localhost\listener\listener* -Recurse
Set-Item WSMan:\localhost\MaxTimeoutms 1800000Set-Item WSMan:\localhost\Service\Auth\Basic $true
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer"New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force
# WinRMwrite-output "Setting up WinRM"write-host "(host) setting up WinRM"
cmd.exe /c winrm quickconfig -qcmd.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=HTTPS" "@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}"cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yescmd.exe /c netsh firewall add portopening TCP 5986 "Port 5986"cmd.exe /c net stop winrmcmd.exe /c sc config winrm start= autocmd.exe /c net start winrm
</powershell>
1) Why do I need a user-data script; why is this not just baked in?
Every time I touch Windows it's jumping hoop after hoop.
--
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 packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/2ea34afc-88c9-4972-8a15-fb2c886c315f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/6c3447c0-8954-4b61-b84c-e16c994d6838%40googlegroups.com.
--
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 packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/995c3699-0d60-4921-b9fd-3a6466f805b5%40googlegroups.com.