add ability to change domain name
This commit is contained in:
parent
b7272412b4
commit
7234433575
2 changed files with 9 additions and 3 deletions
7
main.tf
7
main.tf
|
@ -19,6 +19,7 @@ locals {
|
||||||
cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", {
|
cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", {
|
||||||
fixed_address = var.fixed_address
|
fixed_address = var.fixed_address
|
||||||
})
|
})
|
||||||
|
domain_name = coalesce(var.domain_name, var.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "tls_private_key" "debian" {
|
resource "tls_private_key" "debian" {
|
||||||
|
@ -52,7 +53,7 @@ resource "null_resource" "cert" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_volume" "debian" {
|
resource "libvirt_volume" "debian" {
|
||||||
name = "${var.name}.iso"
|
name = "${local.domain_name}.iso"
|
||||||
pool = var.disk_pool
|
pool = var.disk_pool
|
||||||
size = var.disk_size
|
size = var.disk_size
|
||||||
base_volume_name = var.disk_base
|
base_volume_name = var.disk_base
|
||||||
|
@ -66,14 +67,14 @@ resource "libvirt_volume" "debian" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_cloudinit_disk" "debian" {
|
resource "libvirt_cloudinit_disk" "debian" {
|
||||||
name = "${var.name}.iso"
|
name = "${local.domain_name}.iso"
|
||||||
pool = var.cloudinit_pool
|
pool = var.cloudinit_pool
|
||||||
user_data = local.cloudinit_user_data
|
user_data = local.cloudinit_user_data
|
||||||
network_config = local.cloudinit_network_config
|
network_config = local.cloudinit_network_config
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "libvirt_domain" "debian" {
|
resource "libvirt_domain" "debian" {
|
||||||
name = var.name
|
name = local.domain_name
|
||||||
memory = var.memory
|
memory = var.memory
|
||||||
vcpu = 4
|
vcpu = 4
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
|
@ -2,6 +2,11 @@ variable "name" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "domain_name" {
|
||||||
|
type = string
|
||||||
|
default = null
|
||||||
|
}
|
||||||
|
|
||||||
variable "disk_size" {
|
variable "disk_size" {
|
||||||
type = number
|
type = number
|
||||||
default = 1024 * 1024 * 1024 * 15
|
default = 1024 * 1024 * 1024 * 15
|
||||||
|
|
Reference in a new issue