Skip to content

Instantly share code, notes, and snippets.

@matilote

matilote/main.tf Secret

Created August 3, 2020 11:06
Show Gist options
  • Save matilote/c1ec9955edc3c2140f6e52eb092376f8 to your computer and use it in GitHub Desktop.
Save matilote/c1ec9955edc3c2140f6e52eb092376f8 to your computer and use it in GitHub Desktop.
resource "digitalocean_droplet" "node" {
image = "ubuntu-20-04-x64"
name = "${var.hostname}-${var.TF_VAR_chain}"
region = "lon1"
size = "s-2vcpu-4gb"
ssh_keys = flatten([
var.ssh_fingerprint
])
connection {
user = "root"
type = "ssh"
private_key = "${file(var.pvt_key)}"
timeout = "2m"
host = self.ipv4_address
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"sudo apt-get update",
"sudo apt-get install -y docker.io",
"git clone https://github.com/NethermindEth/nethermind.git",
"cd nethermind/",
"git checkout ${var.TF_VAR_tag}",
"sudo sed -i '14s|.*|ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:4111|' /lib/systemd/system/docker.service",
"sudo systemctl daemon-reload",
"sudo systemctl restart docker",
"docker build -t nethermind .",
"docker run -itd --network host --name nethermind -v /root/logs:/nethermind/logs nethermind --config ${var.TF_VAR_chain} --JsonRpc.Enabled true --JsonRpc.Host 0.0.0.0 --Metrics.Enabled true --Metrics.NodeName 'SMOKE ${var.TF_VAR_chain} ${var.TF_VAR_tag}' --Metrics.PushGatewayUrl ${var.gateway}",
]
}
}
resource "local_file" "node_ip" {
content = "${digitalocean_droplet.node.ipv4_address}"
filename = "node_ip.txt"
}
output "public_ip" {
description = "output the public ip of provider instance"
value = "${digitalocean_droplet.node.ipv4_address}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment