-
Notifications
You must be signed in to change notification settings - Fork 2
/
variables.pkr.hcl
230 lines (195 loc) · 5.47 KB
/
variables.pkr.hcl
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
variable "name" {
description = "The name of the virtual machine"
type = string
default = "sift"
}
variable "guest_os_type" {
description = "The guest_os_type (default: ubuntu-64)"
type = string
default = "ubuntu-64"
}
variable "output_directory" {
description = "The location to build all virtual machines to"
type = string
default = "_outputs"
}
variable "source_directory" {
description = "The location to source a VMX from, leave blank for calculated"
type = string
default = ""
}
variable "username" {
description = "The default username for the OS"
type = string
default = "sansforensics"
}
variable "password" {
description = "The password for the the default user for the OS"
type = string
default = "forensics"
}
variable "ubuntu_images_url" {
description = "The default place to obtain the OS images from"
type = string
#default = "http://archive.ubuntu.com/ubuntu/dists/jammy/main/installer-amd64/current/legacy-images"
default = "https://releases.ubuntu.com/22.04.1"
}
variable "ubuntu_images_iso_filename" {
description = "The default filename for the server install"
type = string
default = "ubuntu-22.04.1-live-server-amd64.iso"
}
variable "accelerator" {
description = "The accelerator to use, only useful with QEMU builds"
type = string
default = "kvm"
}
variable "headless" {
description = "Whether or not to build the VM headless"
type = string
default = "false"
}
variable "cpus" {
description = "The number of CPUs to give to the virtual machine during the build"
type = string
default = "4"
}
variable "memory" {
description = "The amount of memory to give to the virtual machine during the build"
type = string
default = "4096"
}
variable "disk_size" {
description = "Disk Size for the primary drive (in MB)"
type = string
default = "500000"
}
variable "vmware_disk_type_id" {
description = "VMWare Disk Type ID"
type = number
default = 0
}
variable "http_proxy" {
type = string
default = ""
}
variable "https_proxy" {
type = string
default = ""
}
variable "no_proxy" {
type = string
default = ""
}
variable "aws_region" {
description = "AWS Region to use by default for any AMI or EBS Builds"
type = string
default = "us-east-2"
}
variable "aws_regions" {
description = "List of AWS Regions to copy the AMI to (only valid for amazon-ebs builder)"
type = list(string)
default = [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-central-1",
"eu-north-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-southeast-1",
"ap-southeast-2",
]
}
variable "aws_ami" {
description = "AWS Base AMI to build on top of (leave empty for source_filter to be used)"
type = string
default = ""
}
variable "aws_ami_source_filter_name" {
description = "AWS Source AMI Filter Name"
type = string
default = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*"
}
variable "aws_ami_source_owner" {
description = "AWS Source AMI Owner"
type = list(string)
default = ["099720109477"]
}
variable "aws_instance_type" {
description = "AWS Instance Type"
type = string
default = "m4.xlarge"
# default = "a1.xlarge"
}
variable "aws_volume_size" {
description = "AWS Root Block Volume Size (expressed in GB)"
type = number
default = 20
}
variable "aws_accounts" {
description = "AWS Accounts that any AMI created should be allowed to use"
type = list(string)
default = []
}
variable "aws_vpc_filters" {
description = "The filter used to select the VPC to launch AMI builders into"
type = map(string)
default = {}
}
variable "aws_vpc_subnet_filters" {
description = "The filter used to select the subnet in the VPC to launch AMI builders into"
type = map(string)
default = {}
}
variable "aws_tags" {
description = "Tags to add the the AMI image"
type = map(string)
default = {}
}
variable "development_mode" {
description = "Enable development for the build"
type = bool
default = false
}
locals {
timestamp = formatdate("YYYY-MM-DD-hhmm", timestamp())
cloud_config = templatefile("builtin_files/cloud-config.yaml", {
hostname = var.name
username = var.username
password = bcrypt(var.password)
})
user_data = templatefile("builtin_files/aws-cloud-config.yaml", {
username = var.username,
})
ubuntu_desktop_preseed = templatefile("builtin_files/ubuntu-desktop-preseed.cfg", {
username = var.username,
password = var.password,
})
boot_command = [
"c<wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/\"",
"<enter><wait>",
"initrd /casper/initrd",
"<enter><wait>",
"boot",
"<enter>"
]
shutdown_command = "echo '${var.password}' | sudo -S shutdown -P now"
iso_checksum = "file:${var.ubuntu_images_url}/SHA256SUMS"
iso_urls = ["${var.ubuntu_images_url}/${var.ubuntu_images_iso_filename}"]
script_environment_variables = [
"DEBIAN_FRONTEND=noninteractive",
"SSH_USERNAME=${var.username}",
"SSH_PASSWORD=${var.password}",
"http_proxy=${var.http_proxy}",
"https_proxy=${var.https_proxy}",
"no_proxy=${var.no_proxy}",
]
vmware_vmx_source = var.source_directory != "" ? var.source_directory : "${var.name}-vmware-iso"
}