From 7aac5730adcb53808f8e708ca52ebac088db9fdf Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Wed, 5 Apr 2023 19:15:03 +0200 Subject: [PATCH] split invariants into seperate module --- debian/main.tf | 28 ++++++++++++++++------------ debian/variables.tf | 39 ++++++++++++++++++--------------------- invariants/outputs.tf | 30 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 33 deletions(-) create mode 100644 invariants/outputs.tf diff --git a/debian/main.tf b/debian/main.tf index c52c40f..2a3448d 100644 --- a/debian/main.tf +++ b/debian/main.tf @@ -6,16 +6,20 @@ terraform { } } -module "tf_debian_vm" { - source = "git::https://git.pim.kunis.nl/pim/tf-debian-vm.git" - name = var.name - admin_authorized_keys = var.admin_authorized_keys - insecure_password = var.insecure_password - use_host_cert = var.use_host_cert - disk_pool = var.disk_pool - disk_base = var.disk_base - disk_base_pool = var.disk_base_pool - cloudinit_pool = var.cloudinit_pool - bridge_name = var.bridge_name - ca_host = var.ca_host +module "invariants" { + source = "git::https://git.pim.kunis.nl/home/tf-modules.git/invariants" +} + +module "tf_debian_vm" { + source = "git::https://git.pim.kunis.nl/pim/tf-debian-vm.git" + name = var.name + admin_authorized_keys = coalesce(var.admin_authorized_keys, module.invariants.admin_authorized_keys) + insecure_password = coalesce(var.insecure_password, false) + use_host_cert = coalesce(var.use_host_cert, true) + disk_pool = coalesce(var.disk_pool, module.invariants.disk_pool) + disk_base = coalesce(var.disk_base, module.invariants.disk_base) + disk_base_pool = coalesce(var.disk_base_pool, module.invariants.disk_base_pool) + cloudinit_pool = coalesce(var.cloudinit_pool, module.invariants.cloudinit_pool) + bridge_name = coalesce(var.bridge_name, module.invariants.bridge_name) + ca_host = coalesce(var.ca_host, module.invariants.ca_host) } diff --git a/debian/variables.tf b/debian/variables.tf index 5abefcf..10b6b97 100644 --- a/debian/variables.tf +++ b/debian/variables.tf @@ -3,49 +3,46 @@ variable "name" { } variable "admin_authorized_keys" { - type = list(string) - default = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOodpLr+FDRyKyHjucHizNLVFHZ5AQmE9GmxMnOsSoaw pimkunis@thinkpadpim", - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINUZp4BCxf7uLa1QWonx/Crf8tYZ5MKIZ+EuaBa82LrV user@user-laptop" - ] + type = list(string) + default = null } variable "insecure_password" { - type = bool - default = false + type = bool + default = null } variable "use_host_cert" { - type = bool - default = true + type = bool + default = null } variable "disk_pool" { - type = string - default = "disk" + type = string + default = null } variable "disk_base" { - type = string - default = "debian-bookworm.qcow2" + type = string + default = null } variable "disk_base_pool" { - type = string - default = "iso" + type = string + default = null } variable "cloudinit_pool" { - type = string - default = "init" + type = string + default = null } variable "bridge_name" { - type = string - default = "dmzbr" + type = string + default = null } variable "ca_host" { - type = string - default = "hermes.dmz" + type = string + default = null } diff --git a/invariants/outputs.tf b/invariants/outputs.tf new file mode 100644 index 0000000..8a1d536 --- /dev/null +++ b/invariants/outputs.tf @@ -0,0 +1,30 @@ +output "admin_authorized_keys" { + value = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOodpLr+FDRyKyHjucHizNLVFHZ5AQmE9GmxMnOsSoaw pimkunis@thinkpadpim", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINUZp4BCxf7uLa1QWonx/Crf8tYZ5MKIZ+EuaBa82LrV user@user-laptop" + ] +} + +output "disk_pool" { + value = "disk" +} + +output "disk_base" { + value = "debian-bookworm.qcow2" +} + +output "disk_base_pool" { + value = "iso" +} + +output "cloudinit_pool" { + value = "init" +} + +output "bridge_name" { + value = "dmzbr" +} + +output "ca_host" { + value = "hermes.dmz" +}