-
Notifications
You must be signed in to change notification settings - Fork 1
/
packer-azure.json
88 lines (87 loc) · 3.48 KB
/
packer-azure.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
{
"builders": [
{
"type": "azure-arm",
"client_id": "{{user `azure_client_id`}}",
"client_secret": "{{user `azure_client_secret`}}",
"tenant_id": "{{user `azure_tenant_id`}}",
"subscription_id": "{{user `azure_subscription_id`}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",
"disk_caching_type": "ReadWrite",
"communicator": "winrm",
"winrm_username": "vagrant",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "60m",
"vm_size": "Standard_A2_v2",
"location": "UK South",
"azure_tags": {
"dept": "dynamics"
},
"managed_image_name": "dynamics",
"managed_image_resource_group_name": "NetworkWatcherRG"
}
],
"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"
},
{
"type": "powershell",
"inline": [
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit /mode:vm",
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }"
]
}
],
"variables": {
"azure_client_id": "{{env `AZURE_CLIENT_ID`}}",
"azure_client_secret": "{{env `AZURE_CLIENT_SECRET`}}",
"azure_tenant_id": "{{env `AZURE_TENANT_ID`}}",
"azure_subscription_id": "{{env `AZURE_SUBSCRIPTION_ID`}}"
}
}