-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
54 lines (46 loc) · 1.3 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
data "template_file" "config" {
template = "${file("${path.module}/assets/config.cfg")}"
vars {
userlist = "${jsonencode(var.users)}"
ip_address = "${module.vm.ip_address}"
}
}
module "vm" {
source = "armorfret/algo-base/linode"
version = "0.0.5"
name = "${var.name}"
ssh_keys = ["${var.ssh_keys}"]
ssh_users = ["${var.ssh_users}"]
region = "${var.region}"
type = "${var.type}"
algo_repo = "${var.algo_repo}"
source_image_id = "${var.image_id}"
}
resource "null_resource" "configuration" {
triggers = {
linode_id = "${module.vm.linode_id}"
ip_address = "${module.vm.ip_address}"
content = "${data.template_file.config.rendered}"
}
connection {
type = "ssh"
user = "root"
host = "${module.vm.ip_address}"
}
provisioner "file" {
content = "${data.template_file.config.rendered}"
destination = "/opt/algo/config.cfg"
}
provisioner "remote-exec" {
script = "${path.module}/assets/deploy.sh"
}
provisioner "local-exec" {
command = "${path.module}/assets/download.sh"
working_dir = "${path.root}"
environment = {
VPN_IP_ADDRESS = "${module.vm.ip_address}"
VPN_NAME = "${var.name}"
VPN_REGION = "${var.region}"
}
}
}