-
Notifications
You must be signed in to change notification settings - Fork 1
/
packer-vbox.json
128 lines (127 loc) · 4.97 KB
/
packer-vbox.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
"builders": [
{
"communicator": "winrm",
"disk_size": "{{user `disk_size`}}",
"floppy_files": [
"answer_files/AutoUnattend.xml",
"scripts/winrm.ps1"
],
"guest_additions_mode": "disable",
"guest_os_type": "Windows2012_64",
"headless": true,
"iso_checksum": "{{user `iso_checksum`}}",
"iso_url": "{{user `iso_url`}}",
"post_shutdown_delay": "2m",
"shutdown_timeout": "15m",
"shutdown_command": "c:\\windows\\system32\\sysprep\\sysprep /generalize /quiet /oobe /shutdown /unattend:c:\\scripts\\unattend.xml",
"type": "virtualbox-iso",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--natpf1",
"winrm,tcp,,55985,,5985"
],
[
"modifyvm",
"{{.Name}}",
"--memory",
"16384"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"4"
]
],
"vm_name": "{{user `os_type`}}-{{timestamp}}",
"winrm_password": "{{user `winrm_password`}}",
"winrm_timeout": "5h",
"winrm_username": "{{user `winrm_username`}}"
}
],
"post-processors": [
{
"compression_level": 9,
"keep_input_artifact": false,
"output": "dynamics-{{user `os_type`}}-{{.Provider}}.box",
"type": "vagrant"
}
],
"provisioners": [
{
"inline": [
"winrm quickconfig -q",
"winrm set winrm/config/service/Auth @{Basic=\"true\"}",
"winrm set winrm/config/service @{AllowUnencrypted=\"true\"}",
"winrm set winrm/config/winrs @{MaxMemoryPerShellMB=\"1024\"}",
"netsh advfirewall set allprofiles state off"
],
"type": "windows-shell"
},
{
"inline": [
"powercfg /SetActive SCHEME_MIN",
"cmd /c schtasks /CHANGE /TN \"\\Microsoft\\Windows\\Windows Defender\\Windows Defender Cache Maintenance\" /RL LIMITED",
"cmd /c schtasks /CHANGE /TN \"\\Microsoft\\Windows\\Windows Defender\\Windows Defender Cleanup\" /RL LIMITED",
"cmd /c schtasks /CHANGE /TN \"\\Microsoft\\Windows\\Windows Defender\\Windows Defender Scheduled Scan\" /RL LIMITED",
"cmd /c schtasks /CHANGE /TN \"\\Microsoft\\Windows\\Windows Defender\\Windows Defender Verification\" /RL LIMITED",
"Install-WindowsFeature Net-Framework-Core,Windows-Identity-Foundation -IncludeAllSubFeature -source d:/sources/sxs",
"(New-Object System.Net.WebClient).DownloadFile('https://downloads.puppetlabs.com/windows/puppet6/puppet-agent-6.18.0-x64.msi', 'C:/Windows/Temp/puppet.msi')",
"cmd /c start /wait msiexec /qn /i C:\\Windows\\Temp\\puppet.msi /log C:\\Windows\\Temp\\puppet.log"
],
"type": "powershell"
},
{
"destination": "c:\\scripts\\unattend.xml",
"source": "answer_files/AutoUnattend.xml",
"type": "file"
},
{
"destination": "c:\\ProgramData\\PuppetLabs\\puppet\\etc\\hiera.yaml",
"source": "files/hiera.yaml",
"type": "file"
},
{
"destination": "c:\\windows\\temp\\puppet.zip",
"source": "puppet.zip",
"type": "file"
},
{
"scripts": [
"./scripts/puppet-apply.ps1"
],
"type": "powershell"
},
{
"inline": [
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12",
"Invoke-WebRequest -Uri https://download.virtualbox.org/virtualbox/{{user `vbox_ver`}}/VBoxGuestAdditions_{{user `vbox_ver`}}.iso -Outfile C:\\Users\\{{user `winrm_username`}}\\VBoxGuestAdditions.iso",
"Mount-DiskImage -ImagePath C:\\Users\\{{user `winrm_username`}}\\VBoxGuestAdditions.iso",
"c:\\windows\\system32\\cmd /c E:\\cert\\VBoxCertUtil.exe add-trusted-publisher e:\\cert\\vbox*.cer --root e:\\cert\\vbox*.cer",
"c:\\windows\\system32\\cmd /c start /b /wait E:\\VBoxWindowsAdditions.exe /S /force",
"Dismount-DiskImage -ImagePath C:\\Users\\{{user `winrm_username`}}\\VBoxGuestAdditions.iso",
"Remove-Item C:\\Users\\{{user `winrm_username`}}\\VBoxGuestAdditions.iso -Force",
"Move-Item -Path c:\\ProgramData\\Puppetlabs\\code -Destination c:\\ProgramData\\Puppetlabs\\code.build -Force",
"icacls c:\\ProgramData\\Puppetlabs /grant {{user `winrm_username`}}:F /Q /C /T",
"icacls c:\\ProgramData\\Puppetlabs /grant everyone:F /Q /C /T",
"icacls \"c:\\Program Files\\Puppet Labs\" /grant {{user `winrm_username`}}:F /Q /C /T",
"icacls c:\\Scripts /grant {{user `winrm_username`}}:F /Q /C /T",
"if (Test-Path c:\\scripts\\prefix) { Remove-Item C:\\Scripts\\prefix -Force }"
],
"type": "powershell"
}
],
"variables": {
"build_user": "{{env `USERNAME`}}",
"disk_size": "{{env `DISK_SIZE`}}",
"iso_checksum": "md5:{{env `ISO_MD5`}}",
"iso_url": "{{env `ISO_URL`}}",
"os_type": "{{env `OS_TYPE`}}",
"vbox_ver": "{{env `VBOX_VER`}}",
"winrm_password": "{{env `WINRM_PASSWORD`}}",
"winrm_username": "{{env `WINRM_USERNAME`}}"
}
}