-
Notifications
You must be signed in to change notification settings - Fork 1
/
ol7-esxi.pkr.hcl
executable file
·241 lines (194 loc) · 5.05 KB
/
ol7-esxi.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
231
232
233
234
235
236
237
238
239
240
241
#----------------------------------------------------------------------------------
# Packer template to build an Oracle Linux R7 image on VMware ESXi
# juliusn - Sun Dec 5 08:48:39 EST 2021
#----------------------------------------------------------------------------------
source "vmware-iso" "oraclelinux" {
# VM settings
vm_name = var.vm_name
display_name = var.vm_name
guest_os_type = "oraclelinux7-64"
shutdown_command = "shutdown -h now"
version = var.vm_guest_version
iso_url = var.vm_iso_url
iso_checksum = var.vm_iso_checksum
ssh_username = var.vm_access_username
ssh_password = var.vm_access_password
ssh_timeout = var.vm_ssh_timeout
cpus = var.cpu_count
memory = var.ram_gb * 1024
cdrom_adapter_type = "sata"
disk_size = var.vm_disk_size
disk_adapter_type = "pvscsi"
vmdk_name = "${var.vm_name}_disk"
usb = "true"
network_adapter_type = "vmxnet3"
# ESXi settings
disk_type_id = "thin"
remote_type = var.esx_remote_type
remote_host = var.esx_remote_hostname
remote_datastore = var.esx_remote_datastore
remote_username = var.esx_remote_username
remote_password = var.esx_remote_password
keep_registered = true
skip_export = true
skip_compaction = true
headless = true
vnc_over_websocket = true
insecure_connection = true
vmx_data = {
"ethernet0.present" = "TRUE"
"ethernet0.virtualdev" = "vmxnet3"
"ethernet0.networkName" = "${var.esx_port_group}"
"scsi0.virtualdev" = "pvscsi"
"annotation" = "${var.vm_name}"
"vhv.enable" = "TRUE"
"nestedHVEnabled" = "TRUE"
}
boot_wait = var.boot_wait_iso
boot_key_interval = var.boot_key_interval_iso
boot_keygroup_interval = var.boot_keygroup_interval_iso
http_directory = "http_directory/oracle-linux"
boot_command = [
"<wait><esc><wait> linux ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ol7-kickstart.cfg<enter><wait>"
]
}
build {
sources = [
"sources.vmware-iso.oraclelinux"
]
provisioner "file" {
sources = ["tkg-scripts"]
destination = "/root/scripts"
}
provisioner "file" {
sources = ["certs"]
destination = "/root/certs"
}
provisioner "shell" {
scripts = [
"tkg-scripts/10-update-certificates.sh",
"tkg-scripts/11-oraclelinux-settings.sh",
"tkg-scripts/12-oraclelinux-docker.sh",
"tkg-scripts/14-install-hashicorp.sh",
"tkg-scripts/15-install-govc.sh",
"tkg-scripts/16-install-nmon.sh",
"tkg-scripts/17-install-password-store.sh",
"tkg-scripts/19-user-settings.sh",
"tkg-scripts/20-oraclelinux-cleanup.sh",
"tkg-scripts/21-install-ntp-client.sh",
"tkg-scripts/22-install-postfix.sh",
# "tkg-scripts/27-install-powershell.sh",
"tkg-scripts/31-download-k8s-tools.sh"
]
}
provisioner "file" {
sources = ["ova"]
destination = "/home/tkg/ova"
}
provisioner "file" {
sources = ["tkg"]
destination = "/home/tkg/tkg"
}
provisioner "shell" {
inline = [
"chown -R tkg:tkg /home/tkg/ova",
"chown -R tkg:tkg /home/tkg/tkg",
"su - tkg -c /home/tkg/scripts/33-tkg-install.sh",
"su - tkg -c /home/tkg/scripts/36-configure-password-store.sh"
]
}
post-processor "manifest" {
output = "oraclelinux.manifest.json"
strip_path = true
}
}
variable "vm_name" {
type = string
}
variable "vm_guest_os_type" {
type = string
}
variable "vm_guest_version" {
type = string
}
variable "vm_access_username" {
type = string
}
variable "vm_access_password" {
type = string
}
variable "vm_ssh_timeout" {
type = string
}
variable "cpu_count" {
type = number
}
variable "ram_gb" {
type = number
}
variable "vm_disk_size" {
type = number
}
variable "boot_key_interval_iso" {
type = string
}
variable "boot_wait_iso" {
type = string
}
variable "boot_keygroup_interval_iso" {
type = string
}
variable "vm_iso_url" {
type = string
}
variable "vm_iso_checksum" {
type = string
}
variable "vcenter_hostname" {
type = string
}
variable "vcenter_username" {
type = string
}
variable "vcenter_password" {
type = string
}
variable "vcenter_cluster" {
type = string
}
variable "vcenter_datacenter" {
type = string
}
variable "vcenter_datastore" {
type = string
}
variable "vcenter_folder" {
type = string
}
variable "vcenter_port_group" {
type = string
}
variable "esx_remote_type" {
type = string
}
variable "esx_remote_hostname" {
type = string
}
variable "esx_remote_datastore" {
type = string
}
variable "esx_remote_username" {
type = string
}
variable "esx_remote_password" {
type = string
}
variable "esx_port_group" {
type = string
}
variable "fusion_app_directory" {
type = string
}
variable "fusion_output_directory" {
type = string
}