├── .gitignore ├── LICENSE ├── README.md ├── bootstrap ├── aws │ └── userdata │ │ └── bootstrap-aws.txt └── vmware │ └── answer_files │ └── 2012r2 │ └── Autounattend.xml ├── provisioners ├── ansible │ ├── java8-packer.yml │ └── roles │ │ └── java8 │ │ ├── defaults │ │ └── main.yml │ │ └── tasks │ │ └── main.yml └── powershell │ ├── configure-winrm.ps1 │ ├── defrag-c.ps1 │ ├── disable-uac.ps1 │ ├── install-chocolatey.ps1 │ ├── install-iis.ps1 │ ├── sysprep-bundleconfig.ps1 │ └── sysprep-ec2config.ps1 └── templates ├── ubuntu-1404 ├── http │ └── preseed.cfg └── virtualbox-ubuntu.json └── windows-server-2012 ├── aws-win2012R2-apibox.json ├── aws-win2012R2-servicebox.json ├── virtualbox-2012R2-servicebox.json └── vmware-2012R2-servicebox.json /.gitignore: -------------------------------------------------------------------------------- 1 | # VmWare output 2 | output-vmware* 3 | 4 | # Packer ISO download cache 5 | packer_cache/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ricard Clau 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repo contains some examples for building AWS AMIs and VMWare templates using Packer 2 | 3 | # Folder structure 4 | 5 | The packer code is structured as follows: 6 | 7 | - **bootstrap**: This folder contains bootstrap scripts for AWS and VMWare. 8 | - **files**: This folder contains static files. 9 | - **provisioners**: This folder contains provisioning Powershell scripts, Ansible playbooks, etc. 10 | - **templates**: This folder contains the Packer templates. Each template sub-folder should contain a ```README.md``` explaining the usage of the template. 11 | 12 | # How to use the templates 13 | 14 | ## VMWare 15 | 16 | - Install either VMWare Fusion if you are using MacOSx or VMWare Workstation if you are using Windows or Linux 17 | - Run `packer build templates/windows-server-2012/vmware-2012R2-servicebox.json` 18 | 19 | ## AWS AMIs 20 | 21 | - Create a VPC with at least a subnet where you will run the instance to build the AMI 22 | - Create a Security group allowing ports 3389 (RDP) and 5985 (WinRM) 23 | - Run `packer build -var 'aws_access_key=YOUR_KEY' -var 'aws_secret_key=YOUR_SECRET' -var 'subnet_id=subnet-XXXXXX' -var 'security_group_id=sg-YYYYYY' templates/windows-server-2012/aws-win2012R2-servicebox.json` or if you have the AWS CLI tool configure with an ~/.aws/credentials file you can omit the aws credentals parameters 24 | -------------------------------------------------------------------------------- /bootstrap/aws/userdata/bootstrap-aws.txt: -------------------------------------------------------------------------------- 1 | 2 | # turn off PowerShell execution policy restrictions 3 | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine 4 | 5 | # configure WinRM 6 | winrm quickconfig -q 7 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}' 8 | winrm set winrm/config '@{MaxTimeoutms="7200000"}' 9 | winrm set winrm/config/service '@{AllowUnencrypted="true"}' 10 | winrm set winrm/config/service/auth '@{Basic="true"}' 11 | 12 | # open port 5985 in the internal Windows firewall to allow WinRM communication 13 | netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow 14 | 15 | # restart WinRM 16 | net stop winrm 17 | sc config winrm start=auto 18 | net start winrm 19 | -------------------------------------------------------------------------------- /bootstrap/vmware/answer_files/2012r2/Autounattend.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | en-US 7 | 8 | 9 | 0809:00000809 10 | en-GB 11 | en-US 12 | en-US 13 | en-GB 14 | 15 | 16 | 17 | 18 | 19 | 20 | Primary 21 | 1 22 | 350 23 | 24 | 25 | 2 26 | Primary 27 | true 28 | 29 | 30 | 31 | 32 | true 33 | NTFS 34 | 35 | 1 36 | 1 37 | 38 | 39 | NTFS 40 | 41 | C 42 | 2 43 | 2 44 | 45 | 46 | 0 47 | true 48 | 49 | 50 | 51 | 52 | 53 | 54 | /IMAGE/NAME 55 | Windows Server 2012 R2 SERVERSTANDARD 56 | 57 | 58 | 59 | 0 60 | 2 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | OnError 71 | 72 | true 73 | Vagrant 74 | Vagrant 75 | 76 | 77 | 78 | 79 | 80 | 81 | false 82 | 83 | vagrant-2012-r2 84 | GMT Standard Time 85 | 86 | 87 | 88 | true 89 | 90 | 91 | false 92 | false 93 | 94 | 95 | true 96 | 97 | 98 | false 99 | 100 | 101 | 102 | false 103 | 104 | 105 | 106 | 107 | true 108 | @FirewallAPI.dll,-28752 109 | all 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | vagrant 119 | true</PlainText> 120 | </Password> 121 | <Enabled>true</Enabled> 122 | <LogonCount>2</LogonCount> 123 | <Username>Administrator</Username> 124 | </AutoLogon> 125 | <FirstLogonCommands> 126 | <SynchronousCommand wcm:action="add"> 127 | <CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> 128 | <Description>Set Execution Policy 64 Bit</Description> 129 | <Order>1</Order> 130 | <RequiresUserInput>true</RequiresUserInput> 131 | </SynchronousCommand> 132 | <SynchronousCommand wcm:action="add"> 133 | <CommandLine>C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine> 134 | <Description>Set Execution Policy 32 Bit</Description> 135 | <Order>2</Order> 136 | <RequiresUserInput>true</RequiresUserInput> 137 | </SynchronousCommand> 138 | <SynchronousCommand wcm:action="add"> 139 | <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine> 140 | <Description>winrm quickconfig -q</Description> 141 | <Order>3</Order> 142 | <RequiresUserInput>true</RequiresUserInput> 143 | </SynchronousCommand> 144 | <SynchronousCommand wcm:action="add"> 145 | <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine> 146 | <Description>winrm quickconfig -transport:http</Description> 147 | <Order>4</Order> 148 | <RequiresUserInput>true</RequiresUserInput> 149 | </SynchronousCommand> 150 | <SynchronousCommand wcm:action="add"> 151 | <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine> 152 | <Description>Win RM MaxTimoutms</Description> 153 | <Order>5</Order> 154 | <RequiresUserInput>true</RequiresUserInput> 155 | </SynchronousCommand> 156 | <SynchronousCommand wcm:action="add"> 157 | <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="800"}</CommandLine> 158 | <Description>Win RM MaxMemoryPerShellMB</Description> 159 | <Order>6</Order> 160 | <RequiresUserInput>true</RequiresUserInput> 161 | </SynchronousCommand> 162 | <SynchronousCommand wcm:action="add"> 163 | <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine> 164 | <Description>Win RM AllowUnencrypted</Description> 165 | <Order>7</Order> 166 | <RequiresUserInput>true</RequiresUserInput> 167 | </SynchronousCommand> 168 | <SynchronousCommand wcm:action="add"> 169 | <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine> 170 | <Description>Win RM auth Basic</Description> 171 | <Order>8</Order> 172 | <RequiresUserInput>true</RequiresUserInput> 173 | </SynchronousCommand> 174 | <SynchronousCommand wcm:action="add"> 175 | <CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine> 176 | <Description>Win RM client auth Basic</Description> 177 | <Order>9</Order> 178 | <RequiresUserInput>true</RequiresUserInput> 179 | </SynchronousCommand> 180 | <SynchronousCommand wcm:action="add"> 181 | <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine> 182 | <Description>Win RM listener Address/Port</Description> 183 | <Order>10</Order> 184 | <RequiresUserInput>true</RequiresUserInput> 185 | </SynchronousCommand> 186 | <SynchronousCommand wcm:action="add"> 187 | <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine> 188 | <Description>Win RM adv firewall enable</Description> 189 | <Order>11</Order> 190 | <RequiresUserInput>true</RequiresUserInput> 191 | </SynchronousCommand> 192 | <SynchronousCommand wcm:action="add"> 193 | <CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine> 194 | <Description>Win RM port open</Description> 195 | <Order>12</Order> 196 | <RequiresUserInput>true</RequiresUserInput> 197 | </SynchronousCommand> 198 | <SynchronousCommand wcm:action="add"> 199 | <CommandLine>cmd.exe /c net stop winrm </CommandLine> 200 | <Description>Stop Win RM Service </Description> 201 | <Order>13</Order> 202 | <RequiresUserInput>true</RequiresUserInput> 203 | </SynchronousCommand> 204 | <SynchronousCommand wcm:action="add"> 205 | <CommandLine>cmd.exe /c sc config winrm start= auto</CommandLine> 206 | <Description>Win RM Autostart</Description> 207 | <Order>14</Order> 208 | <RequiresUserInput>true</RequiresUserInput> 209 | </SynchronousCommand> 210 | <SynchronousCommand wcm:action="add"> 211 | <CommandLine>cmd.exe /c net start winrm</CommandLine> 212 | <Description>Start Win RM Service</Description> 213 | <Order>15</Order> 214 | <RequiresUserInput>true</RequiresUserInput> 215 | </SynchronousCommand> 216 | <SynchronousCommand wcm:action="add"> 217 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine> 218 | <Order>16</Order> 219 | <Description>Show file extensions in Explorer</Description> 220 | </SynchronousCommand> 221 | <SynchronousCommand wcm:action="add"> 222 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine> 223 | <Order>17</Order> 224 | <Description>Enable QuickEdit mode</Description> 225 | </SynchronousCommand> 226 | <SynchronousCommand wcm:action="add"> 227 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine> 228 | <Order>18</Order> 229 | <Description>Show Run command in Start Menu</Description> 230 | </SynchronousCommand> 231 | <SynchronousCommand wcm:action="add"> 232 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine> 233 | <Order>19</Order> 234 | <Description>Show Administrative Tools in Start Menu</Description> 235 | </SynchronousCommand> 236 | <SynchronousCommand wcm:action="add"> 237 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine> 238 | <Order>20</Order> 239 | <Description>Zero Hibernation File</Description> 240 | </SynchronousCommand> 241 | <SynchronousCommand wcm:action="add"> 242 | <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine> 243 | <Order>21</Order> 244 | <Description>Disable Hibernation Mode</Description> 245 | </SynchronousCommand> 246 | <SynchronousCommand wcm:action="add"> 247 | <CommandLine>cmd.exe /c powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c</CommandLine> 248 | <Order>22</Order> 249 | <Description>Power plan set to High Performance</Description> 250 | </SynchronousCommand> 251 | </FirstLogonCommands> 252 | <OOBE> 253 | <HideEULAPage>true</HideEULAPage> 254 | <HideLocalAccountScreen>true</HideLocalAccountScreen> 255 | <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> 256 | <HideOnlineAccountScreens>true</HideOnlineAccountScreens> 257 | <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> 258 | <NetworkLocation>Home</NetworkLocation> 259 | <ProtectYourPC>1</ProtectYourPC> 260 | </OOBE> 261 | <UserAccounts> 262 | <AdministratorPassword> 263 | <Value>vagrant</Value> 264 | <PlainText>true</PlainText> 265 | </AdministratorPassword> 266 | </UserAccounts> 267 | <RegisteredOwner/> 268 | </component> 269 | </settings> 270 | <settings pass="offlineServicing"> 271 | <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> 272 | <EnableLUA>false</EnableLUA> 273 | </component> 274 | </settings> 275 | <cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="wim:c:/wim/install.wim#Windows Server 2012 R2 SERVERSTANDARD"/> 276 | </unattend> -------------------------------------------------------------------------------- /provisioners/ansible/java8-packer.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Java8 install 3 | hosts: all 4 | become: True 5 | become_method: sudo 6 | become_user: root 7 | remote_user: vagrant 8 | 9 | roles: 10 | - java8 -------------------------------------------------------------------------------- /provisioners/ansible/roles/java8/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # The repo/ppa that this role is designed to work with 3 | java8_java_repo: "ppa:openjdk-r/ppa" 4 | # As above. Choose openjdk-8, openjdk-7 etc - from 6 to 9 5 | java8_java_package: "openjdk-8-jre" -------------------------------------------------------------------------------- /provisioners/ansible/roles/java8/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Configure Java PPA 3 | apt_repository: 4 | repo: "{{ java8_java_repo }}" 5 | state: present 6 | update_cache: yes 7 | 8 | - name: Install Java 9 | apt: 10 | name: "{{ java8_java_package }}" 11 | state: present 12 | update_cache: yes -------------------------------------------------------------------------------- /provisioners/powershell/configure-winrm.ps1: -------------------------------------------------------------------------------- 1 | 2 | winrm quickconfig -q 3 | winrm quickconfig -transport:http 4 | winrm set winrm/config '@{MaxTimeoutms="7200000"}' 5 | winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}' 6 | winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}' 7 | winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}' 8 | winrm set winrm/config/service '@{AllowUnencrypted="true"}' 9 | winrm set winrm/config/service/auth '@{Basic="true"}' 10 | winrm set winrm/config/client/auth '@{Basic="true"}' 11 | winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"} ' 12 | 13 | netsh advfirewall firewall set rule group="remote administration" new enable=yes 14 | netsh firewall add portopening TCP 5985 "Port 5985" 15 | net stop winrm 16 | sc.exe config winrm start= auto 17 | net start winrm -------------------------------------------------------------------------------- /provisioners/powershell/defrag-c.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Starting Defrag C..." 2 | Optimize-Volume C -Verbose -------------------------------------------------------------------------------- /provisioners/powershell/disable-uac.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Disabling UAC..." 2 | New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -PropertyType DWord -Value 0 -Force 3 | New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 0 -Force -------------------------------------------------------------------------------- /provisioners/powershell/install-chocolatey.ps1: -------------------------------------------------------------------------------- 1 | iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) -------------------------------------------------------------------------------- /provisioners/powershell/install-iis.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Installing IIS..." 2 | Import-Module ServerManager 3 | $features = @( 4 | "Web-WebServer", 5 | "Web-Static-Content", 6 | "Web-Http-Errors", 7 | "Web-Http-Redirect", 8 | "Web-Stat-Compression", 9 | "Web-Filtering", 10 | "Web-Asp-Net45", 11 | "Web-Net-Ext45", 12 | "Web-ISAPI-Ext", 13 | "Web-ISAPI-Filter", 14 | "Web-Mgmt-Console", 15 | "Web-Mgmt-Tools", 16 | "NET-Framework-45-ASPNET" 17 | ) 18 | Add-WindowsFeature $features -Verbose 19 | 20 | Write-Host "Opening port 80..." 21 | netsh advfirewall firewall add rule name="open_80_api" dir=in localport=80 protocol=TCP action=allow 22 | 23 | choco install -y webdeploy -------------------------------------------------------------------------------- /provisioners/powershell/sysprep-bundleconfig.ps1: -------------------------------------------------------------------------------- 1 | $EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\BundleConfig.xml" 2 | $xml = [xml](get-content $EC2SettingsFile) 3 | $xmlElement = $xml.get_DocumentElement() 4 | 5 | foreach ($element in $xmlElement.Property) 6 | { 7 | if ($element.Name -eq "AutoSysprep") 8 | { 9 | $element.Value="Yes" 10 | } 11 | } 12 | $xml.Save($EC2SettingsFile) -------------------------------------------------------------------------------- /provisioners/powershell/sysprep-ec2config.ps1: -------------------------------------------------------------------------------- 1 | $EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\Config.xml" 2 | $xml = [xml](get-content $EC2SettingsFile) 3 | $xmlElement = $xml.get_DocumentElement() 4 | $xmlElementToModify = $xmlElement.Plugins 5 | 6 | foreach ($element in $xmlElementToModify.Plugin) 7 | { 8 | if ($element.name -eq "Ec2SetPassword") 9 | { 10 | $element.State="Enabled" 11 | } 12 | elseif ($element.name -eq "Ec2SetComputerName") 13 | { 14 | $element.State="Enabled" 15 | } 16 | elseif ($element.name -eq "Ec2HandleUserData") 17 | { 18 | $element.State="Enabled" 19 | } 20 | } 21 | $xml.Save($EC2SettingsFile) -------------------------------------------------------------------------------- /templates/ubuntu-1404/http/preseed.cfg: -------------------------------------------------------------------------------- 1 | debconf debconf/frontend select Noninteractive 2 | choose-mirror-bin mirror/http/proxy string 3 | d-i base-installer/kernel/override-image string linux-server 4 | d-i clock-setup/utc boolean true 5 | d-i clock-setup/utc-auto boolean true 6 | d-i finish-install/reboot_in_progress note 7 | d-i grub-installer/only_debian boolean true 8 | d-i grub-installer/with_other_os boolean true 9 | d-i partman-auto-lvm/guided_size string max 10 | d-i partman-auto/choose_recipe select atomic 11 | d-i partman-auto/method string lvm 12 | d-i partman-lvm/confirm boolean true 13 | d-i partman-lvm/confirm_nooverwrite boolean true 14 | d-i partman-lvm/device_remove_lvm boolean true 15 | d-i partman/choose_partition select finish 16 | d-i partman/confirm boolean true 17 | d-i partman/confirm_nooverwrite boolean true 18 | d-i partman/confirm_write_new_label boolean true 19 | 20 | # Default user 21 | d-i passwd/user-fullname string vagrant 22 | d-i passwd/username string vagrant 23 | d-i passwd/user-password password vagrant 24 | d-i passwd/user-password-again password vagrant 25 | d-i passwd/username string vagrant 26 | 27 | # Minimum packages (see postinstall.sh) 28 | d-i pkgsel/include string openssh-server 29 | d-i pkgsel/install-language-support boolean false 30 | d-i pkgsel/update-policy select none 31 | d-i pkgsel/upgrade select none 32 | 33 | d-i time/zone string UTC 34 | d-i user-setup/allow-password-weak boolean true 35 | d-i user-setup/encrypt-home boolean false 36 | tasksel tasksel/first multiselect standard, server -------------------------------------------------------------------------------- /templates/ubuntu-1404/virtualbox-ubuntu.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "http://releases.ubuntu.com/14.04/ubuntu-14.04.4-server-amd64.iso", 4 | "iso_checksum": "2ac1f3e0de626e54d05065d6f549fa3a", 5 | "iso_checksum_type": "md5" 6 | }, 7 | "builders": [ 8 | { 9 | "type": "virtualbox-iso", 10 | "boot_command": [ 11 | "<esc><wait>", 12 | "<esc><wait>", 13 | "<enter><wait>", 14 | "/install/vmlinuz<wait>", 15 | " auto<wait>", 16 | " console-setup/ask_detect=false<wait>", 17 | " console-setup/layoutcode=gb<wait>", 18 | " console-setup/modelcode=pc105<wait>", 19 | " debian-installer=en_GB<wait>", 20 | " fb=false<wait>", 21 | " initrd=/install/initrd.gz<wait>", 22 | " kbd-chooser/method=gb<wait>", 23 | " keyboard-configuration/layout=GB<wait>", 24 | " keyboard-configuration/variant=GB<wait>", 25 | " locale=en_GB<wait>", 26 | " netcfg/get_hostname=ubuntu-1404<wait>", 27 | " netcfg/get_domain=vagrantup.com<wait>", 28 | " noapic<wait>", 29 | " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>", 30 | " -- <wait>", 31 | "<enter><wait>" 32 | ], 33 | "boot_wait": "10s", 34 | "disk_size": 10240, 35 | "output_directory": "ubuntu1404-{{timestamp}}", 36 | "guest_os_type": "Linux_64", 37 | "http_directory": "{{template_dir}}/http", 38 | "iso_checksum": "{{user `iso_checksum`}}", 39 | "iso_checksum_type": "{{user `iso_checksum_type`}}", 40 | "iso_url": "{{user `iso_url`}}", 41 | "ssh_username": "vagrant", 42 | "ssh_password": "vagrant", 43 | "ssh_port": 22, 44 | "ssh_wait_timeout": "10000s", 45 | "shutdown_command": "echo 'shutdown -P now' > /tmp/shutdown.sh; echo 'vagrant'|sudo -S sh '/tmp/shutdown.sh'" 46 | } 47 | ], 48 | "provisioners": [ 49 | { 50 | "type": "shell", 51 | "execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'", 52 | "inline": [ 53 | "sleep 30", 54 | "sudo apt-get -y update", 55 | "sudo apt-get -y upgrade", 56 | "echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers" 57 | ] 58 | }, 59 | { 60 | "type": "ansible", 61 | "playbook_file": "{{template_dir}}/../../provisioners/ansible/java8-packer.yml" 62 | } 63 | ] 64 | } -------------------------------------------------------------------------------- /templates/windows-server-2012/aws-win2012R2-apibox.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "", 4 | "aws_secret_key": "", 5 | "subnet_id": "", 6 | "security_group_id": "", 7 | "dotnet_version": "4.5.2", 8 | "base_ami": "ami-7943ec0a" 9 | }, 10 | "builders": [ 11 | { 12 | "type": "amazon-ebs", 13 | "region": "eu-west-1", 14 | "instance_type": "t2.micro", 15 | "source_ami": "{{user `base_ami`}}", 16 | "ami_name": "apidemo-W2012R2-{{timestamp}}", 17 | "user_data_file": "{{template_dir}}/../../bootstrap/aws/userdata/bootstrap-aws.txt", 18 | "communicator": "winrm", 19 | "winrm_timeout": "4h", 20 | "winrm_port": 5985, 21 | "winrm_username": "Administrator", 22 | "subnet_id": "{{user `subnet_id`}}", 23 | "security_group_id": "{{user `security_group_id`}}", 24 | "access_key": "{{user `aws_access_key`}}", 25 | "secret_key": "{{user `aws_secret_key`}}", 26 | "tags": { 27 | "version": "2012r2", 28 | "builder": "packer" 29 | } 30 | } 31 | ], 32 | "provisioners": [ 33 | { 34 | "type": "powershell", 35 | "scripts": [ 36 | "{{template_dir}}/../../provisioners/powershell/disable-uac.ps1", 37 | "{{template_dir}}/../../provisioners/powershell/install-chocolatey.ps1" 38 | ] 39 | }, 40 | { 41 | "type": "powershell", 42 | "inline": [ 43 | "choco install -y dotnet{{user `dotnet_version`}}", 44 | "choco install -y psget", 45 | "Add-WindowsFeature telnet-client -Verbose", 46 | "Add-WindowsFeature SNMP-Service -Verbose" 47 | ] 48 | }, 49 | { 50 | "type": "powershell", 51 | "scripts": [ 52 | "{{template_dir}}/../../provisioners/powershell/install-iis.ps1" 53 | ] 54 | }, 55 | { 56 | "type": "powershell", 57 | "scripts": [ 58 | "{{template_dir}}/../../provisioners/powershell/sysprep-ec2config.ps1", 59 | "{{template_dir}}/../../provisioners/powershell/sysprep-bundleconfig.ps1", 60 | "{{template_dir}}/../../provisioners/powershell/defrag-c.ps1" 61 | ] 62 | } 63 | ] 64 | } -------------------------------------------------------------------------------- /templates/windows-server-2012/aws-win2012R2-servicebox.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "aws_access_key": "", 4 | "aws_secret_key": "", 5 | "subnet_id": "", 6 | "security_group_id": "", 7 | "dotnet_version": "4.5.2", 8 | "base_ami": "ami-7943ec0a" 9 | }, 10 | "builders": [ 11 | { 12 | "type": "amazon-ebs", 13 | "region": "eu-west-1", 14 | "instance_type": "t2.micro", 15 | "source_ami": "{{user `base_ami`}}", 16 | "ami_name": "servicedemo-W2012R2-{{timestamp}}", 17 | "user_data_file": "{{template_dir}}/../../bootstrap/aws/userdata/bootstrap-aws.txt", 18 | "communicator": "winrm", 19 | "winrm_timeout": "4h", 20 | "winrm_port": 5985, 21 | "winrm_username": "Administrator", 22 | "subnet_id": "{{user `subnet_id`}}", 23 | "security_group_id": "{{user `security_group_id`}}", 24 | "access_key": "{{user `aws_access_key`}}", 25 | "secret_key": "{{user `aws_secret_key`}}", 26 | "tags": { 27 | "version": "2012r2", 28 | "builder": "packer" 29 | } 30 | } 31 | ], 32 | "provisioners": [ 33 | { 34 | "type": "powershell", 35 | "scripts": [ 36 | "{{template_dir}}/../../provisioners/powershell/disable-uac.ps1", 37 | "{{template_dir}}/../../provisioners/powershell/install-chocolatey.ps1" 38 | ] 39 | }, 40 | { 41 | "type": "powershell", 42 | "inline": [ 43 | "choco install -y dotnet{{user `dotnet_version`}}", 44 | "choco install -y psget", 45 | "Add-WindowsFeature telnet-client -Verbose", 46 | "Add-WindowsFeature SNMP-Service -Verbose" 47 | ] 48 | }, 49 | { 50 | "type": "powershell", 51 | "scripts": [ 52 | "{{template_dir}}/../../provisioners/powershell/sysprep-ec2config.ps1", 53 | "{{template_dir}}/../../provisioners/powershell/sysprep-bundleconfig.ps1", 54 | "{{template_dir}}/../../provisioners/powershell/defrag-c.ps1" 55 | ] 56 | } 57 | ] 58 | } -------------------------------------------------------------------------------- /templates/windows-server-2012/virtualbox-2012R2-servicebox.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO", 4 | "iso_checksum_type": "md5", 5 | "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a", 6 | "autounattend": "{{template_dir}}/../../bootstrap/vmware/answer_files/2012r2/Autounattend.xml" 7 | }, 8 | "builders": [ 9 | { 10 | "type": "virtualbox-iso", 11 | "iso_url": "{{user `iso_url`}}", 12 | "iso_checksum_type": "{{user `iso_checksum_type`}}", 13 | "iso_checksum": "{{user `iso_checksum`}}", 14 | "headless": false, 15 | "boot_wait": "1m", 16 | "communicator": "winrm", 17 | "winrm_timeout": "4h", 18 | "winrm_username": "Administrator", 19 | "winrm_password": "vagrant", 20 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 21 | "guest_os_type": "Windows2012_64", 22 | "guest_additions_mode": "disable", 23 | "output_directory": "win2012-servicebox-{{timestamp}}", 24 | "disk_size": 15360, 25 | "floppy_files": [ 26 | "{{user `autounattend`}}", 27 | "{{template_dir}}/../../provisioners/powershell/configure-winrm.ps1" 28 | ] 29 | } 30 | ], 31 | "provisioners": [ 32 | { 33 | "type": "powershell", 34 | "scripts": [ 35 | "{{template_dir}}/../../provisioners/powershell/disable-uac.ps1", 36 | "{{template_dir}}/../../provisioners/powershell/install-chocolatey.ps1" 37 | ] 38 | }, 39 | { 40 | "type": "powershell", 41 | "inline": [ 42 | "choco install -y dotnet{{user `dotnet_version`}}", 43 | "choco install -y psget", 44 | "Add-WindowsFeature telnet-client -Verbose", 45 | "Add-WindowsFeature SNMP-Service -Verbose" 46 | ] 47 | } 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /templates/windows-server-2012/vmware-2012R2-servicebox.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "iso_url": "http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO", 4 | "iso_checksum_type": "md5", 5 | "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a", 6 | "autounattend": "{{template_dir}}/../../bootstrap/vmware/answer_files/2012r2/Autounattend.xml", 7 | "disk_type_id": "4" 8 | }, 9 | "builders": [ 10 | { 11 | "type": "vmware-iso", 12 | "iso_url": "{{user `iso_url`}}", 13 | "iso_checksum_type": "{{user `iso_checksum_type`}}", 14 | "iso_checksum": "{{user `iso_checksum`}}", 15 | "headless": false, 16 | "boot_wait": "1m", 17 | "communicator": "winrm", 18 | "winrm_timeout": "4h", 19 | "winrm_username": "Administrator", 20 | "winrm_password": "vagrant", 21 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 22 | "guest_os_type": "windows8srv-64", 23 | "output_directory": "win2012-servicebox-{{timestamp}}", 24 | "disk_size": 15360, 25 | "disk_type_id": "{{user `disk_type_id`}}", 26 | "vnc_port_min": 5900, 27 | "vnc_port_max": 5980, 28 | "floppy_files": [ 29 | "{{user `autounattend`}}", 30 | "{{template_dir}}/../../provisioners/powershell/configure-winrm.ps1" 31 | ], 32 | "vmx_data": { 33 | "memsize": "2048", 34 | "numvcpus": "2", 35 | "scsi0.virtualDev": "lsisas1068" 36 | } 37 | } 38 | ], 39 | "provisioners": [ 40 | { 41 | "type": "powershell", 42 | "scripts": [ 43 | "{{template_dir}}/../../provisioners/powershell/disable-uac.ps1", 44 | "{{template_dir}}/../../provisioners/powershell/install-chocolatey.ps1" 45 | ] 46 | }, 47 | { 48 | "type": "powershell", 49 | "inline": [ 50 | "choco install -y dotnet{{user `dotnet_version`}}", 51 | "choco install -y psget", 52 | "Add-WindowsFeature telnet-client -Verbose", 53 | "Add-WindowsFeature SNMP-Service -Verbose" 54 | ] 55 | } 56 | ] 57 | } --------------------------------------------------------------------------------