Skip to content

Commit 6545531

Browse files
committed
move gemini-3h primitives to archive
1 parent 68b7b04 commit 6545531

25 files changed

+3469
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
data "aws_ami" "ubuntu_amd64" {
2+
most_recent = true
3+
4+
filter {
5+
name = "name"
6+
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
7+
}
8+
9+
filter {
10+
name = "virtualization-type"
11+
values = ["hvm"]
12+
}
13+
14+
filter {
15+
name = "architecture"
16+
values = ["x86_64"]
17+
}
18+
19+
owners = ["099720109477"]
20+
}
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
locals {
2+
autoid_nodes_ip_v4 = flatten([
3+
[aws_instance.autoid_node.*.public_ip]
4+
]
5+
)
6+
autoid_nodes_ip_v6 = flatten([
7+
[aws_instance.autoid_node.*.ipv6_addresses]
8+
]
9+
)
10+
}
11+
12+
resource "null_resource" "setup-autoid-nodes" {
13+
count = length(local.autoid_nodes_ip_v4)
14+
15+
depends_on = [aws_instance.autoid_node]
16+
17+
# trigger on node ip changes
18+
triggers = {
19+
cluster_instance_ipv4s = join(",", local.autoid_nodes_ip_v4)
20+
}
21+
22+
connection {
23+
host = local.autoid_nodes_ip_v4[count.index]
24+
user = var.ssh_user
25+
type = "ssh"
26+
agent = true
27+
private_key = file("${var.private_key_path}")
28+
timeout = "300s"
29+
}
30+
31+
# create subspace dir
32+
provisioner "remote-exec" {
33+
inline = [
34+
"sudo mkdir -p /home/${var.ssh_user}/subspace/",
35+
"sudo chown -R ${var.ssh_user}:${var.ssh_user} /home/${var.ssh_user}/subspace/ && sudo chmod -R 750 /home/${var.ssh_user}/subspace/"
36+
]
37+
}
38+
39+
# copy install file
40+
provisioner "file" {
41+
source = "${var.path_to_scripts}/installer.sh"
42+
destination = "/home/${var.ssh_user}/subspace/installer.sh"
43+
}
44+
45+
# copy config files
46+
provisioner "file" {
47+
source = "${var.path_to_configs}/"
48+
destination = "/home/${var.ssh_user}/subspace/"
49+
}
50+
51+
# copy LE script
52+
provisioner "file" {
53+
source = "${var.path_to_scripts}/acme.sh"
54+
destination = "/home/${var.ssh_user}/subspace/acme.sh"
55+
}
56+
57+
# install docker and docker compose and LE script
58+
provisioner "remote-exec" {
59+
inline = [
60+
"sudo bash /home/${var.ssh_user}/subspace/installer.sh",
61+
"bash /home/${var.ssh_user}/subspace/acme.sh",
62+
]
63+
}
64+
65+
}
66+
67+
resource "null_resource" "prune-autoid-nodes" {
68+
count = var.autoid-node-config.prune ? length(local.autoid_nodes_ip_v4) : 0
69+
depends_on = [null_resource.setup-autoid-nodes]
70+
71+
triggers = {
72+
prune = var.autoid-node-config.prune
73+
}
74+
75+
connection {
76+
host = local.autoid_nodes_ip_v4[count.index]
77+
user = var.ssh_user
78+
type = "ssh"
79+
agent = true
80+
private_key = file("${var.private_key_path}")
81+
timeout = "300s"
82+
}
83+
84+
provisioner "file" {
85+
source = "${var.path_to_scripts}/prune_docker_system.sh"
86+
destination = "/home/${var.ssh_user}/subspace/prune_docker_system.sh"
87+
}
88+
89+
# prune network
90+
provisioner "remote-exec" {
91+
inline = [
92+
"sudo bash /home/${var.ssh_user}/subspace/prune_docker_system.sh"
93+
]
94+
}
95+
}
96+
97+
resource "null_resource" "start-autoid-nodes" {
98+
count = length(local.autoid_nodes_ip_v4)
99+
100+
depends_on = [null_resource.setup-autoid-nodes]
101+
102+
# trigger on node deployment version change
103+
triggers = {
104+
deployment_version = var.autoid-node-config.deployment-version
105+
reserved_only = var.autoid-node-config.reserved-only
106+
}
107+
108+
connection {
109+
host = local.autoid_nodes_ip_v4[count.index]
110+
user = var.ssh_user
111+
type = "ssh"
112+
agent = true
113+
private_key = file("${var.private_key_path}")
114+
timeout = "300s"
115+
}
116+
117+
# copy node keys file
118+
provisioner "file" {
119+
source = "./autoid_node_keys.txt"
120+
destination = "/home/${var.ssh_user}/subspace/node_keys.txt"
121+
}
122+
123+
# copy boostrap node keys file
124+
provisioner "file" {
125+
source = "./bootstrap_node_keys.txt"
126+
destination = "/home/${var.ssh_user}/subspace/bootstrap_node_keys.txt"
127+
}
128+
129+
130+
# copy boostrap node keys file
131+
provisioner "file" {
132+
source = "./bootstrap_node_autoid_keys.txt"
133+
destination = "/home/${var.ssh_user}/subspace/bootstrap_node_autoid_keys.txt"
134+
}
135+
136+
# copy dsn_boostrap node keys file
137+
provisioner "file" {
138+
source = "./dsn_bootstrap_node_keys.txt"
139+
destination = "/home/${var.ssh_user}/subspace/dsn_bootstrap_node_keys.txt"
140+
}
141+
142+
# copy keystore
143+
provisioner "file" {
144+
source = "./keystore"
145+
destination = "/home/${var.ssh_user}/subspace/keystore/"
146+
}
147+
148+
# copy compose file creation script
149+
provisioner "file" {
150+
source = "${var.path_to_scripts}/create_domain_node_compose_file.sh"
151+
destination = "/home/${var.ssh_user}/subspace/create_compose_file.sh"
152+
}
153+
154+
# start docker containers
155+
provisioner "remote-exec" {
156+
inline = [
157+
# stop any running service
158+
"sudo docker compose -f /home/${var.ssh_user}/subspace/docker-compose.yml down ",
159+
160+
# set hostname
161+
"sudo hostnamectl set-hostname ${var.network_name}-autoid-node-${count.index}",
162+
163+
# create .env file
164+
"echo NODE_ORG=${var.autoid-node-config.docker-org} > /home/${var.ssh_user}/subspace/.env",
165+
"echo NODE_TAG=${var.autoid-node-config.docker-tag} >> /home/${var.ssh_user}/subspace/.env",
166+
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subspace/.env",
167+
"echo DOMAIN_PREFIX=${var.autoid-node-config.domain-prefix[0]} >> /home/${var.ssh_user}/subspace/.env",
168+
"echo DOMAIN_LABEL=${var.autoid-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
169+
"echo DOMAIN_ID=${var.autoid-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
170+
"echo NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
171+
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /home/${var.ssh_user}/subspace/node_keys.txt) >> /home/${var.ssh_user}/subspace/.env",
172+
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subspace/.env",
173+
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /home/${var.ssh_user}/subspace/.env",
174+
"echo NODE_DSN_PORT=${var.autoid-node-config.node-dsn-port} >> /home/${var.ssh_user}/subspace/.env",
175+
"echo POT_EXTERNAL_ENTROPY=${var.pot_external_entropy} >> /home/${var.ssh_user}/subspace/.env",
176+
177+
# create docker compose file
178+
"bash /home/${var.ssh_user}/subspace/create_compose_file.sh ${var.bootstrap-node-config.reserved-only} ${length(local.domain_nodes_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${length(local.bootstrap_nodes_autoid_ip_v4)} ${var.autoid-node-config.enable-domains} ${var.autoid-node-config.domain-id[0]}",
179+
180+
# start subspace node
181+
"sudo docker compose -f /home/${var.ssh_user}/subspace/docker-compose.yml up -d",
182+
]
183+
}
184+
}
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
locals {
2+
bootstrap_nodes_autoid_ip_v4 = flatten([
3+
[aws_instance.bootstrap_node_autoid.*.public_ip]
4+
]
5+
)
6+
7+
bootstrap_nodes_autoid_ip_v6 = flatten([
8+
[aws_instance.bootstrap_node_autoid.*.ipv6_addresses]
9+
]
10+
)
11+
}
12+
13+
resource "null_resource" "setup-bootstrap-nodes-autoid" {
14+
count = length(local.bootstrap_nodes_autoid_ip_v4)
15+
16+
depends_on = [aws_instance.bootstrap_node_autoid]
17+
18+
# trigger on node ip changes
19+
triggers = {
20+
cluster_instance_ipv4s = join(",", local.bootstrap_nodes_autoid_ip_v4)
21+
}
22+
23+
connection {
24+
host = local.bootstrap_nodes_autoid_ip_v4[count.index]
25+
user = var.ssh_user
26+
type = "ssh"
27+
agent = true
28+
private_key = file("${var.private_key_path}")
29+
timeout = "300s"
30+
}
31+
32+
# create subspace dir
33+
provisioner "remote-exec" {
34+
inline = [
35+
"sudo mkdir -p /home/${var.ssh_user}/subspace/",
36+
"sudo chown -R ${var.ssh_user}:${var.ssh_user} /home/${var.ssh_user}/subspace/ && sudo chmod -R 750 /home/${var.ssh_user}/subspace/"
37+
]
38+
}
39+
40+
# copy install file
41+
provisioner "file" {
42+
source = "${var.path_to_scripts}/installer.sh"
43+
destination = "/home/${var.ssh_user}/subspace/installer.sh"
44+
}
45+
46+
# copy config files
47+
provisioner "file" {
48+
source = "${var.path_to_configs}/"
49+
destination = "/home/${var.ssh_user}/subspace/"
50+
}
51+
52+
# install docker and docker compose
53+
provisioner "remote-exec" {
54+
inline = [
55+
"sudo bash /home/${var.ssh_user}/subspace/installer.sh",
56+
]
57+
}
58+
59+
}
60+
61+
resource "null_resource" "prune-bootstrap-nodes-autoid" {
62+
count = var.bootstrap-node-autoid-config.prune ? length(local.bootstrap_nodes_autoid_ip_v4) : 0
63+
depends_on = [null_resource.setup-bootstrap-nodes-autoid]
64+
65+
triggers = {
66+
prune = var.bootstrap-node-autoid-config.prune
67+
}
68+
69+
connection {
70+
host = local.bootstrap_nodes_autoid_ip_v4[count.index]
71+
user = var.ssh_user
72+
type = "ssh"
73+
agent = true
74+
private_key = file("${var.private_key_path}")
75+
timeout = "300s"
76+
}
77+
78+
provisioner "file" {
79+
source = "${var.path_to_scripts}/prune_docker_system.sh"
80+
destination = "/home/${var.ssh_user}/subspace/prune_docker_system.sh"
81+
}
82+
83+
# prune network
84+
provisioner "remote-exec" {
85+
inline = [
86+
"sudo bash /home/${var.ssh_user}/subspace/prune_docker_system.sh"
87+
]
88+
}
89+
}
90+
91+
resource "null_resource" "start-bootstrap-nodes-autoid" {
92+
count = length(local.bootstrap_nodes_autoid_ip_v4)
93+
94+
depends_on = [null_resource.setup-bootstrap-nodes-autoid]
95+
96+
# trigger on node deployment version change
97+
triggers = {
98+
deployment_version = var.bootstrap-node-autoid-config.deployment-version
99+
reserved_only = var.bootstrap-node-autoid-config.reserved-only
100+
}
101+
102+
connection {
103+
host = local.bootstrap_nodes_autoid_ip_v4[count.index]
104+
user = var.ssh_user
105+
type = "ssh"
106+
agent = true
107+
private_key = file("${var.private_key_path}")
108+
timeout = "300s"
109+
}
110+
111+
# copy bootstrap node keys file
112+
provisioner "file" {
113+
source = "./bootstrap_node_autoid_keys.txt"
114+
destination = "/home/${var.ssh_user}/subspace/node_keys.txt"
115+
}
116+
117+
# copy boostrap node keys file
118+
provisioner "file" {
119+
source = "./bootstrap_node_keys.txt"
120+
destination = "/home/${var.ssh_user}/subspace/bootstrap_node_keys.txt"
121+
}
122+
123+
# copy DSN bootstrap node keys file
124+
provisioner "file" {
125+
source = "./dsn_bootstrap_node_keys.txt"
126+
destination = "/home/${var.ssh_user}/subspace/dsn_bootstrap_node_keys.txt"
127+
}
128+
129+
# copy compose file creation script
130+
provisioner "file" {
131+
source = "${var.path_to_scripts}/create_bootstrap_node_domain_compose_file.sh"
132+
destination = "/home/${var.ssh_user}/subspace/create_compose_file.sh"
133+
}
134+
135+
# start docker containers
136+
provisioner "remote-exec" {
137+
inline = [
138+
# stop any running service
139+
"sudo docker compose -f /home/${var.ssh_user}/subspace/docker-compose.yml down ",
140+
141+
# set hostname
142+
"sudo hostnamectl set-hostname ${var.network_name}-bootstrap-node-autoid-${count.index}",
143+
144+
# create .env file
145+
"echo NODE_ORG=${var.bootstrap-node-autoid-config.docker-org} > /home/${var.ssh_user}/subspace/.env",
146+
"echo NODE_TAG=${var.bootstrap-node-autoid-config.docker-tag} >> /home/${var.ssh_user}/subspace/.env",
147+
"echo NETWORK_NAME=${var.network_name} >> /home/${var.ssh_user}/subspace/.env",
148+
"echo NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
149+
"echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /home/${var.ssh_user}/subspace/node_keys.txt) >> /home/${var.ssh_user}/subspace/.env",
150+
"echo DOMAIN_LABEL=${var.domain-node-config.domain-labels[1]} >> /home/${var.ssh_user}/subspace/.env",
151+
"echo DOMAIN_ID=${var.domain-node-config.domain-id[1]} >> /home/${var.ssh_user}/subspace/.env",
152+
"echo NR_API_KEY=${var.nr_api_key} >> /home/${var.ssh_user}/subspace/.env",
153+
"echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /home/${var.ssh_user}/subspace/.env",
154+
"echo DSN_NODE_ID=${count.index} >> /home/${var.ssh_user}/subspace/.env",
155+
"echo DSN_NODE_KEY=$(sed -nr 's/NODE_${count.index}_DSN_KEY=//p' /home/${var.ssh_user}/subspace/node_keys.txt) >> /home/${var.ssh_user}/subspace/.env",
156+
"echo DSN_LISTEN_PORT=${var.bootstrap-node-autoid-config.dsn-listen-port} >> /home/${var.ssh_user}/subspace/.env",
157+
"echo NODE_DSN_PORT=${var.bootstrap-node-autoid-config.node-dsn-port} >> /home/${var.ssh_user}/subspace/.env",
158+
"echo OPERATOR_PORT=${var.bootstrap-node-autoid-config.operator-port} >> /home/${var.ssh_user}/subspace/.env",
159+
"echo GENESIS_HASH=${var.bootstrap-node-autoid-config.genesis-hash} >> /home/${var.ssh_user}/subspace/.env",
160+
161+
# create docker compose file
162+
"bash /home/${var.ssh_user}/subspace/create_compose_file.sh ${var.bootstrap-node-autoid-config.reserved-only} ${length(local.bootstrap_nodes_autoid_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${var.domain-node-config.enable-domains} ",
163+
164+
# start subspace node
165+
"sudo docker compose -f /home/${var.ssh_user}/subspace/docker-compose.yml up -d",
166+
]
167+
}
168+
}

0 commit comments

Comments
 (0)