output IPs of servers with openstack provider

2,025 views
Skip to first unread message

vincent.g...@gmail.com

unread,
Mar 30, 2017, 11:28:31 AM3/30/17
to Terraform
Hi all,
I would like to output the private IPs (not floating) of instances created through a unique resource with count = 3.

resource "openstack_compute_instance_v2" "node" {
count = "${var.node_count}"
name = "${var.cluster_name}_node"
region = "${var.region}"
flavor_name = "${var.node_flavor_name}"
image_id= "${data.openstack_images_image_v2.node_image.id}"
key_pair = "${openstack_compute_keypair_v2.keypair.name}"
security_groups = [ "${openstack_networking_secgroup_v2.node_secgroup.name}" ]
network = {
uuid = "${openstack_networking_network_v2.node_network.id}"
}
}


output "node_private_address" {
value = "${openstack_compute_instance_v2.node.network.fixed_ip_v4}"
}

But it doesn't output anything

If I put this, nothing is output because I didn't assign any floating IP

output "node_private_address" {
value = "${openstack_compute_instance_v2.node.access_ip_v4.}"
}


Do you have any trick to get the private IPs from a group of server ?
BR

Joe Topjian

unread,
Mar 30, 2017, 11:46:12 AM3/30/17
to terrafo...@googlegroups.com
Hello,

Since an OpenStack instance can take one or more networks, it is indexed, so you have to specify the network's index in order to see its attributes. In this case, the first network has an index of 0:

openstack_compute_instance_v2.node.network.0.fixed_ip_v4

You can see the full list of attributes and their indexes by doing "terraform show" after a deployment.

Hope that helps,
Joe

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/3024991d-2bec-4f78-a81c-9e8a10eabef2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vincent.g...@gmail.com

unread,
Mar 30, 2017, 11:51:52 AM3/30/17
to Terraform
Tx !
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

vincent.g...@gmail.com

unread,
Mar 30, 2017, 12:24:01 PM3/30/17
to Terraform
And is there any way to get the list of IPs for a group without knowing the number of servers ? I mean I have to precise all the index of node resource, one in each output so I need to add output when scaling the number of node...

Joe Topjian

unread,
Mar 30, 2017, 12:38:16 PM3/30/17
to terrafo...@googlegroups.com
This should be possible to do for outputs, unless I'm mistaken. Check the Terraform docs for count and element (any other related functions that take an index):


and try to apply that to an output. 

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/6e6b518d-4c2b-4ba4-b1b0-74edd4ee10af%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages