-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathproxmox-ve-vsphere.pkr.hcl
170 lines (150 loc) · 3.68 KB
/
proxmox-ve-vsphere.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
packer {
required_plugins {
# see https://github.com/hashicorp/packer-plugin-vsphere
vsphere = {
version = "1.4.2"
source = "github.com/hashicorp/vsphere"
}
}
}
variable "cpus" {
type = number
default = 2
}
variable "memory" {
type = number
default = 2 * 1024
}
variable "disk_size" {
type = number
default = 20 * 1024
}
variable "vsphere_os_iso" {
type = string
default = env("VSPHERE_OS_ISO")
}
variable "vsphere_host" {
type = string
default = env("GOVC_HOST")
}
variable "vsphere_username" {
type = string
default = env("GOVC_USERNAME")
}
variable "vsphere_password" {
type = string
default = env("GOVC_PASSWORD")
}
variable "vsphere_esxi_host" {
type = string
default = env("VSPHERE_ESXI_HOST")
}
variable "vsphere_datacenter" {
type = string
default = env("GOVC_DATACENTER")
}
variable "vsphere_cluster" {
type = string
default = env("GOVC_CLUSTER")
}
variable "vsphere_datastore" {
type = string
default = env("GOVC_DATASTORE")
}
variable "vsphere_folder" {
type = string
default = env("VSPHERE_TEMPLATE_FOLDER")
}
variable "vsphere_network" {
type = string
default = env("VSPHERE_VLAN")
}
variable "vsphere_ip_wait_address" {
type = string
default = env("VSPHERE_IP_WAIT_ADDRESS")
}
variable "apt_cache_host" {
type = string
default = env("APT_CACHE_HOST")
}
variable "apt_cache_port" {
type = string
default = env("APT_CACHE_PORT")
}
variable "shell_provisioner_scripts" {
type = list(string)
default = [
"provisioners/apt_proxy.sh",
"provisioners/upgrade.sh",
"provisioners/network.sh",
"provisioners/localisation-pt.sh",
"provisioners/reboot.sh",
"provisioners/provision.sh",
]
}
source "vsphere-iso" "proxmox-ve-amd64" {
vm_name = "proxmox-ve-amd64"
guest_os_type = "debian12_64Guest"
NestedHV = true
CPUs = var.cpus
RAM = var.memory
storage {
disk_size = var.disk_size
disk_thin_provisioned = true
}
disk_controller_type = ["pvscsi"]
iso_paths = [
var.vsphere_os_iso,
]
vcenter_server = var.vsphere_host
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = true
datacenter = var.vsphere_datacenter
cluster = var.vsphere_cluster
host = var.vsphere_esxi_host
folder = var.vsphere_folder
datastore = var.vsphere_datastore
network_adapters {
network = var.vsphere_network
network_card = "vmxnet3"
}
convert_to_template = true
ssh_username = "root"
ssh_password = "vagrant"
ssh_timeout = "60m"
cd_label = "proxmox-ais"
cd_files = ["answer.toml"]
boot_wait = "5s"
boot_command = [
# select Advanced Options.
"<end><enter>",
# select Install Proxmox VE (Automated).
"<down><down><down><enter>",
# wait for the shell prompt.
"<wait1m>",
# do the installation.
"proxmox-fetch-answer partition proxmox-ais >/run/automatic-installer-answers<enter><wait>exit<enter>",
# wait for the installation to finish.
"<wait4m>",
# login.
"root<enter><wait5s>vagrant<enter><wait5s>",
# install the guest agent.
"apt-get update<enter><wait1m>",
"apt-get install -y open-vm-tools<enter><wait30s>",
]
shutdown_command = "poweroff"
}
build {
sources = [
"source.vsphere-iso.proxmox-ve-amd64",
]
provisioner "shell" {
expect_disconnect = true
environment_vars = [
"apt_cache_host=${var.apt_cache_host}",
"apt_cache_port=${var.apt_cache_port}",
]
scripts = var.shell_provisioner_scripts
}
}