extract Terraform dummy-module to separate repo

https://github.com/status-im/infra-tf-dummy-module

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-05-05 13:02:48 +02:00
parent 389e6dd432
commit 0b9d097274
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
12 changed files with 9 additions and 162 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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.

View File

@ -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"
}

View File

@ -1,11 +0,0 @@
output "public_ips" {
value = var.ips
}
output "hostnames" {
value = keys(local.hostnames)
}
output "hosts" {
value = local.hostnames
}

View File

@ -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
}

View File

@ -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"
}
}
}

View File

@ -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"

View File

@ -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"