-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
56 lines (49 loc) · 1.41 KB
/
main.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
50
51
52
53
54
55
56
locals {
address = var.address
user = var.user
version = var.vs
}
resource "tailscale_tailnet_key" "key" {
reusable = true
ephemeral = false
preauthorized = true
}
resource "null_resource" "deploy_tailscale" {
depends_on = [
tailscale_tailnet_key.key,
]
connection {
type = "ssh"
user = local.user
script_path = "/home/${local.user}/deploy_tailscale.sh"
agent = true
host = local.address
}
provisioner "file" {
content = file("${path.module}/install_tailscale.sh")
destination = "/home/${local.user}/install_tailscale.sh"
}
provisioner "file" {
content = file("${path.module}/tailscaled.defaults")
destination = "/home/${local.user}/tailscaled.defaults"
}
provisioner "file" {
content = file("${path.module}/tailscaled.service")
destination = "/home/${local.user}/tailscaled.service"
}
provisioner "remote-exec" {
inline = [<<-EOT
sudo mv /home/${local.user}/tailscaled.service /root/tailscaled.service
sudo mv /home/${local.user}/tailscaled.defaults /root/tailscaled.defaults
sudo mv /home/${local.user}/install_tailscale.sh /root/install_tailscale.sh
sudo chmod +x /root/install_tailscale.sh
EOT
]
}
provisioner "remote-exec" {
inline = [<<-EOT
sudo /root/install_tailscale.sh ${local.version} ${tailscale_tailnet_key.key.key}
EOT
]
}
}