aboutsummaryrefslogtreecommitdiffstats
path: root/openlab/modules/openstack/compute/main.tf
blob: 1e087379f06cb3bbc65d4a752a67673973d15c7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
resource "openstack_compute_instance_v2" "nodes" {
  name      = "${var.cluster_name}-${var.node_name}-${count.index}"
  image_id  = data.openstack_images_image_v2.vm_image.id
  flavor_id = data.openstack_compute_flavor_v2.flavor.id
  key_pair  = data.terraform_remote_state.keypair.outputs.name
  network {
    name = data.terraform_remote_state.network.outputs.name
  }
  security_groups = [ data.terraform_remote_state.securitygroup.outputs.name ]

  user_data = var.user_data

  count = var.node_count
}

resource "openstack_compute_floatingip_v2" "floatingip" {
  pool = var.floating_ip_pool

  count = var.node_count
}

resource "openstack_compute_floatingip_associate_v2" "floatipassociation" {
  floating_ip = openstack_compute_floatingip_v2.floatingip[count.index].address
  instance_id = openstack_compute_instance_v2.nodes[count.index].id

  count = var.node_count
}