-
Notifications
You must be signed in to change notification settings - Fork 1
/
ol7-vcenter.pkr.hcl
executable file
·235 lines (188 loc) · 4.66 KB
/
ol7-vcenter.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
#----------------------------------------------------------------------------------
# Packer template to build an Oracle Linux R7 image on VMware vCenter
# juliusn - Sun Dec 5 08:48:39 EST 2021
#----------------------------------------------------------------------------------
packer {
required_version = ">= 1.7.0"
}
source "vsphere-iso" "oraclelinux" {
# VM settings
vm_name = var.vm_name
guest_os_type = "oraclelinux7_64Guest"
shutdown_command = "shutdown -h now"
vm_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
CPU_hot_plug = true
RAM = var.ram_gb * 1024
RAM_hot_plug = true
disk_controller_type = ["pvscsi"]
network_adapters {
network = var.vcenter_port_group
network_card = "vmxnet3"
}
storage {
disk_size = var.vm_disk_size
disk_thin_provisioned = true
}
# vCenter settings
vcenter_server = var.vcenter_hostname
username = var.vcenter_username
password = var.vcenter_password
cluster = var.vcenter_cluster
datacenter = var.vcenter_datacenter
datastore = var.vcenter_datastore
folder = var.vcenter_folder
insecure_connection = true
convert_to_template = true
remove_cdrom = true
boot_order = "disk,cdrom"
http_directory = "http_directory/oracle-linux"
boot_command = [
"<wait><esc><wait> linux ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ol7-kickstart.cfg<enter><wait>"
]
}
build {
sources = [
"sources.vsphere-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
}