Skip to content
Snippets Groups Projects
Commit 1753acb9 authored by Bo-Chun Chen's avatar Bo-Chun Chen Committed by John-Paul Robinson
Browse files

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
parent 72ff347d
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment