Skip to content

Commit

Permalink
Ignore node IPs in Terraform output
Browse files Browse the repository at this point in the history
We wanted to group all IP addresses under a single output variable, so
that one could `terraform output ips` to get a clear view of what was
spawned (and so we could generate a SSH config file for accessing any of
the spawned VMs by name).

However, the "splat" syntax we wanted to use is not supported in
Terraform <= 0.11, so we just ignore the nodes (other than bootstrap and
router) for now.

For reference: hashicorp/terraform#17048

Issue: GH-889
  • Loading branch information
gdemonet committed Apr 9, 2019
1 parent 46c7dbe commit 79ccbad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ EOF
print_host_config router "$(get_ip router)" > "$SSH_CONFIG_FILE"
print_host_config bootstrap "$(get_ip bootstrap)" >> "$SSH_CONFIG_FILE"

for idx in `seq 1 $NODES_COUNT`; do
print_host_config "node$idx" "$(get_ip nodes "$(expr $idx - 1)")" >> "$SSH_CONFIG_FILE"
done
# FIXME: this needs Terraform v0.12 to work (see ./nodes.tf)
# for idx in `seq 1 $NODES_COUNT`; do
# print_host_config "node$idx" "$(get_ip nodes "$(expr $idx - 1)")" >> "$SSH_CONFIG_FILE"
# done
7 changes: 5 additions & 2 deletions eve/workers/openstack-multiple-nodes/terraform/nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ resource "openstack_compute_instance_v2" "nodes" {
"${local.workload_plane_network}",
]

# We need the subnets to be created before attempting to reach the DHCP server
# We need the subnets to be created before attempting to reach the DHCP server
depends_on = [
"openstack_networking_subnet_v2.control_plane_subnet",
"openstack_networking_subnet_v2.workload_plane_subnet",
Expand All @@ -129,6 +129,9 @@ output "ips" {
value = {
bootstrap = "${openstack_compute_instance_v2.bootstrap.network.0.fixed_ip_v4}"
router = "${openstack_compute_instance_v2.router.network.0.fixed_ip_v4}"
nodes = ["${openstack_compute_instance_v2.nodes.*.network.0.fixed_ip_v4}"]

# FIXME: this syntax does not work (but will in v0.12)
# see https://github.com/hashicorp/terraform/issues/17048
# nodes = ["${openstack_compute_instance_v2.nodes.*.network.0.fixed_ip_v4}"]
}
}

0 comments on commit 79ccbad

Please sign in to comment.