resource "openstack_compute_instance_v2" "followers" { count = var.num_followers name = "terratest_follower_${count.index}" image_id = var.image_id flavor_name = var.follower_flavor key_pair = openstack_compute_keypair_v2.this.name security_groups = [openstack_networking_secgroup_v2.ssh_ping.name] network { name = openstack_networking_network_v2.private.name } } resource "openstack_networking_floatingip_v2" "followers" { count = var.num_followers pool = "public" } resource "openstack_compute_floatingip_associate_v2" "followers" { count = var.num_followers floating_ip = openstack_networking_floatingip_v2.followers[count.index].address instance_id = openstack_compute_instance_v2.followers[count.index].id connection { type = "ssh" host = openstack_networking_floatingip_v2.followers[count.index].address user = "ubuntu" agent = false private_key = file(var.private_key_file) } provisioner "remote-exec" { inline = [ "sudo apt-get update > terratest.log", "sudo echo ${openstack_networking_floatingip_v2.leader.address} > leader_fip.txt", "echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections", "sudo apt-get -y install python3-pip >> terratest.log", "pip3 install numpy >> terratest.log" ] } } output "follower_floatingips" { value = openstack_compute_floatingip_associate_v2.followers.*.floating_ip }