diff --git a/eth1.tf b/eth1.tf index 54d5ef9..efd3d56 100644 --- a/eth1.tf +++ b/eth1.tf @@ -4,7 +4,7 @@ * 2 x 512 GB NVMe SSD * 1 x 2 TB NVMe SSD */ module "nimbus_eth1_node_hetzner" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "metal" env = "nimbus" diff --git a/fluffy.tf b/fluffy.tf index 102c59b..61df3ec 100644 --- a/fluffy.tf +++ b/fluffy.tf @@ -3,7 +3,7 @@ * 64 GB DDR4 RAM * 2 x 512 GB NVMe SSD */ module "nimbus_nodes_fluffy_hetzner" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "metal" env = "nimbus" diff --git a/kiln.tf b/kiln.tf index 7735704..9b82e61 100644 --- a/kiln.tf +++ b/kiln.tf @@ -1,5 +1,5 @@ module "nimbus_nodes_kiln_hetzner" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "metal" env = "nimbus" diff --git a/logs.tf b/logs.tf index 30f77c7..19d78dd 100644 --- a/logs.tf +++ b/logs.tf @@ -1,5 +1,5 @@ module "nimbus_log_store" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "store" env = "logs" diff --git a/mainnet.tf b/mainnet.tf index ade63a8..9b20eb2 100644 --- a/mainnet.tf +++ b/mainnet.tf @@ -3,7 +3,7 @@ * 64 GB DDR4 RAM * 2 x 512 GB NVMe SSD */ module "nimbus_nodes_mainnet_hetzner" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "metal" env = "nimbus" diff --git a/modules/dummy-module/README.md b/modules/dummy-module/README.md deleted file mode 100644 index 7f54a52..0000000 --- a/modules/dummy-module/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Description - -This is a dummy module which does not create any actual cloud resources. It's intended for registering hosts which cannot be managed with Terraform to our infra. - -For example providers like Hetzner or MacStadium have no provider module for Terrafom. - -This module creates the Ansible inventory hosts in order to make hosts appear the same way all the other hosts created by Terraform do. diff --git a/modules/dummy-module/main.tf b/modules/dummy-module/main.tf deleted file mode 100644 index 7c98987..0000000 --- a/modules/dummy-module/main.tf +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************* - * WARNING! - * This is just creating the inventory entries - * the same way I do it for other hosts so - * Ansible can use them during provisioning. - *************************************************/ - -/* DERIVED --------------------------------------*/ - -locals { - stage = var.stage != "" ? var.stage : terraform.workspace - tokens = split(".", local.stage) - dc = "${var.prefix}-${var.region}" - # map of hostname => ip - hostnames = { for i, ip in var.ips : - "${var.name}-${format("%02d", i + 1)}.${local.dc}.${var.env}.${local.stage}" => ip - } - -} - -/* RESOURCES ------------------------------------*/ - -resource "ansible_host" "host" { - for_each = local.hostnames - inventory_hostname = each.key - groups = [var.group, local.dc, "${var.env}.${local.stage}"] - - vars = { - hostname = each.key - dns_entry = "${each.key}.${var.domain}" - dns_domain = var.domain - data_center = local.dc - region = var.region - env = var.env - stage = local.stage - ansible_host = each.value - /* Optional extra Ansible variables necessary for Windows */ - ansible_shell_type = (var.shell_type == null ? null : var.shell_type) - ansible_become_user = (var.become_user == null ? null : var.become_user) - ansible_become_method = (var.become_method == null ? null : var.become_method) - } -} - -resource "cloudflare_record" "host" { - for_each = local.hostnames - - zone_id = var.zone_id - name = each.key - value = each.value - type = "A" -} diff --git a/modules/dummy-module/outputs.tf b/modules/dummy-module/outputs.tf deleted file mode 100644 index a65237e..0000000 --- a/modules/dummy-module/outputs.tf +++ /dev/null @@ -1,11 +0,0 @@ -output "public_ips" { - value = var.ips -} - -output "hostnames" { - value = keys(local.hostnames) -} - -output "hosts" { - value = local.hostnames -} diff --git a/modules/dummy-module/variables.tf b/modules/dummy-module/variables.tf deleted file mode 100644 index d044655..0000000 --- a/modules/dummy-module/variables.tf +++ /dev/null @@ -1,71 +0,0 @@ -/* SCALING --------------------------------------*/ - -variable "region" { - description = "Region in which the host reside." - type = string -} - -variable "prefix" { - description = "Short name of provider being used." - type = string - default = "ms" -} - -/* STATIC ---------------------------------------*/ - -variable "ips" { - description = "Static list of IPs used by the hosts." - type = list(string) -} - -/* GENERAL --------------------------------------*/ - -variable "name" { - description = "Prefix of hostname before index." - type = string - default = "node" -} - -variable "group" { - description = "Name of Ansible group to add hosts to." - type = string -} - -variable "env" { - description = "Environment for these hosts, affects DNS entries." - type = string -} - -variable "stage" { - description = "Name of stage, like prod, dev, or staging." - type = string - default = "" -} - -variable "domain" { - description = "DNS Domain to update" - type = string -} - -variable "zone_id" { - description = "ID of CloudFlare zone for host record." - /* We default to: statusim.net */ - default = "14660d10344c9898521c4ba49789f563" -} - -variable "shell_type" { - description = "Type of shell used by Ansible." - type = string - default = null -} - -variable "become_user" { - description = "What user Ansible should become." - type = string - default = null -} -variable "become_method" { - description = "Method used by Ansible to become a user." - type = string - default = null -} diff --git a/modules/dummy-module/versions.tf b/modules/dummy-module/versions.tf deleted file mode 100644 index bfc746b..0000000 --- a/modules/dummy-module/versions.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_version = "~> 1.0.0" - required_providers { - ansible = { - source = "nbering/ansible" - version = " = 1.0.4" - } - cloudflare = { - source = "cloudflare/cloudflare" - version = " = 2.21.0" - } - } -} diff --git a/openeth.tf b/openeth.tf index 7ccc238..082a8fe 100644 --- a/openeth.tf +++ b/openeth.tf @@ -3,7 +3,7 @@ * 64 GB DDR4 RAM * 2 x 512 GB NVMe SSD */ module "nimbus_openeth_mainnet" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "mainnet" env = "nimbus" diff --git a/prater.tf b/prater.tf index e97ad0c..d9c210b 100644 --- a/prater.tf +++ b/prater.tf @@ -89,7 +89,7 @@ module "nimbus_nodes_prater_unstable_large" { } module "nimbus_nodes_prater_windows" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "windows" env = "nimbus" @@ -110,7 +110,7 @@ module "nimbus_nodes_prater_windows" { } module "nimbus_nodes_prater_hetzner" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "metal" env = "nimbus" @@ -148,7 +148,7 @@ resource "cloudflare_record" "testing_prater_beacon_api" { } module "nimbus_nodes_prater_macos" { - source = "./modules/dummy-module" + source = "github.com/status-im/infra-tf-dummy-module" name = "macos" env = "nimbus"