commit 3fca5934e5c6b4cd2c25b0b048bce0a23b73ab54
parent 70b7238caa7a2233ecbbedc1c4a38843f871811f
Author: Dionysis Grigoropoulos <dgrig@erethon.com>
Date: Sat, 21 Nov 2020 22:50:17 +0200
terraform: Run terraform fmt on all TF files
Diffstat:
8 files changed, 169 insertions(+), 160 deletions(-)
diff --git a/terraform/infrastructure/lenny/main.tf b/terraform/infrastructure/lenny/main.tf
@@ -6,9 +6,9 @@ module "lenny_network" {
source = "../../modules/libvirt_network"
network_bridge_interface = "virbr1"
- network_name = "lenny_network"
- network_cidr = "192.168.134.0/24"
- network_dns_enabled = false
+ network_name = "lenny_network"
+ network_cidr = "192.168.134.0/24"
+ network_dns_enabled = false
}
resource "libvirt_volume" "base_debian_volume" {
@@ -19,7 +19,7 @@ resource "libvirt_volume" "base_debian_volume" {
}
resource "libvirt_pool" "disk_pool" {
- name = "tf_pool"
+ name = "tf_pool"
type = "dir"
path = "/data/Disks"
}
@@ -27,18 +27,18 @@ resource "libvirt_pool" "disk_pool" {
module "dirty_debian_dev" {
source = "../../modules/libvirt_host"
- host_name = "dirty_debian_dev"
- host_memory = "512"
- host_vcpu = 1
- host_autostart = false
- storage_pool = libvirt_pool.disk_pool.name
- volume_name = "dirty_debian_dev"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.lenny_network.id
- network_cidr = module.lenny_network.cidr
- network_host = "2"
- enable_cloud_init = true
+ host_name = "dirty_debian_dev"
+ host_memory = "512"
+ host_vcpu = 1
+ host_autostart = false
+ storage_pool = libvirt_pool.disk_pool.name
+ volume_name = "dirty_debian_dev"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.lenny_network.id
+ network_cidr = module.lenny_network.cidr
+ network_host = "2"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -48,18 +48,18 @@ EOF
module "nv_core" {
source = "../../modules/libvirt_host"
- host_name = "nc_core"
- host_memory = "512"
- host_vcpu = 1
- host_autostart = false
- storage_pool = libvirt_pool.disk_pool.name
- volume_name = "nv_core"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.lenny_network.id
- network_cidr = module.lenny_network.cidr
- network_host = "3"
- enable_cloud_init = true
+ host_name = "nc_core"
+ host_memory = "512"
+ host_vcpu = 1
+ host_autostart = false
+ storage_pool = libvirt_pool.disk_pool.name
+ volume_name = "nv_core"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.lenny_network.id
+ network_cidr = module.lenny_network.cidr
+ network_host = "3"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -69,18 +69,18 @@ EOF
module "tor_proxy" {
source = "../../modules/libvirt_host"
- host_name = "tor_proxy"
- host_memory = "256"
- host_vcpu = 1
- host_autostart = false
- storage_pool = libvirt_pool.disk_pool.name
- volume_name = "tor_proxy"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.lenny_network.id
- network_cidr = module.lenny_network.cidr
- network_host = "4"
- enable_cloud_init = true
+ host_name = "tor_proxy"
+ host_memory = "256"
+ host_vcpu = 1
+ host_autostart = false
+ storage_pool = libvirt_pool.disk_pool.name
+ volume_name = "tor_proxy"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.lenny_network.id
+ network_cidr = module.lenny_network.cidr
+ network_host = "4"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
diff --git a/terraform/infrastructure/lenny/versions.tf b/terraform/infrastructure/lenny/versions.tf
@@ -1,7 +1,7 @@
terraform {
required_providers {
libvirt = {
- source = "erethon.com/third-party/libvirt"
+ source = "erethon.com/third-party/libvirt"
version = "0.6.2"
}
}
diff --git a/terraform/infrastructure/oricono/main.tf b/terraform/infrastructure/oricono/main.tf
@@ -6,9 +6,18 @@ module "ori_network" {
source = "../../modules/libvirt_network"
network_bridge_interface = "virbr1"
- network_name = "ori_network"
- network_cidr = "192.168.144.0/24"
- network_dns_enabled = false
+ network_name = "ori_network"
+ network_cidr = "192.168.144.0/24"
+ network_dns_enabled = false
+}
+
+module "hacky_network" {
+ source = "../../modules/libvirt_network"
+
+ network_bridge_interface = "virbr2"
+ network_name = "hacky_network"
+ network_cidr = "192.168.145.0/24"
+ network_dns_enabled = false
}
resource "libvirt_volume" "base_debian_volume" {
@@ -28,17 +37,17 @@ resource "libvirt_volume" "base_openbsd_volume" {
module "dirty_debian_dev" {
source = "../../modules/libvirt_host"
- host_name = "dirty_debian_dev"
- host_memory = "1024"
- host_vcpu = 2
- storage_pool = var.libvirt_storage_pool
- volume_name = "dirty_debian_dev"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.ori_network.id
- network_cidr = module.ori_network.cidr
- network_host = "2"
- enable_cloud_init = true
+ host_name = "dirty_debian_dev"
+ host_memory = "1024"
+ host_vcpu = 2
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "dirty_debian_dev"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.ori_network.id
+ network_cidr = module.ori_network.cidr
+ network_host = "2"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -48,18 +57,18 @@ EOF
module "nv_core" {
source = "../../modules/libvirt_host"
- host_name = "nc_core"
- host_memory = "1024"
- host_vcpu = 1
- storage_pool = var.libvirt_storage_pool
- volume_name = "nv_core"
- volume_size = "21474836480"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.ori_network.id
- network_cidr = module.ori_network.cidr
- network_host = "3"
- enable_cloud_init = true
+ host_name = "nc_core"
+ host_memory = "1024"
+ host_vcpu = 1
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "nv_core"
+ volume_size = "21474836480"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.ori_network.id
+ network_cidr = module.ori_network.cidr
+ network_host = "3"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -69,33 +78,33 @@ EOF
module "openbsd_68" {
source = "../../modules/libvirt_host"
- host_name = "openbsd68"
- host_memory = "512"
- host_vcpu = 1
- storage_pool = var.libvirt_storage_pool
- volume_name = "openbsd_68"
- base_volume_id = libvirt_volume.base_openbsd_volume.id
- disks = [{"volume_id": libvirt_volume.base_openbsd_volume.id}]
- network_id = module.ori_network.id
- network_cidr = module.ori_network.cidr
- network_host = "4"
+ host_name = "openbsd68"
+ host_memory = "512"
+ host_vcpu = 1
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "openbsd_68"
+ base_volume_id = libvirt_volume.base_openbsd_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_openbsd_volume.id }]
+ network_id = module.ori_network.id
+ network_cidr = module.ori_network.cidr
+ network_host = "4"
enable_cloud_init = false
}
module "xorg_enabled" {
source = "../../modules/libvirt_host"
- host_name = "xorg_enabled"
- host_memory = "1024"
- host_vcpu = 1
- storage_pool = var.libvirt_storage_pool
- volume_name = "xorg_enabled"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.ori_network.id
- network_cidr = module.ori_network.cidr
- network_host = "5"
- enable_cloud_init = true
+ host_name = "xorg_enabled"
+ host_memory = "1024"
+ host_vcpu = 1
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "xorg_enabled"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.ori_network.id
+ network_cidr = module.ori_network.cidr
+ network_host = "5"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -105,17 +114,17 @@ EOF
module "rust_dev" {
source = "../../modules/libvirt_host"
- host_name = "rust_dev"
- host_memory = "1024"
- host_vcpu = 2
- storage_pool = var.libvirt_storage_pool
- volume_name = "rust_dev"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.ori_network.id
- network_cidr = module.ori_network.cidr
- network_host = "7"
- enable_cloud_init = true
+ host_name = "rust_dev"
+ host_memory = "1024"
+ host_vcpu = 2
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "rust_dev"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.ori_network.id
+ network_cidr = module.ori_network.cidr
+ network_host = "7"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
diff --git a/terraform/infrastructure/oricono/versions.tf b/terraform/infrastructure/oricono/versions.tf
@@ -1,7 +1,7 @@
terraform {
required_providers {
libvirt = {
- source = "erethon.com/third-party/libvirt"
+ source = "erethon.com/third-party/libvirt"
version = "0.6.2"
}
}
diff --git a/terraform/infrastructure/production/main.tf b/terraform/infrastructure/production/main.tf
@@ -6,9 +6,9 @@ module "dev_network" {
source = "../../modules/libvirt_network"
network_bridge_interface = "virbr1"
- network_name = "dev_network"
- network_cidr = var.libvirt_cidr
- network_dns_enabled = false
+ network_name = "dev_network"
+ network_cidr = var.libvirt_cidr
+ network_dns_enabled = false
}
resource "libvirt_volume" "base_debian_volume" {
@@ -21,17 +21,17 @@ resource "libvirt_volume" "base_debian_volume" {
module "production_matrix" {
source = "../../modules/libvirt_host"
- host_name = "production_matrix"
- host_memory = "1536"
- host_vcpu = 2
- storage_pool = var.libvirt_storage_pool
- volume_name = "production_matrix_volume"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.dev_network.id
- network_cidr = module.dev_network.cidr
- network_host = "2"
- enable_cloud_init = true
+ host_name = "production_matrix"
+ host_memory = "1536"
+ host_vcpu = 2
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "production_matrix_volume"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.dev_network.id
+ network_cidr = module.dev_network.cidr
+ network_host = "2"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -41,16 +41,16 @@ EOF
module "production_pg_matrix" {
source = "../../modules/libvirt_host"
- host_name = "production_pg_matrix"
- host_memory = "1024"
- storage_pool = var.libvirt_storage_pool
- volume_name = "production_pg_matrix_volume"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.dev_network.id
- network_cidr = module.dev_network.cidr
- network_host = "3"
- enable_cloud_init = true
+ host_name = "production_pg_matrix"
+ host_memory = "1024"
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "production_pg_matrix_volume"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.dev_network.id
+ network_cidr = module.dev_network.cidr
+ network_host = "3"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -60,16 +60,16 @@ EOF
module "production_libreops_grafana" {
source = "../../modules/libvirt_host"
- host_name = "production_libreops_grafana"
- host_memory = "512"
- storage_pool = var.libvirt_storage_pool
- volume_name = "production_libreops_grafana"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.dev_network.id
- network_cidr = module.dev_network.cidr
- network_host = "4"
- enable_cloud_init = true
+ host_name = "production_libreops_grafana"
+ host_memory = "512"
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "production_libreops_grafana"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.dev_network.id
+ network_cidr = module.dev_network.cidr
+ network_host = "4"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
@@ -79,16 +79,16 @@ EOF
module "production_grafana" {
source = "../../modules/libvirt_host"
- host_name = "production_grafana"
- host_memory = "1024"
- storage_pool = var.libvirt_storage_pool
- volume_name = "production_grafana"
- base_volume_id = libvirt_volume.base_debian_volume.id
- disks = [{"volume_id": libvirt_volume.base_debian_volume.id}]
- network_id = module.dev_network.id
- network_cidr = module.dev_network.cidr
- network_host = "5"
- enable_cloud_init = true
+ host_name = "production_grafana"
+ host_memory = "1024"
+ storage_pool = var.libvirt_storage_pool
+ volume_name = "production_grafana"
+ base_volume_id = libvirt_volume.base_debian_volume.id
+ disks = [{ "volume_id" : libvirt_volume.base_debian_volume.id }]
+ network_id = module.dev_network.id
+ network_cidr = module.dev_network.cidr
+ network_host = "5"
+ enable_cloud_init = true
cloudinit_user_template = <<EOF
runcmd:
- echo 'source /etc/network/interfaces.d/*' > /etc/network/interfaces
diff --git a/terraform/modules/libvirt_host/main.tf b/terraform/modules/libvirt_host/main.tf
@@ -1,5 +1,5 @@
resource "libvirt_volume" "volume" {
- count = (var.volume_name != "" ? 1 : 0)
+ count = (var.volume_name != "" ? 1 : 0)
name = var.volume_name
pool = var.storage_pool
format = var.volume_format
@@ -13,15 +13,15 @@ resource "random_pet" "random" {
}
resource "libvirt_cloudinit_disk" "cloud_init" {
- count = (var.enable_cloud_init == true ? 1 : 0)
- name = "cloud-init-${random_pet.random[0].id}.iso"
- pool = var.storage_pool
+ count = (var.enable_cloud_init == true ? 1 : 0)
+ name = "cloud-init-${random_pet.random[0].id}.iso"
+ pool = var.storage_pool
user_data = templatefile("${path.module}/user_template.yml", {
extra_lines = var.cloudinit_user_template
})
network_config = templatefile("${path.module}/network_template.yml", {
- gateway = cidrhost(var.network_cidr, 1)
- ip_address = "${cidrhost(var.network_cidr, var.network_host)}/${split("/", var.network_cidr)[1]}"
+ gateway = cidrhost(var.network_cidr, 1)
+ ip_address = "${cidrhost(var.network_cidr, var.network_host)}/${split("/", var.network_cidr)[1]}"
nameservers = var.cloudinit_nameservers
})
}
@@ -50,8 +50,8 @@ resource "libvirt_domain" "libvirt_host" {
for_each = var.disks
iterator = disk
content {
- #file = (disk.iso != "" ? disk.iso : null)
- volume_id = (libvirt_volume.volume[0].id != "" ? libvirt_volume.volume[0].id : null)
+ #file = (disk.iso != "" ? disk.iso : null)
+ volume_id = (libvirt_volume.volume[0].id != "" ? libvirt_volume.volume[0].id : null)
}
}
diff --git a/terraform/modules/libvirt_host/vars.tf b/terraform/modules/libvirt_host/vars.tf
@@ -32,12 +32,12 @@ variable "host_autostart" {
}
variable "storage_pool" {
- type = string
+ type = string
default = "default"
}
variable "volume_name" {
- type = string
+ type = string
default = ""
}
@@ -62,26 +62,26 @@ variable "cloudinit_user_template" {
}
variable "enable_cloud_init" {
- type = bool
+ type = bool
default = false
}
variable "cloudinit_nameservers" {
- type = list
+ type = list
default = ["88.198.92.222"]
}
variable "base_volume_id" {
- type = string
+ type = string
default = ""
}
variable "iso" {
- type = string
+ type = string
default = ""
}
variable "disks" {
- type = list
+ type = list
default = []
}
diff --git a/terraform/modules/libvirt_host/versions.tf b/terraform/modules/libvirt_host/versions.tf
@@ -1,7 +1,7 @@
terraform {
required_providers {
libvirt = {
- source = "erethon.com/third-party/libvirt"
+ source = "erethon.com/third-party/libvirt"
version = "0.6.2"
}
random = {