From 44a4f356ba3769299d3981703585afb124c2b725 Mon Sep 17 00:00:00 2001 From: Brian King <1854985+inflatador@users.noreply.github.com> Date: Tue, 6 Dec 2022 20:28:38 -0600 Subject: [PATCH] Terraform Openstack: replace deprecated template provider with supported cloudinit provider (#9536) --- .../openstack/modules/compute/main.tf | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/contrib/terraform/openstack/modules/compute/main.tf b/contrib/terraform/openstack/modules/compute/main.tf index bf28d2758..7af82e120 100644 --- a/contrib/terraform/openstack/modules/compute/main.tf +++ b/contrib/terraform/openstack/modules/compute/main.tf @@ -15,8 +15,11 @@ data "openstack_images_image_v2" "image_master" { name = var.image_master == "" ? var.image : var.image_master } -data "template_file" "cloudinit" { - template = file("${path.module}/templates/cloudinit.yaml") +data "cloudinit_config" "cloudinit" { + part { + content_type = "text/cloud-config" + content = file("${path.module}/templates/cloudinit.yaml") + } } data "openstack_networking_network_v2" "k8s_network" { @@ -221,7 +224,7 @@ resource "openstack_compute_instance_v2" "bastion" { image_id = var.bastion_root_volume_size_in_gb == 0 ? local.image_to_use_node : null flavor_id = var.flavor_bastion key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.bastion_root_volume_size_in_gb > 0 ? [local.image_to_use_node] : [] @@ -275,7 +278,7 @@ resource "openstack_compute_instance_v2" "k8s_master" { image_id = var.master_root_volume_size_in_gb == 0 ? local.image_to_use_master : null flavor_id = var.flavor_k8s_master key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { @@ -399,7 +402,7 @@ resource "openstack_compute_instance_v2" "k8s_master_no_etcd" { image_id = var.master_root_volume_size_in_gb == 0 ? local.image_to_use_master : null flavor_id = var.flavor_k8s_master key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { @@ -462,7 +465,7 @@ resource "openstack_compute_instance_v2" "etcd" { image_id = var.etcd_root_volume_size_in_gb == 0 ? local.image_to_use_master : null flavor_id = var.flavor_etcd key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.etcd_root_volume_size_in_gb > 0 ? [local.image_to_use_master] : [] @@ -576,7 +579,7 @@ resource "openstack_compute_instance_v2" "k8s_master_no_floating_ip_no_etcd" { image_id = var.master_root_volume_size_in_gb == 0 ? local.image_to_use_master : null flavor_id = var.flavor_k8s_master key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.master_root_volume_size_in_gb > 0 ? [local.image_to_use_master] : [] @@ -634,7 +637,7 @@ resource "openstack_compute_instance_v2" "k8s_node" { image_id = var.node_root_volume_size_in_gb == 0 ? local.image_to_use_node : null flavor_id = var.flavor_k8s_node key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.node_root_volume_size_in_gb > 0 ? [local.image_to_use_node] : [] @@ -697,7 +700,7 @@ resource "openstack_compute_instance_v2" "k8s_node_no_floating_ip" { image_id = var.node_root_volume_size_in_gb == 0 ? local.image_to_use_node : null flavor_id = var.flavor_k8s_node key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.node_root_volume_size_in_gb > 0 ? [local.image_to_use_node] : [] @@ -755,7 +758,7 @@ resource "openstack_compute_instance_v2" "k8s_nodes" { image_id = var.node_root_volume_size_in_gb == 0 ? local.image_to_use_node : null flavor_id = each.value.flavor key_pair = openstack_compute_keypair_v2.k8s.name - user_data = data.template_file.cloudinit.rendered + user_data = data.cloudinit_config.cloudinit.rendered dynamic "block_device" { for_each = var.node_root_volume_size_in_gb > 0 ? [local.image_to_use_node] : []