@@ -20,11 +20,11 @@ variable "hcloud_ssh_key_fingerprint" {
2020
2121variable "hetzner_supernode_size" {
2222 type = string
23- default = " cax41 "
23+ default = " cax31 "
2424}
2525variable "hetzner_fullnode_size" {
2626 type = string
27- default = " cax31 "
27+ default = " cax21 "
2828}
2929
3030variable "hetzner_regions" {
@@ -196,3 +196,52 @@ resource "local_file" "ansible_inventory" {
196196 )
197197 filename = " ../../../ansible/inventories/devnet-0/hetzner_inventory.ini"
198198}
199+
200+ locals {
201+ ssh_config_path = pathexpand (" ~/.ssh/config.d/ssh_config.${ var . ethereum_network } .hetzner" )
202+ }
203+
204+ resource "local_file" "ssh_config" {
205+ content = templatefile (" ${ path . module } /../ssh_config.tmpl" ,
206+ {
207+ ethereum_network = var.ethereum_network
208+ hosts = merge (
209+ {
210+ for key , server in hcloud_server . main : " ${ var . ethereum_network } -${ key } " => {
211+ hostname = coalesce (server. ipv4_address , (try (server. ipv6_address , " " )))
212+ private_ip = try (hcloud_server_network. main [key ]. ip , " " )
213+ name = key
214+ user = " devops"
215+ }
216+ }
217+ )
218+ }
219+ )
220+ filename = local. ssh_config_path
221+
222+ depends_on = [hcloud_server . main ]
223+
224+ lifecycle {
225+ create_before_destroy = true
226+ }
227+ }
228+
229+ # Ensure cleanup on destroy
230+ resource "null_resource" "ssh_config_cleanup" {
231+ triggers = {
232+ ssh_config_path = local.ssh_config_path
233+ }
234+
235+ # This provisioner runs on destroy
236+ provisioner "local-exec" {
237+ when = destroy
238+ command = " rm -f ${ self . triggers . ssh_config_path } || true"
239+ }
240+
241+ depends_on = [local_file . ssh_config ]
242+ }
243+
244+ output "ssh_config_file" {
245+ value = " SSH config generated at: ${ local . ssh_config_path } "
246+ description = " Path to the generated SSH config file"
247+ }
0 commit comments