├── 2012r2-parallels.json
├── 2012r2-virtualbox.json
├── LICENSE
├── README.md
├── amazon-sysprep.json
├── answer_files
├── 2008_r2
│ └── Autounattend.xml
└── 2012_r2
│ ├── Autounattend.xml
│ ├── Autounattend_sysprep.xml
│ ├── parallels
│ └── Autounattend.xml
│ └── updates
│ └── Autounattend.xml
├── scripts
├── BundleConfig.ps1
├── Ec2Config.ps1
├── cleanup.ps1
├── cleanup2.ps1
├── disable-password-complexity.ps1
├── ec2-bootstrap.ps1
├── ec2-user-data.ps1
├── microsoft-updates.bat
├── openssh.ps1
├── oracle-cert.cer
├── parallels-guest-tools.ps1
├── provision.ps1
├── rsync.bat
├── virtualbox-guest-tools.ps1
├── win-updates.ps1
└── winrmconfig.bat
└── vagrantfile-windows_2012_r2.template
/2012r2-parallels.json:
--------------------------------------------------------------------------------
1 | {
2 | "builders": [
3 | {
4 | "type": "parallels-windows-iso",
5 | "vm_name": "vagrant-rsync",
6 | "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",
7 | "iso_checksum_type": "md5",
8 | "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a",
9 | "winrm_username": "vagrant",
10 | "winrm_password": "vagrant",
11 | "winrm_wait_timeout": "60m",
12 | "winrm_port":5985,
13 | "headless": false,
14 | "boot_wait": "2m",
15 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
16 | "guest_os_type": "win-8.1",
17 | "parallels_tools_flavor": "win",
18 | "disk_size": 61440,
19 | "floppy_files": [
20 | "./answer_files/2012_r2/parallels/Autounattend.xml",
21 | "./scripts/microsoft-updates.bat",
22 | "./scripts/win-updates.ps1",
23 | "./scripts/oracle-cert.cer",
24 | "./scripts/disable-password-complexity.ps1"
25 | ],
26 | "prlctl": [
27 | ["set", "{{.Name}}", "--memsize", "2048"],
28 | ["set", "{{.Name}}", "--cpus", "2"],
29 | ["set", "{{.Name}}", "--winsystray-in-macmenu", "off"],
30 | ["set", "{{.Name}}", "--startup-view", "window"]
31 | ]
32 | },
33 | {
34 | "type": "parallels-windows-pvm",
35 | "source_path": "./output-parallels-windows-iso/vagrant-rsync.pvm",
36 | "headless": false,
37 | "boot_wait": "30s",
38 | "winrm_username": "vagrant",
39 | "winrm_password": "vagrant",
40 | "winrm_wait_timeout": "5m",
41 | "winrm_port":5985,
42 | "winrm_host":"localhost",
43 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
44 | "shutdown_timeout": "10m",
45 | "parallels_tools_mode": "disable",
46 | "prlctl": [
47 | ["set", "{{.Name}}", "--memsize", "2048"],
48 | ["set", "{{.Name}}", "--cpus", "2"],
49 | ["set", "{{.Name}}", "--winsystray-in-macmenu", "off"],
50 | ["set", "{{.Name}}", "--startup-view", "window"]
51 | ]
52 | }
53 | ],
54 | "provisioners": [
55 | {
56 | "type": "powershell",
57 | "scripts": [
58 | "./scripts/parallels-guest-tools.ps1",
59 | "./scripts/disable-password-complexity.ps1"
60 | ],
61 | "only":["basebox-parallels"]
62 | },
63 | {
64 | "type": "powershell",
65 | "scripts": [
66 | "./scripts/openssh.ps1"
67 | ],
68 | "only":["parallels-windows-ovf"]
69 | },
70 | {
71 | "type":"windows-shell",
72 | "scripts": [
73 | "./scripts/rsync.bat"
74 | ],
75 | "only":["parallels-windows-ovf"]
76 | },
77 | {
78 | "type":"powershell",
79 | "inline": [
80 | "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))",
81 | "choco install seek-dsc"
82 | ],
83 | "only":["parallels-windows-ovf"]
84 | },
85 | {
86 | "type": "powershell",
87 | "scripts": [
88 | "./scripts/cleanup.ps1"
89 | ],
90 | "only":["parallels-windows-ovf"]
91 | },
92 | {
93 | "type": "restart-windows",
94 | "only":["parallels-windows-ovf"]
95 | },
96 | {
97 | "type": "powershell",
98 | "scripts": [
99 | "./scripts/cleanup2.ps1"
100 | ],
101 | "only":["parallels-windows-ovf"]
102 | },
103 | {
104 | "type": "file",
105 | "source": "./answer_files/2012_r2/Autounattend_sysprep.xml",
106 | "destination": "c:/Windows/Temp/Autounattend_sysprep.xml",
107 | "only":["parallels-windows-ovf"]
108 | }
109 | ],
110 | "post-processors": [
111 | {
112 | "type": "vagrant",
113 | "keep_input_artifact": true,
114 | "output": "windows2012r2-{{.Provider}}.box",
115 | "vagrantfile_template": "vagrantfile-windows_2012_r2.template",
116 | "only":["parallels-windows-ovf"]
117 | }
118 | ]
119 | }
120 |
--------------------------------------------------------------------------------
/2012r2-virtualbox.json:
--------------------------------------------------------------------------------
1 | {
2 | "builders": [
3 | {
4 | "type": "virtualbox-windows-iso",
5 | "vm_name": "vagrant-rsync",
6 | "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",
7 | "iso_checksum_type": "md5",
8 | "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a",
9 | "winrm_username": "vagrant",
10 | "winrm_password": "vagrant",
11 | "winrm_wait_timeout": "8h",
12 | "winrm_port":5985,
13 | "headless": false,
14 | "boot_wait": "1m",
15 | "guest_additions_mode": "upload",
16 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
17 | "guest_os_type": "Windows2012_64",
18 | "disk_size": 61440,
19 | "floppy_files": [
20 | "./answer_files/2012_r2/Autounattend.xml",
21 | "./scripts/microsoft-updates.bat",
22 | "./scripts/win-updates.ps1",
23 | "./scripts/oracle-cert.cer",
24 | "./scripts/disable-password-complexity.ps1"
25 | ],
26 | "vboxmanage": [
27 | [
28 | "modifyvm",
29 | "{{.Name}}",
30 | "--memory",
31 | "2048"
32 | ],
33 | [
34 | "modifyvm",
35 | "{{.Name}}",
36 | "--cpus",
37 | "2"
38 | ],
39 | [
40 | "modifyvm",
41 | "{{.Name}}",
42 | "--natpf1",
43 | "guestwinrm,tcp,127.0.0.1,5985,,5985"
44 | ]
45 | ]
46 | },
47 | {
48 | "type": "virtualbox-windows-ovf",
49 | "source_path": "./output-virtualbox-windows-iso/vagrant-rsync.ovf",
50 | "headless": false,
51 | "guest_additions_mode": "disable",
52 | "boot_wait": "30s",
53 | "winrm_username": "vagrant",
54 | "winrm_password": "vagrant",
55 | "winrm_wait_timeout": "5m",
56 | "winrm_port":5985,
57 | "winrm_host":"localhost",
58 | "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
59 | "shutdown_timeout": "10m",
60 | "http_directory":"/tmp",
61 | "vboxmanage": [
62 | [
63 | "modifyvm",
64 | "{{.Name}}",
65 | "--memory",
66 | "2048"
67 | ],
68 | [
69 | "modifyvm",
70 | "{{.Name}}",
71 | "--vram",
72 | "64"
73 | ],
74 | [
75 | "modifyvm",
76 | "{{.Name}}",
77 | "--cpus",
78 | "2"
79 | ]
80 | ]
81 | }
82 | ],
83 | "provisioners": [
84 | {
85 | "type":"powershell",
86 | "inline": [
87 | "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')))>$null 2>&1",
88 | "choco install 7zip -y"
89 | ],
90 | "only":["virtualbox-windows-iso"]
91 | },
92 | {
93 | "type": "file",
94 | "source": "./answer_files/2012_r2/Autounattend_sysprep.xml",
95 | "destination": "c:/Windows/Temp/Autounattend_sysprep.xml",
96 | "only":["virtualbox-windows-iso"]
97 | },
98 | {
99 | "type": "powershell",
100 | "scripts": [
101 | "./scripts/virtualbox-guest-tools.ps1",
102 | "./scripts/disable-password-complexity.ps1"
103 | ],
104 | "only":["virtualbox-windows-iso"]
105 | },
106 | {
107 | "type": "powershell",
108 | "scripts": [
109 | "./scripts/openssh.ps1"
110 | ],
111 | "only":["virtualbox-windows-ovf"]
112 | },
113 | {
114 | "type":"windows-shell",
115 | "scripts": [
116 | "./scripts/rsync.bat"
117 | ],
118 | "only":["virtualbox-windows-ovf"]
119 | },
120 | {
121 | "type": "powershell",
122 | "elevated_user": "vagrant",
123 | "elevated_password": "vagrant",
124 | "scripts": [
125 | "./scripts/provision.ps1"
126 | ],
127 | "only":["virtualbox-windows-ovf"]
128 | },
129 | {
130 | "type": "powershell",
131 | "scripts": [
132 | "./scripts/cleanup.ps1"
133 | ],
134 | "only":["virtualbox-windows-ovf"]
135 | },
136 | {
137 | "type": "restart-windows",
138 | "only":["virtualbox-windows-ovf"]
139 | },
140 | {
141 | "type": "powershell",
142 | "scripts": [
143 | "./scripts/cleanup2.ps1"
144 | ],
145 | "only":["virtualbox-windows-ovf"]
146 | }
147 | ],
148 | "post-processors": [
149 | {
150 | "type": "vagrant",
151 | "keep_input_artifact": true,
152 | "output": "windows2012r2-{{.Provider}}.box",
153 | "vagrantfile_template": "vagrantfile-windows_2012_r2.template",
154 | "only":["virtualbox-windows-ovf"]
155 | }
156 | ]
157 | }
158 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Matt Fellows
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, 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,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Packer Community Example Templates
2 |
3 | [Packer Community](https://github.com/packer-community/packer-windows-plugins/) Templates for Windows environments to test/showcase many of the Windows-specific Builders and Provisioners.
4 |
5 | ## Running
6 |
7 | * Install [Packer](https://github.com/mitchellh/packer/) and [Packer Community](https://github.com/packer-community/packer-windows-plugins/)
8 | * Clone this repo:
9 |
10 | ```
11 | git clone git@github.com:mefellows/packer-windows-templates.git && cd packer-community-templates
12 | ```
13 |
14 | * Run Packer
15 |
16 | Common practice is to create intermediate boxes in [machine image pipelines](http://www.onegeek.com.au/articles/machine-factories-part1-vagrant), such as a 'Base' and 'Application' images. The examples below follow this pattern.
17 |
18 | ### Vagrant Boxes
19 |
20 | Run the ISO builder to produce a simple Base box with VirtualBox guest additions and optionally Windows updates (Uncomment the [relevant](/blob/master/answer_files/2012_r2/Autounattend.xml#L242-L265) lines in the Autounattend.xml files to enable this):
21 |
22 | ```
23 | packer build -only=virtualbox-windows-iso 2012r2-virtualbox.json
24 | ```
25 |
26 | Run the OVF builder to produce a simple base box with rsync and Seek DSC resources installed:
27 |
28 |
29 | ```
30 | packer build -only=virtualbox-windows-ovf 2012r2-virtualbox.json
31 | ```
32 |
33 | ### AWS Machines
34 |
35 | ```
36 | packer build --var base_ami=ami-ac3a1cc4 --var subnet_id=subnet-1234abcd--var vpc_id=vpc-4567defg ./amazon-sysprep.json
37 | ```
38 |
39 |
40 | ## Windows Updates
41 |
42 | Use the `/answer_files/2012_r2/updates/Autounattend.xml` file as a replacement in the `floppy_files` configuration item.
43 |
44 | ## Sysprep
45 |
46 | An example unattended sysprep file is automatically uploaded to `c:/Windows/Temp/Autounattend_sysprep.xml` which can be used in a provisioner to sysprep the machine. For example, you may replace the default `shutdown_command` in the OVF builder with the following:
47 |
48 | ```
49 | "shutdown_command": "c:/windows/system32/sysprep/sysprep.exe /generalize /oobe /quiet /shutdown /unattend:c:/Windows/Temp/Autounattend_sysprep.xml",
50 | "shutdown_timeout": "15m"
51 | ```
52 |
53 | NOTE: This currently impacts the rsync (SSH) capability due to SIDs and such.
54 |
55 | ## Credits
56 |
57 | Thanks to Joe's [joefitzgerald/packer-windows](https://github.com/joefitzgerald/packer-windows) templates for the inspiration and basis for much of this work.
--------------------------------------------------------------------------------
/amazon-sysprep.json:
--------------------------------------------------------------------------------
1 | {
2 | "variables": {
3 | "build_version": "1.0.1",
4 | "base_ami":"ami-3a3b1d52",
5 | "user":"vagrant",
6 | "password":"FooBar@123",
7 | "instance_type":"t2.small",
8 | "vpc_id":"",
9 | "subnet_id":""
10 | },
11 | "builders": [
12 | {
13 | "type": "amazon-windows-ebs",
14 | "name": "base-ami",
15 | "region": "us-east-1",
16 | "source_ami": "{{user `base_ami`}}",
17 | "instance_type": "{{user `instance_type`}}",
18 | "ami_name": "sysprep-windows-{{user `build_version`}}",
19 | "user_data_file":"./scripts/ec2-bootstrap.ps1",
20 | "associate_public_ip_address":true,
21 | "winrm_username": "{{user `user`}}",
22 | "winrm_password": "{{user `password`}}",
23 | "winrm_wait_timeout": "20m",
24 | "winrm_private_ip": false,
25 | "winrm_port":5985,
26 | "vpc_id": "{{user `vpc_id`}}",
27 | "subnet_id": "{{user `subnet_id`}}"
28 | }
29 | ],
30 | "provisioners": [
31 | {
32 | "type":"powershell",
33 | "scripts": [
34 | "./scripts/Ec2Config.ps1",
35 | "./scripts/BundleConfig.ps1"
36 | ]
37 | }
38 | ]
39 | }
40 |
--------------------------------------------------------------------------------
/answer_files/2008_r2/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 1
11 | Primary
12 | 60000
13 |
14 |
15 |
16 |
17 | false
18 | NTFS
19 | C
20 | 1
21 | 1
22 |
23 |
24 |
25 | 0
26 | true
27 |
28 |
51 | OnError
52 |
53 |
54 | true
55 | Vagrant Administrator
56 | Vagrant Inc.
57 |
58 |
59 |
60 |
61 |
62 | Never
63 |
64 |
65 |
66 |
67 |
68 | 0
69 | 1
70 |
71 | OnError
72 | false
73 |
74 |
75 | /IMAGE/NAME
76 | Windows Server 2008 R2 SERVERSTANDARD
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | en-US
85 |
86 | en-US
87 | en-US
88 | en-US
89 | en-US
90 | en-US
91 |
92 |
93 |
94 |
95 | false
96 |
97 |
98 |
99 |
100 |
101 |
102 | vagrant
103 | true
104 |
105 |
106 |
107 |
108 | vagrant
109 | true
110 |
111 | Vagrant User
112 | vagrant
113 | administrators
114 | vagrant
115 |
116 |
117 |
118 |
119 | true
120 | true
121 | Home
122 |
123 |
124 |
125 | vagrant
126 | true
127 |
128 | vagrant
129 | true
130 |
131 |
132 |
133 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy bypass -Force"
134 | Set Execution Policy 64 Bit
135 | 1
136 | true
137 |
138 |
139 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy bypass -Force"
140 | Set Execution Policy 32 Bit
141 | 2
142 | true
143 |
144 |
145 | cmd.exe /c winrm quickconfig -q
146 | winrm quickconfig -q
147 | 3
148 | true
149 |
150 |
151 | // Re order the numbers and possibly update descriptions
152 |
153 | cmd.exe /c winrm quickconfig -transport:http
154 | winrm quickconfig -transport:http
155 | 4
156 | true
157 |
158 |
159 | cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
160 | Win RM MaxTimoutms
161 | 5
162 | true
163 |
164 |
165 | cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
166 | Win RM MaxMemoryPerShellMB
167 | 6
168 | true
169 |
170 |
171 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
172 | Win RM AllowUnencrypted
173 | 7
174 | true
175 |
176 |
177 | cmd.exe /c winrm set winrm/config/client @{AllowUnencrypted="true"}
178 | Win RM AllowUnencrypted
179 | 7
180 | true
181 |
182 |
183 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
184 | Win RM auth Basic
185 | 8
186 | true
187 |
188 |
189 | cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
190 | Win RM client auth Basic
191 | 9
192 | true
193 |
194 |
195 | cmd.exe /c winrm set winrm/config/service/auth @{CredSSP="true"}
196 | Win RM client auth Basic
197 | 9
198 | true
199 |
200 |
201 | cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
202 | Win RM listener Address/Port
203 | 10
204 | true
205 |
206 |
207 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
208 | Win RM adv firewall enable
209 | 11
210 | true
211 |
212 |
213 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
214 | Win RM port open
215 | 12
216 | true
217 |
218 |
219 | cmd.exe /c net stop winrm
220 | Stop Win RM Service
221 | 13
222 | true
223 |
224 |
225 | cmd.exe /c sc config winrm start= auto
226 | Win RM Autostart
227 | 14
228 | true
229 |
230 |
231 | cmd.exe /c net start winrm
232 | Start Win RM Service
233 | 15
234 | true
235 |
236 |
237 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
238 | 16
239 | Show file extensions in Explorer
240 |
241 |
242 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
243 | 17
244 | Enable QuickEdit mode
245 |
246 |
247 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
248 | 18
249 | Show Run command in Start Menu
250 |
251 |
252 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
253 | 19
254 | Show Administrative Tools in Start Menu
255 |
256 |
257 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
258 | 20
259 | Zero Hibernation File
260 |
261 |
262 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
263 | 21
264 | Disable Hibernation Mode
265 |
266 |
267 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
268 | 22
269 | Disable password expiration for vagrant user
270 |
271 |
272 | Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
273 |
274 | Enable-WSManCredSSP -role client -delegatecomputer * -force
275 | Enable-WSManCredSSP -role client -delegatecomputer *.seek.int -force
276 | Enable-WSManCredSSP -role server -force
277 |
278 |
279 |
280 |
292 |
293 |
294 |
295 |
296 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart
297 | Install OpenSSH
298 | 99
299 | true
300 |
301 |
302 |
303 |
315 |
316 |
317 | false
318 |
319 |
320 |
321 |
322 |
323 | false
324 |
325 |
326 | vagrant-2008R2
327 | Pacific Standard Time
328 |
329 |
330 |
331 | true
332 |
333 |
334 |
335 | false
336 | false
337 |
338 |
339 | true
340 |
341 |
342 | true
343 |
344 |
345 |
346 |
347 |
--------------------------------------------------------------------------------
/answer_files/2012_r2/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | en-US
7 |
8 | en-US
9 | en-US
10 | en-US
11 | en-US
12 | en-US
13 |
14 |
15 |
16 |
17 |
18 |
19 | Primary
20 | 1
21 | 350
22 |
23 |
24 | 2
25 | Primary
26 | true
27 |
28 |
29 |
30 |
31 | true
32 | NTFS
33 |
34 | 1
35 | 1
36 |
37 |
38 | NTFS
39 |
40 | C
41 | 2
42 | 2
43 |
44 |
45 | 0
46 | true
47 |
48 |
49 |
50 |
51 |
52 |
53 | /IMAGE/NAME
54 | Windows Server 2012 R2 SERVERSTANDARD
55 |
56 |
57 |
58 | 0
59 | 2
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | OnError
70 |
71 | true
72 | Vagrant
73 | Vagrant
74 |
75 |
76 |
77 |
78 |
79 |
80 | false
81 |
82 | vagrant-2012-r2
83 | Pacific Standard Time
84 |
85 |
86 |
87 | true
88 |
89 |
90 | false
91 | false
92 |
93 |
94 | true
95 |
96 |
97 | true
98 |
99 |
100 |
101 |
102 |
103 |
104 | vagrant
105 | true
106 |
107 | true
108 | vagrant
109 |
110 |
111 |
112 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
113 | Set Execution Policy 64 Bit
114 | 1
115 | true
116 |
117 |
118 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
119 | Set Execution Policy 32 Bit
120 | 2
121 | true
122 |
123 |
124 | cmd.exe /c winrm quickconfig -q
125 | winrm quickconfig -q
126 | 3
127 | true
128 |
129 |
130 | cmd.exe /c winrm quickconfig -transport:http
131 | winrm quickconfig -transport:http
132 | 4
133 | true
134 |
135 |
136 | cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
137 | Win RM MaxTimoutms
138 | 5
139 | true
140 |
141 |
142 | cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
143 | Win RM MaxMemoryPerShellMB
144 | 6
145 | true
146 |
147 |
148 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
149 | Win RM AllowUnencrypted
150 | 7
151 | true
152 |
153 |
154 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
155 | Win RM auth Basic
156 | 8
157 | true
158 |
159 |
160 | cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
161 | Win RM client auth Basic
162 | 9
163 | true
164 |
165 |
166 | cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
167 | Win RM listener Address/Port
168 | 10
169 | true
170 |
171 |
172 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
173 | Win RM adv firewall enable
174 | 11
175 | true
176 |
177 |
178 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
179 | Win RM port open
180 | 12
181 | true
182 |
183 |
184 | cmd.exe /c net stop winrm
185 | Stop Win RM Service
186 | 13
187 | true
188 |
189 |
190 | cmd.exe /c sc config winrm start= auto
191 | Win RM Autostart
192 | 14
193 | true
194 |
195 |
196 | cmd.exe /c net start winrm
197 | Start Win RM Service
198 | 15
199 | true
200 |
201 |
202 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
203 | 16
204 | Show file extensions in Explorer
205 |
206 |
207 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
208 | 17
209 | Enable QuickEdit mode
210 |
211 |
212 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
213 | 18
214 | Show Run command in Start Menu
215 |
216 |
217 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
218 | 19
219 | Show Administrative Tools in Start Menu
220 |
221 |
222 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
223 | 20
224 | Zero Hibernation File
225 |
226 |
227 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
228 | 21
229 | Disable Hibernation Mode
230 |
231 |
232 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
233 | 22
234 | Disable password expiration for vagrant user
235 |
236 |
237 | cmd.exe /c powershell -File a:\disable-password-complexity.ps1
238 | Disable password complexity
239 | 23
240 | true
241 |
242 |
251 |
252 |
253 |
266 |
267 |
268 |
269 | true
270 | true
271 | true
272 | true
273 | true
274 | Home
275 | 1
276 |
277 |
278 |
279 | vagrant
280 | true
281 |
282 |
283 |
284 |
285 | vagrant
286 | true
287 |
288 | administrators
289 | Vagrant
290 | vagrant
291 | Vagrant User
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 | false
301 |
302 |
303 |
304 |
305 |
--------------------------------------------------------------------------------
/answer_files/2012_r2/Autounattend_sysprep.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 1
6 |
7 |
8 | false
9 | false
10 |
11 |
12 |
13 |
14 | en-US
15 | en-US
16 | en-US
17 | en-US
18 |
19 |
20 |
21 | true
22 | 1
23 | Work
24 | true
25 |
26 | UTC
27 |
35 |
36 |
37 |
38 |
39 |
41 |
42 |
43 | vagrant
44 | true
45 |
46 |
47 |
48 |
49 | vagrant
50 | true
51 |
52 | administrators
53 | Vagrant
54 | vagrant
55 | Vagrant User
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/answer_files/2012_r2/parallels/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | 1
11 | Primary
12 | 60000
13 |
14 |
15 |
16 |
17 | false
18 | NTFS
19 | C
20 | 1
21 | 1
22 |
23 |
24 |
25 | 0
26 | true
27 |
28 | OnError
29 |
30 |
31 | true
32 | Vagrant Administrator
33 | Vagrant Inc.
34 |
35 | XC9B7-NBPP2-83J2H-RHMBY-92BT4
36 | Never
37 |
38 |
39 |
40 |
41 |
42 | 0
43 | 1
44 |
45 | OnError
46 | false
47 |
48 |
49 | /IMAGE/NAME
50 | Windows Server 2012 R2 SERVERSTANDARD
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | en-US
59 |
60 | en-US
61 | en-US
62 | en-US
63 | en-US
64 | en-US
65 |
66 |
67 |
68 |
69 | false
70 |
71 |
72 |
73 |
74 |
75 |
76 | vagrant
77 | true
78 |
79 |
80 |
81 |
82 | vagrant
83 | true
84 |
85 | Vagrant User
86 | vagrant
87 | administrators
88 | vagrant
89 |
90 |
91 |
92 |
93 | true
94 | true
95 | Home
96 | 1
97 |
98 |
99 |
100 | vagrant
101 | true
102 |
103 | vagrant
104 | true
105 |
106 |
107 |
108 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
109 | Set Execution Policy 64 Bit
110 | 1
111 | true
112 |
113 |
114 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
115 | Set Execution Policy 32 Bit
116 | 2
117 | true
118 |
119 |
120 | cmd.exe /c winrm quickconfig -q
121 | winrm quickconfig -q
122 | 3
123 | true
124 |
125 |
126 | cmd.exe /c winrm quickconfig -transport:http
127 | winrm quickconfig -transport:http
128 | 4
129 | true
130 |
131 |
132 | cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
133 | Win RM MaxTimoutms
134 | 5
135 | true
136 |
137 |
138 | cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
139 | Win RM MaxMemoryPerShellMB
140 | 6
141 | true
142 |
143 |
144 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
145 | Win RM AllowUnencrypted
146 | 7
147 | true
148 |
149 |
150 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
151 | Win RM auth Basic
152 | 8
153 | true
154 |
155 |
156 | cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
157 | Win RM client auth Basic
158 | 9
159 | true
160 |
161 |
162 | cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
163 | Win RM listener Address/Port
164 | 10
165 | true
166 |
167 |
168 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
169 | Win RM adv firewall enable
170 | 11
171 | true
172 |
173 |
174 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
175 | Win RM port open
176 | 12
177 | true
178 |
179 |
180 | cmd.exe /c net stop winrm
181 | Stop Win RM Service
182 | 13
183 | true
184 |
185 |
186 | cmd.exe /c sc config winrm start= auto
187 | Win RM Autostart
188 | 14
189 | true
190 |
191 |
192 | cmd.exe /c net start winrm
193 | Start Win RM Service
194 | 15
195 | true
196 |
197 |
198 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
199 | 16
200 | Show file extensions in Explorer
201 |
202 |
203 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
204 | 17
205 | Enable QuickEdit mode
206 |
207 |
208 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
209 | 18
210 | Show Run command in Start Menu
211 |
212 |
213 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
214 | 19
215 | Show Administrative Tools in Start Menu
216 |
217 |
218 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
219 | 20
220 | Zero Hibernation File
221 |
222 |
223 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
224 | 21
225 | Disable Hibernation Mode
226 |
227 |
228 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
229 | 22
230 | Disable password expiration for vagrant user
231 |
232 |
233 | cmd.exe /c powershell -File a:\disable-password-complexity.ps1
234 | Disable password complexity
235 | 23
236 | true
237 |
238 |
239 |
247 |
248 |
261 |
262 |
263 | false
264 |
265 |
266 |
267 |
268 |
269 | false
270 |
271 | talentsearchapi
272 | AUS Eastern Standard Time
273 | false
274 |
275 |
276 |
277 | true
278 |
279 |
280 |
281 |
282 |
--------------------------------------------------------------------------------
/answer_files/2012_r2/updates/Autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | en-US
7 |
8 | en-US
9 | en-US
10 | en-US
11 | en-US
12 | en-US
13 |
14 |
15 |
16 |
17 |
18 |
19 | Primary
20 | 1
21 | 350
22 |
23 |
24 | 2
25 | Primary
26 | true
27 |
28 |
29 |
30 |
31 | true
32 | NTFS
33 |
34 | 1
35 | 1
36 |
37 |
38 | NTFS
39 |
40 | C
41 | 2
42 | 2
43 |
44 |
45 | 0
46 | true
47 |
48 |
49 |
50 |
51 |
52 |
53 | /IMAGE/NAME
54 | Windows Server 2012 R2 SERVERSTANDARD
55 |
56 |
57 |
58 | 0
59 | 2
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | OnError
70 |
71 | true
72 | Vagrant
73 | Vagrant
74 |
75 |
76 |
77 |
78 |
79 |
80 | false
81 |
82 | vagrant-2012-r2
83 | Pacific Standard Time
84 |
85 |
86 |
87 | true
88 |
89 |
90 | false
91 | false
92 |
93 |
94 | true
95 |
96 |
97 | true
98 |
99 |
100 |
101 |
102 |
103 |
104 | vagrant
105 | true
106 |
107 | true
108 | vagrant
109 |
110 |
111 |
112 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
113 | Set Execution Policy 64 Bit
114 | 1
115 | true
116 |
117 |
118 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy Bypass -Force"
119 | Set Execution Policy 32 Bit
120 | 2
121 | true
122 |
123 |
124 | cmd.exe /c winrm quickconfig -q
125 | winrm quickconfig -q
126 | 3
127 | true
128 |
129 |
130 | cmd.exe /c winrm quickconfig -transport:http
131 | winrm quickconfig -transport:http
132 | 4
133 | true
134 |
135 |
136 | cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
137 | Win RM MaxTimoutms
138 | 5
139 | true
140 |
141 |
142 | cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
143 | Win RM MaxMemoryPerShellMB
144 | 6
145 | true
146 |
147 |
148 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
149 | Win RM AllowUnencrypted
150 | 7
151 | true
152 |
153 |
154 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
155 | Win RM auth Basic
156 | 8
157 | true
158 |
159 |
160 | cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
161 | Win RM client auth Basic
162 | 9
163 | true
164 |
165 |
166 | cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
167 | Win RM listener Address/Port
168 | 10
169 | true
170 |
171 |
172 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
173 | Win RM adv firewall enable
174 | 11
175 | true
176 |
177 |
178 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
179 | Win RM port open
180 | 12
181 | true
182 |
183 |
184 | cmd.exe /c net stop winrm
185 | Stop Win RM Service
186 | 13
187 | true
188 |
189 |
190 | cmd.exe /c sc config winrm start= auto
191 | Win RM Autostart
192 | 14
193 | true
194 |
195 |
196 | cmd.exe /c net start winrm
197 | Start Win RM Service
198 | 15
199 | true
200 |
201 |
202 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
203 | 16
204 | Show file extensions in Explorer
205 |
206 |
207 | %SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f
208 | 17
209 | Enable QuickEdit mode
210 |
211 |
212 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f
213 | 18
214 | Show Run command in Start Menu
215 |
216 |
217 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f
218 | 19
219 | Show Administrative Tools in Start Menu
220 |
221 |
222 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f
223 | 20
224 | Zero Hibernation File
225 |
226 |
227 | %SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f
228 | 21
229 | Disable Hibernation Mode
230 |
231 |
232 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
233 | 22
234 | Disable password expiration for vagrant user
235 |
236 |
237 | cmd.exe /c powershell -File a:\disable-password-complexity.ps1
238 | Disable password complexity
239 | 23
240 | true
241 |
242 |
251 |
252 |
253 |
254 |
255 | cmd.exe /c a:\microsoft-updates.bat
256 | 98
257 | Enable Microsoft Updates
258 |
259 |
260 | cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1
261 | Install Windows Updates
262 | 100
263 | true
264 |
265 |
266 | cmd.exe /c net user vagrant vagrant
267 | Set correct vagrant user/pass so Packer can start
268 | 101
269 |
270 |
271 |
272 |
273 |
274 | true
275 | true
276 | true
277 | true
278 | true
279 | Home
280 | 1
281 |
282 |
283 |
284 | vagrantnotyet
285 | true
286 |
287 |
288 |
289 |
290 | vagrantnotyet
291 | true
292 |
293 | administrators
294 | Vagrant
295 | vagrant
296 | Vagrant User
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 | false
306 |
307 |
308 |
309 |
310 |
--------------------------------------------------------------------------------
/scripts/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)
13 |
--------------------------------------------------------------------------------
/scripts/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)
22 |
--------------------------------------------------------------------------------
/scripts/cleanup.ps1:
--------------------------------------------------------------------------------
1 | # Let's cleanup!
2 | #
3 | # See http://www.hurryupandwait.io/blog/in-search-of-a-light-weight-windows-vagrant-box
4 | # for details!
5 |
6 | # Reduce PageFile size
7 | $System = GWMI Win32_ComputerSystem -EnableAllPrivileges
8 | $System.AutomaticManagedPagefile = $False
9 | $System.Put()
10 |
11 | $CurrentPageFile = gwmi -query "select * from Win32_PageFileSetting where name='c:\\pagefile.sys'"
12 | $CurrentPageFile.InitialSize = 512
13 | $CurrentPageFile.MaximumSize = 512
14 | $CurrentPageFile.Put()
15 |
16 | # Cleanup update uninstallers
17 | Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
18 |
19 | # Run disk cleanup - need to install following and restart
20 | Add-WindowsFeature -Name Desktop-Experience
--------------------------------------------------------------------------------
/scripts/cleanup2.ps1:
--------------------------------------------------------------------------------
1 |
2 | # Disk Cleanup - doesn't get rid of anything at this early stage
3 | # Write-Host "cleaning disk..."
4 | # C:\Windows\System32\cleanmgr.exe /d c: /verylowdisk
5 |
6 | # Remove unnecessary features
7 | @('Desktop-Experience',
8 | 'InkAndHandwritingServices',
9 | 'Server-Media-Foundation',
10 | 'Powershell-ISE') | Remove-WindowsFeature
11 |
12 | Get-WindowsFeature |
13 | ? { $_.InstallState -eq 'Available' } |
14 | Uninstall-WindowsFeature -Remove
15 |
16 | # Defrag C
17 | Optimize-Volume -DriveLetter C
18 |
19 | wget http://download.sysinternals.com/files/SDelete.zip -OutFile sdelete.zip
20 | [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
21 | [System.IO.Compression.ZipFile]::ExtractToDirectory("sdelete.zip", ".")
22 |
23 | reg.exe ADD "HKCU\Software\Sysinternals\SDelete" /v EulaAccepted /t REG_DWORD /d 1 /f
24 | ./sdelete.exe -z c:
--------------------------------------------------------------------------------
/scripts/disable-password-complexity.ps1:
--------------------------------------------------------------------------------
1 | # works on Microsoft Windows Server 2008 #carriage return
2 | secedit /export /cfg c:\new.cfg #carriage return
3 | #start-sleep -s 5 #carriage return
4 | ((get-content c:\new.cfg) -replace ('PasswordComplexity = 1', 'PasswordComplexity = 0')) | Out-File c:\new.cfg #carriage return
5 | secedit /configure /db $env:windir\security\new.sdb /cfg c:\new.cfg /areas SECURITYPOLICY #carriage return
6 | Rename-Item c:\new.cfg c:\new.cfg.txt #carriage return
7 | write-host "That's all folks!" #carriage return
8 | rm c:\new.cfg.txt
--------------------------------------------------------------------------------
/scripts/ec2-bootstrap.ps1:
--------------------------------------------------------------------------------
1 |
2 | write-output "Running User Data Script"
3 | write-host "(host) Running User Data Script"
4 |
5 | # TODO: User should replace password here with something random. Even better, implement over SSL: https://github.com/packer-community/packer-windows-plugins/issues/30
6 | # Also note, this user should be removed in Cfn Init
7 | cmd.exe /c net user /add vagrant FooBar@123
8 | cmd.exe /c net localgroup administrators vagrant /add
9 |
10 | Set-ExecutionPolicy -ExecutionPolicy bypass -Force
11 |
12 | # RDP
13 | cmd.exe /c netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
14 | cmd.exe /c reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
15 |
16 | # WinRM
17 | write-output "Setting up WinRM"
18 | write-host "(host) setting up WinRM"
19 |
20 | cmd.exe /c winrm quickconfig -q
21 | cmd.exe /c winrm quickconfig '-transport:http'
22 | cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
23 | cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="512"}'
24 | cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
25 | cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
26 | cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
27 | cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
28 | cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
29 | cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
30 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
31 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
32 | cmd.exe /c net stop winrm
33 | cmd.exe /c sc config winrm start= auto
34 | cmd.exe /c net start winrm
35 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
36 |
37 |
38 |
--------------------------------------------------------------------------------
/scripts/ec2-user-data.ps1:
--------------------------------------------------------------------------------
1 |
2 | write-output "Running User Data Script"
3 | write-host "(host) Running User Data Script"
4 |
5 | cmd.exe /c net user /add vagrant FooBar@123
6 | cmd.exe /c net localgroup administrators vagrant /add
7 |
8 | Set-ExecutionPolicy -ExecutionPolicy bypass -Force
9 |
10 | # WinRM
11 | write-output "Setting up WinRM"
12 | write-host "(host) setting up WinRM"
13 |
14 | cmd.exe /c winrm quickconfig -q
15 | cmd.exe /c winrm quickconfig '-transport:http'
16 | cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
17 | cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="512"}'
18 | cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
19 | cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
20 | cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
21 | cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
22 | cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
23 | cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
24 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
25 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
26 | cmd.exe /c net stop winrm
27 | cmd.exe /c sc config winrm start= auto
28 | cmd.exe /c net start winrm
29 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
30 |
31 |
32 |
--------------------------------------------------------------------------------
/scripts/microsoft-updates.bat:
--------------------------------------------------------------------------------
1 | net stop wuauserv
2 |
3 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v EnableFeaturedSoftware /t REG_DWORD /d 1 /f
4 |
5 | reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v IncludeRecommendedUpdates /t REG_DWORD /d 1 /f
6 |
7 | echo Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager") > A:\temp.vbs
8 | echo Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") >> A:\temp.vbs
9 |
10 | cscript A:\temp.vbs
11 |
12 | net start wuauserv
--------------------------------------------------------------------------------
/scripts/openssh.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | [switch]$AutoStart = $false
3 | )
4 |
5 | Write-Host "AutoStart: $AutoStart"
6 | $is_64bit = [IntPtr]::size -eq 8
7 |
8 | # setup openssh
9 | $ssh_download_url = "http://www.mls-software.com/files/setupssh-6.6p1-1.exe"
10 | if ($is_64bit) {
11 | Write-Host "64 bit OS found"
12 | $ssh_download_url = "http://www.mls-software.com/files/setupssh-6.6p1-1(x64).exe"
13 | }
14 |
15 | if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
16 | Write-Host "Downloading $ssh_download_url"
17 | (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
18 | Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=22 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait
19 | }
20 |
21 | Stop-Service "OpenSSHd" -Force
22 |
23 | # ensure vagrant can log in
24 | Write-Host "Setting vagrant user file permissions"
25 | New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
26 | C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
27 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
28 | C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"
29 |
30 | Write-Host "Setting SSH home directories"
31 | (Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
32 | Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
33 | Set-Content 'C:\Program Files\OpenSSH\etc\passwd'
34 |
35 | # Set shell to /bin/sh to return exit status
36 | $passwd_file = Get-Content 'C:\Program Files\OpenSSH\etc\passwd'
37 | $passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh'
38 | Set-Content 'C:\Program Files\OpenSSH\etc\passwd' $passwd_file
39 |
40 | # fix opensshd to not be strict
41 | Write-Host "Setting OpenSSH to be non-strict"
42 | $sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
43 | $sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
44 | $sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
45 | $sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes'
46 | # disable the use of DNS to speed up the time it takes to establish a connection
47 | $sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
48 | # disable the login banner
49 | $sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt'
50 | Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config
51 |
52 | # use c:\Windows\Temp as /tmp location
53 | Write-Host "Setting temp directory location"
54 | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp"
55 | C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp"
56 | C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F"
57 |
58 | # add 64 bit environment variables missing from SSH
59 | Write-Host "Setting SSH environment"
60 | $sshenv = "TEMP=C:\Windows\Temp"
61 | if ($is_64bit) {
62 | $env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", `
63 | "ProgramW6432=C:\Program Files", `
64 | "CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files", `
65 | "CommonProgramW6432=C:\Program Files\Common Files"
66 | $sshenv = $sshenv + "`r`n" + ($env_vars -join "`r`n")
67 | }
68 | Set-Content C:\Users\vagrant\.ssh\environment $sshenv
69 |
70 | # record the path for provisioners (without the newline)
71 | Write-Host "Recording PATH for provisioners"
72 | Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte
73 |
74 | # configure firewall
75 | Write-Host "Configuring firewall"
76 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes
77 | netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes
78 | netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22
79 |
80 | Start-Service "OpenSSHd"
81 |
82 | Write-Host "Adding the default vagrant public key to ~/.ssh/authorized_keys:"
83 | Set-Content C:\Users\vagrant\.ssh\authorized_keys "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
--------------------------------------------------------------------------------
/scripts/oracle-cert.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mefellows/packer-community-templates/c34276519a26b83d9ccd64dc91f1b279efc2aaad/scripts/oracle-cert.cer
--------------------------------------------------------------------------------
/scripts/parallels-guest-tools.ps1:
--------------------------------------------------------------------------------
1 | cp C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp -Force
2 | & "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels
3 | C:\Windows\Temp\parallels\Autorun.exe /S
4 |
5 | Start-Sleep -s 60
--------------------------------------------------------------------------------
/scripts/provision.ps1:
--------------------------------------------------------------------------------
1 | # Enable basic Web Server features
2 | Install-WindowsFeature Web-Server
3 | Install-WindowsFeature Web-Mgmt-Tools
4 | Install-WindowsFeature Web-App-Dev -IncludeAllSubFeature
5 |
6 | # Install .NET and related tools so we can build/test/CI.
7 | choco install seek-dsc -y
8 | choco install netfx-4.5.1-devpack -y
9 | choco install microsoft-build-tools -y
10 | choco install vs2013agents -y
11 | Install-WindowsFeature NET-Framework-Core # needs to be here otherwise other packages above don't install
12 |
13 | # F# Bundle
14 | cd $env:TEMP
15 | $webclient = New-Object Net.WebClient
16 | $url = 'http://download.microsoft.com/download/E/A/3/EA38D9B8-E00F-433F-AAB5-9CDA28BA5E7D/FSharp_Bundle.exe'
17 | $webclient.DownloadFile($url, "$pwd\FSharp_Bundle.exe")
18 | .\FSharp_Bundle.exe /install /quiet
--------------------------------------------------------------------------------
/scripts/rsync.bat:
--------------------------------------------------------------------------------
1 | rem install rsync
2 | if not exist "C:\Windows\Temp\7z920-x64.msi" (
3 | powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" Skipping: $($Update.Title) because it requires user input"
56 | } else {
57 | if (!($Update.EulaAccepted)) {
58 | Write-Host "> Note: $($Update.Title) has a license agreement that must be accepted. Accepting the license."
59 | $Update.AcceptEula()
60 | [bool]$addThisUpdate = $true
61 | } else {
62 | [bool]$addThisUpdate = $true
63 | }
64 | }
65 |
66 | if ([bool]$addThisUpdate) {
67 | Write-Host "Adding: $($Update.Title)"
68 | $UpdatesToDownload.Add($Update) |Out-Null
69 | }
70 | }
71 | }
72 |
73 | if ($UpdatesToDownload.Count -eq 0) {
74 | Write-Host "No Updates To Download..."
75 | } else {
76 | Write-Host 'Downloading Updates...'
77 | $Downloader = $UpdateSession.CreateUpdateDownloader()
78 | $Downloader.Updates = $UpdatesToDownload
79 | $Downloader.Download()
80 | }
81 |
82 | $UpdatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'
83 | [bool]$rebootMayBeRequired = $false
84 | Write-Host 'The following updates are downloaded and ready to be installed:'
85 | foreach ($Update in $SearchResult.Updates) {
86 | if (($Update.IsDownloaded)) {
87 | Write-Host "> $($Update.Title)"
88 | $UpdatesToInstall.Add($Update) |Out-Null
89 |
90 | if ($Update.InstallationBehavior.RebootBehavior -gt 0){
91 | [bool]$rebootMayBeRequired = $true
92 | }
93 | }
94 | }
95 |
96 | if ($UpdatesToInstall.Count -eq 0) {
97 | Write-Host 'No updates available to install...'
98 | $global:MoreUpdates=0
99 | $global:RestartRequired=0
100 | Invoke-Expression "a:\openssh.ps1 -AutoStart"
101 | break
102 | }
103 |
104 | if ($rebootMayBeRequired) {
105 | Write-Host 'These updates may require a reboot'
106 | $global:RestartRequired=1
107 | }
108 |
109 | Write-Host 'Installing updates...'
110 |
111 | $Installer = $script:UpdateSession.CreateUpdateInstaller()
112 | $Installer.Updates = $UpdatesToInstall
113 | $InstallationResult = $Installer.Install()
114 |
115 | Write-Host "Installation Result: $($InstallationResult.ResultCode)"
116 | Write-Host "Reboot Required: $($InstallationResult.RebootRequired)"
117 | Write-Host 'Listing of updates installed and individual installation results:'
118 | if ($InstallationResult.RebootRequired) {
119 | $global:RestartRequired=1
120 | } else {
121 | $global:RestartRequired=0
122 | }
123 |
124 | for($i=0; $i -lt $UpdatesToInstall.Count; $i++) {
125 | New-Object -TypeName PSObject -Property @{
126 | Title = $UpdatesToInstall.Item($i).Title
127 | Result = $InstallationResult.GetUpdateResult($i).ResultCode
128 | }
129 | }
130 |
131 | Check-ContinueRestartOrEnd
132 | }
133 |
134 | function Check-WindowsUpdates() {
135 | Write-Host "Checking For Windows Updates"
136 | $Username = $env:USERDOMAIN + "\" + $env:USERNAME
137 |
138 | New-EventLog -Source $ScriptName -LogName 'Windows Powershell' -ErrorAction SilentlyContinue
139 |
140 | $Message = "Script: " + $ScriptPath + "`nScript User: " + $Username + "`nStarted: " + (Get-Date).toString()
141 |
142 | Write-EventLog -LogName 'Windows Powershell' -Source $ScriptName -EventID "104" -EntryType "Information" -Message $Message
143 | Write-Host $Message
144 |
145 | $script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
146 | $script:SearchResult = $script:UpdateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
147 | if ($SearchResult.Updates.Count -ne 0) {
148 | $script:SearchResult.Updates |Select-Object -Property Title, Description, SupportUrl, UninstallationNotes, RebootRequired, EulaAccepted |Format-List
149 | $global:MoreUpdates=1
150 | } else {
151 | Write-Host 'There are no applicable updates'
152 | $global:RestartRequired=0
153 | $global:MoreUpdates=0
154 | }
155 | }
156 |
157 | $script:ScriptName = $MyInvocation.MyCommand.ToString()
158 | $script:ScriptPath = $MyInvocation.MyCommand.Path
159 | $script:UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
160 | $script:UpdateSession.ClientApplicationID = 'Packer Windows Update Installer'
161 | $script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
162 | $script:SearchResult = New-Object -ComObject 'Microsoft.Update.UpdateColl'
163 | $script:Cycles = 0
164 |
165 | Check-WindowsUpdates
166 | if ($global:MoreUpdates -eq 1) {
167 | Install-WindowsUpdates
168 | } else {
169 | Check-ContinueRestartOrEnd
170 | }
--------------------------------------------------------------------------------
/scripts/winrmconfig.bat:
--------------------------------------------------------------------------------
1 | cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy bypass -Force"
2 | Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
3 | Restart-Service WinRM
4 | winrm quickconfig -q
5 | winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="512"}'
6 | winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
7 | winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
8 | winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
9 | winrm set "winrm/config/service/auth" '@{Basic="true"}'
10 | winrm set "winrm/config/client/auth" '@{CredSSP="true"}'
11 | winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
12 |
13 | # Need to run this on client and server
14 | Enable-WSManCredSSP -role client -delegatecomputer * -force
15 | Enable-WSManCredSSP -role client -delegatecomputer *.seek.int -force
16 | Enable-WSManCredSSP -role server -force
17 | Restart-Service WinRM
18 |
19 | C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy bypass -Force"
20 | cmd.exe /c winrm quickconfig -q
21 | cmd.exe /c winrm quickconfig '-transport:http'
22 | cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
23 | cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="512"}'
24 | cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
25 | cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
26 | cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
27 | cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
28 | cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
29 | cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
30 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
31 | cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
32 | cmd.exe /c net stop winrm
33 | cmd.exe /c sc config winrm start= auto
34 | cmd.exe /c net start winrm
35 |
36 | cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE
37 |
--------------------------------------------------------------------------------
/vagrantfile-windows_2012_r2.template:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 | Vagrant.require_version ">= 1.6.2"
5 |
6 | Vagrant.configure("2") do |config|
7 | config.vm.define "vagrant-windows-2012"
8 | config.vm.box = "windows2012r2"
9 | config.vm.communicator = "winrm"
10 |
11 | # Admin user name and password
12 | config.winrm.username = "vagrant"
13 | config.winrm.password = "vagrant"
14 |
15 | config.vm.guest = :windows
16 | config.windows.halt_timeout = 15
17 |
18 | config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
19 | config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
20 | config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
21 |
22 | config.vm.provider :virtualbox do |v, override|
23 | v.gui = true
24 | v.customize ["modifyvm", :id, "--memory", 2048]
25 | v.customize ["modifyvm", :id, "--cpus", 2]
26 | v.customize ["modifyvm", :id, "--vram", 64]
27 | v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
28 | end
29 |
30 | config.vm.provider :vmware_fusion do |v, override|
31 | v.gui = true
32 | v.vmx["memsize"] = "2048"
33 | v.vmx["numvcpus"] = "2"
34 | v.vmx["ethernet0.virtualDev"] = "vmxnet3"
35 | v.vmx["RemoteDisplay.vnc.enabled"] = "false"
36 | v.vmx["RemoteDisplay.vnc.port"] = "5900"
37 | v.vmx["scsi0.virtualDev"] = "lsisas1068"
38 | end
39 |
40 | config.vm.provider :vmware_workstation do |v, override|
41 | v.gui = true
42 | v.vmx["memsize"] = "2048"
43 | v.vmx["numvcpus"] = "2"
44 | v.vmx["ethernet0.virtualDev"] = "vmxnet3"
45 | v.vmx["RemoteDisplay.vnc.enabled"] = "false"
46 | v.vmx["RemoteDisplay.vnc.port"] = "5900"
47 | v.vmx["scsi0.virtualDev"] = "lsisas1068"
48 | end
49 | end
50 |
--------------------------------------------------------------------------------