-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-install-vpn.tf
50 lines (44 loc) · 1.13 KB
/
06-install-vpn.tf
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
resource "random_string" "ipsec_psk" {
length = 20
min_upper = 2
min_lower = 2
min_numeric = 2
min_special = 2
override_special = "$!?@*"
}
resource "random_string" "vpn_pass" {
length = 16
min_upper = 2
min_lower = 2
min_numeric = 2
min_special = 2
override_special = "$!?@*"
}
data "template_file" "vpn_installer" {
template = file("templates/l2tp_vpn.sh")
vars = {
ipsec_psk = random_string.ipsec_psk.result
vpn_user = var.vpn_user
vpn_pass = random_string.vpn_pass.result
}
}
resource "null_resource" "install_vpn_server" {
depends_on = [null_resource.download_vcenter_iso]
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/${local.ssh_key_name}")
host = packet_device.router.access_public_ipv4
}
provisioner "file" {
content = data.template_file.vpn_installer.rendered
destination = "/root/vpn_installer.sh"
}
provisioner "remote-exec" {
inline = [
"cd /root",
"chmod +x /root/vpn_installer.sh",
"/root/vpn_installer.sh"
]
}
}