-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfocal.json.pkr.hcl
executable file
·201 lines (187 loc) · 6.12 KB
/
focal.json.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
source "hyperv-iso" "focal" {
boot_wait = "4s"
boot_command = [
"<esc><esc><esc>",
"set gfxpayload=keep<enter>",
"linux /casper/vmlinuz ",
"\"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
"quiet autoinstall ---<enter>",
"initrd /casper/initrd<enter>",
"boot<enter>",
]
headless = false
switch_name = "Default Switch"
http_directory = "http"
iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
iso_url = "source/ubuntu-20.04.4-live-server-amd64.iso"
memory = var.memory # variable example
ssh_password = "ubuntu"
ssh_username = "ubuntu"
ssh_timeout = "2h"
ssh_handshake_attempts = 20
communicator = "ssh"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
generation = 2
}
source "hyperv-iso" "jammy" {
boot_wait = "4s"
boot_command = [
"<esc><esc><esc>",
"set gfxpayload=keep<enter>",
"linux /casper/vmlinuz ",
"\"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
"quiet autoinstall ---<enter>",
"initrd /casper/initrd<enter>",
"boot<enter>",
]
headless = false
switch_name = "Default Switch"
http_directory = "http"
iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
iso_url = "source/ubuntu-20.04.4-live-server-amd64.iso"
memory = var.memory # variable example
ssh_password = "ubuntu"
ssh_username = "ubuntu"
ssh_timeout = "2h"
ssh_handshake_attempts = 20
communicator = "ssh"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
generation = 2
}
source "qemu" "focal" {
iso_url = "source/ubuntu-20.04.4-live-server-amd64.iso"
iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
output_directory = "kvm-focal"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
disk_size = "8G"
memory = var.memory # variable example
format = "qcow2" #raw also supported
accelerator = "kvm"
http_directory = "http"
ssh_username = "ubuntu"
ssh_password = "ubuntu"
ssh_timeout = "2h"
shutdown_timeout = "2h"
ssh_handshake_attempts = 2000
vm_name = "example"
net_device = "virtio-net"
disk_interface = "virtio"
boot_wait = "3s"
firmware = "OVMF.fd"
boot_command = [
"<esc><esc><esc>",
"linux /casper/vmlinuz ",
"\"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
"autoinstall ---<enter>",
"initrd /casper/initrd<enter>",
"boot<enter>",
]
}
source "qemu" "jammy" {
iso_url = "source/ubuntu-22.04.1-live-server-amd64.iso"
iso_checksum = "10f19c5b2b8d6db711582e0e27f5116296c34fe4b313ba45f9b201a5007056cb"
output_directory = "kvm-output"
shutdown_command = "shutdown now"
disk_size = "8G"
memory = var.memory # variable example
format = "qcow2"
accelerator = "kvm"
http_directory = "http"
ssh_username = "ubuntu"
ssh_password = "ubuntu"
ssh_timeout = "2h"
shutdown_timeout = "2h"
ssh_handshake_attempts = 2000
vm_name = "example"
net_device = "virtio-net"
disk_interface = "virtio"
boot_wait = "4s"
firmware = "OVMF.fd"
boot_command = [
"c",
"linux /casper/vmlinuz ",
"\"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
"autoinstall ---<enter>",
"initrd /casper/initrd<enter>",
"boot<enter>",
]
}
source "lxd" "focal" {
image = "ubuntu:focal"
output_image = "packer-focal"
#https://stgraber.org/2016/03/30/lxd-2-0-image-management-512/
publish_properties = {
description = "Base LXD packer template"
}
virtual_machine = true
}
source "lxd" "jammy" {
image = "ubuntu:jammy"
output_image = "packer-jammy"
#https://stgraber.org/2016/03/30/lxd-2-0-image-management-512/
publish_properties = {
description = "Base LXD packer template"
}
virtual_machine = true
}
source "vmware-iso" "focal" {
iso_url = "source/ubuntu-20.04.4-live-server-amd64.iso"
iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
ssh_username = "ubuntu"
ssh_password = var.sudo_password #secret varaiable example
shutdown_command = "shutdown -P now"
http_directory = "http"
disk_size = 40960
disk_type_id = 0
guest_os_type = "ubuntu64Guest"
vm_name = "PackerVM"
cpus = 2
memory = var.memory
boot_command = [
"<esc><esc><esc>",
"<enter><wait>",
"/casper/vmlinuz ",
"root=/dev/sr0 ",
"initrd=/casper/initrd ",
"autoinstall ",
"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"<enter>"
]
boot_wait = "5s"
ssh_port = 22
}
source "vmware-iso" "jammy" {
iso_url = "source/ubuntu-22.04.1-live-server-amd64.iso"
iso_checksum = "10f19c5b2b8d6db711582e0e27f5116296c34fe4b313ba45f9b201a5007056cb"
ssh_username = "ubuntu"
ssh_password = var.sudo_password #secret varaiable example
shutdown_command = "shutdown -P now"
http_directory = "http"
disk_size = 40960
disk_type_id = 0
guest_os_type = "ubuntu64Guest"
vm_name = "PackerVM"
cpus = 2
memory = var.memory
boot_command = [
"<esc><esc><esc>",
"<enter><wait>",
"/casper/vmlinuz ",
"root=/dev/sr0 ",
"initrd=/casper/initrd ",
"autoinstall ",
"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"<enter>"
]
boot_wait = "5s"
ssh_port = 22
}
build {
sources = ["lxd.jammy"] #swap this to build different images
provisioner "shell" {
inline = ["ls /"]
}
post-processor "shell-local" {
inline = ["echo foo"]
}
}