From 1753acb9f6ce35f61d047cccf1b60fa293a1485a Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Thu, 29 Aug 2019 10:34:31 -0500 Subject: [PATCH] Add image data source in nodes module To avoid error when there's two images with same name use data source to get the latest image to boot up compute nodes --- nodes/main.tf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nodes/main.tf b/nodes/main.tf index f0cfef1..dfeeead 100644 --- a/nodes/main.tf +++ b/nodes/main.tf @@ -10,11 +10,16 @@ variable "key_pair" {type = "string"} variable "compute_node_count" { } variable "internal_network" {} +data "openstack_images_image_v2" "compute" { + name = var.image_compute + most_recent = true +} + # creates compute node resource "openstack_compute_instance_v2" "compute" { depends_on = [var.internal_subnet_id] name = "c${count.index}" - image_name = var.image_compute + image_id = data.openstack_images_image_v2.compute.id flavor_name = var.flavor key_pair = var.key_pair security_groups = ["default"] @@ -39,6 +44,10 @@ output "id" { value = openstack_compute_instance_v2.compute.*.id } +output "image_id" { + value = data.openstack_images_image_v2.compute.id +} + output "network" { value = zipmap(openstack_compute_instance_v2.compute.*.name, openstack_compute_instance_v2.compute.*.network) } -- GitLab