-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwgvpn.pkr.hcl
67 lines (63 loc) · 1.87 KB
/
wgvpn.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
variable "root_password" {
type = string
default = ""
sensitive = true
}
source "vmware-iso" "wgvpn" {
iso_url = "https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.3-x86_64.iso"
iso_checksum = "sha256:b432eb9a71b7f5531cb7868c82f405cc63c052358698f44fbfe06103b40fa1bb"
vm_name = "wgvpn"
version = "13"
guest_os_type = "other3xlinux-64"
cores = 1
cpus = 1
memory = 512
disk_size = 1024
boot_wait = "15s"
http_directory = "http"
shutdown_command = "/sbin/poweroff"
ssh_timeout = "30m"
ssh_username = "root"
ssh_password = "${var.root_password}"
network_adapter_type = "VMXNET3"
vmx_data = {
"disk.EnableUUID" = "TRUE"
"scsi0.virtualdev" = "pvscsi"
}
boot_command = [
"root<enter><wait>",
"ifconfig eth0 up<enter>",
"udhcpc -i eth0<enter><wait10>",
"wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers<enter><wait>",
"setup-alpine -f answers<enter><wait10>",
"${var.root_password}<enter><wait>",
"${var.root_password}<enter>",
"<wait20s>y<enter><wait30s>",
"reboot<enter><wait30s>",
"root<enter><wait>",
"${var.root_password}<enter><wait>",
"sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/g' /etc/ssh/sshd_config<enter>",
"service sshd restart<enter>",
"exit<enter>"
]
}
build {
sources = ["source.vmware-iso.wgvpn"]
provisioner "file" {
sources = [
"files/wireguard.openrc",
"files/wg.conf.tmpl",
"files/motd"
]
destination = "/tmp/"
}
provisioner "shell" {
scripts = [
"files/setup.sh",
"files/cleanup.sh"
]
}
post-processor "shell-local" {
inline = ["ovftool output-wgvpn/wgvpn.vmx wgvpn-`date +%Y%m%d`.ova", "rm -rf output-wgvpn"]
}
}