Made cloud-init configs an input to libvirt-nodes.
This commit is contained in:
@@ -107,6 +107,7 @@ module "worker-nodes" {
|
||||
# root-admin-passwd = var.root-admin-passwd
|
||||
# root-admin-pub-key = var.root-admin-pub-key
|
||||
# libvirt-connection-url = var.libvirt-connection-url
|
||||
# user-datas = data.template_file.master-node-user-datas
|
||||
# }
|
||||
#
|
||||
# module "worker-nodes" {
|
||||
@@ -120,6 +121,7 @@ module "worker-nodes" {
|
||||
# root-admin-passwd = var.root-admin-passwd
|
||||
# root-admin-pub-key = var.root-admin-pub-key
|
||||
# libvirt-connection-url = var.libvirt-connection-url
|
||||
# user-datas = data.template_file.worker-node-user-datas
|
||||
# }
|
||||
#
|
||||
# resource "libvirt_pool" "images" {
|
||||
|
||||
@@ -20,23 +20,13 @@ resource "libvirt_volume" "node-images" {
|
||||
format = "qcow2"
|
||||
}
|
||||
|
||||
data "template_file" "node-user-datas" {
|
||||
template = file("${path.module}/cloud_init.cfg")
|
||||
vars = {
|
||||
admin-passwd = "${var.root-admin-passwd}"
|
||||
admin-pub-key = "${var.root-admin-pub-key}"
|
||||
hostname = "${var.name-prefix}-${count.index}"
|
||||
}
|
||||
count = var.num-nodes
|
||||
}
|
||||
|
||||
data "template_file" "network-config" {
|
||||
template = file("${path.module}/network_config.cfg")
|
||||
}
|
||||
|
||||
resource "libvirt_cloudinit_disk" "node-inits" {
|
||||
name = "${var.name-prefix}-${count.index}-init"
|
||||
user_data = element(data.template_file.node-user-datas.*.rendered, count.index)
|
||||
user_data = element(var.user-datas.*.rendered, count.index)
|
||||
network_config = data.template_file.network-config.rendered
|
||||
pool = var.pool-name
|
||||
count = var.num-nodes
|
||||
|
||||
@@ -24,6 +24,10 @@ variable "node-vcpus" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "user-datas" {
|
||||
description = "A list of cloud-init configs that get applied to their corresponding node."
|
||||
}
|
||||
|
||||
variable "num-nodes" {
|
||||
description = "The number of nodes to create with this config."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user