-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdebian.pkr.hcl
132 lines (110 loc) · 2.54 KB
/
debian.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
packer {
required_plugins {
proxmox = {
version = ">= 1.1.3"
source = "github.com/hashicorp/proxmox"
}
}
}
variable "iso_file" {
type = string
}
variable "cloudinit_storage_pool" {
type = string
default = "local-lvm"
}
variable "cores" {
type = string
default = "2"
}
variable "disk_format" {
type = string
default = "raw"
}
variable "disk_size" {
type = string
default = "20G"
}
variable "disk_storage_pool" {
type = string
default = "local-lvm"
}
variable "cpu_type" {
type = string
default = "kvm64"
}
variable "memory" {
type = string
default = "2048"
}
variable "network_vlan" {
type = string
default = ""
}
variable "machine_type" {
type = string
default = ""
}
variable "proxmox_api_password" {
type = string
sensitive = true
}
variable "proxmox_api_user" {
type = string
}
variable "proxmox_host" {
type = string
}
variable "proxmox_node" {
type = string
}
source "proxmox-iso" "debian" {
proxmox_url = "https://${var.proxmox_host}/api2/json"
insecure_skip_tls_verify = true
username = var.proxmox_api_user
password = var.proxmox_api_password
template_description = "Built from ${basename(var.iso_file)} on ${formatdate("YYYY-MM-DD hh:mm:ss ZZZ", timestamp())}"
node = var.proxmox_node
network_adapters {
bridge = "vmbr0"
firewall = true
model = "virtio"
vlan_tag = var.network_vlan
}
disks {
disk_size = var.disk_size
format = var.disk_format
io_thread = true
storage_pool = var.disk_storage_pool
type = "scsi"
}
scsi_controller = "virtio-scsi-single"
http_directory = "./"
boot_wait = "10s"
boot_command = ["<esc><wait>auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<enter>"]
boot_iso {
type = "scsi"
iso_file = var.iso_file
unmount = true
}
cloud_init = true
cloud_init_storage_pool = var.cloudinit_storage_pool
vm_name = trimsuffix(basename(var.iso_file), ".iso")
cpu_type = var.cpu_type
os = "l26"
memory = var.memory
cores = var.cores
sockets = "1"
machine = var.machine_type
# Note: this password is needed by packer to run the file provisioner, but
# once that is done - the password will be set to random one by cloud init.
ssh_password = "packer"
ssh_username = "root"
}
build {
sources = ["source.proxmox-iso.debian"]
provisioner "file" {
destination = "/etc/cloud/cloud.cfg"
source = "cloud.cfg"
}
}