forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
69 lines (58 loc) · 1.49 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
57
58
59
60
61
62
63
64
65
66
67
68
69
terraform {
required_providers {
metal = {
source = "equinix/metal"
}
}
}
variable "public_key_path" {}
variable "private_key_path" {}
variable "metal_token" {}
variable "metal_project_id" {}
variable "metal_plan" {}
variable "metal_location" {
default="sjc1"
}
variable "nodes" {
default = 1
}
provider "metal" {
auth_token = var.metal_token
}
resource "metal_ssh_key" "key1" {
name = "key1"
public_key = file(var.public_key_path)
}
# Create a device and add it to tf_project_1
resource "metal_device" "test" {
count = var.nodes
hostname = "test-${count.index}"
plan = var.metal_plan
facilities = [ var.metal_location ]
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = var.metal_project_id
depends_on = [ metal_ssh_key.key1 ]
connection {
type = "ssh"
host = metal_device.test[count.index].access_public_ipv4
user = "root"
private_key = file(var.private_key_path)
agent = false
}
provisioner "file" {
source="scripts"
destination="/provision"
}
provisioner "file" {
source="../../contrib/scripts/add_vagrant_box.sh"
destination="/provision"
}
provisioner "remote-exec" {
inline = [
"sudo chmod 755 /provision/*.sh",
"sudo /provision/install.sh",
"go get -u github.com/cilium/cilium || true"
]
}
}