aboutsummaryrefslogtreecommitdiffstats
path: root/openlab/modules/openstack/compute/main.tf
diff options
context:
space:
mode:
Diffstat (limited to 'openlab/modules/openstack/compute/main.tf')
-rw-r--r--openlab/modules/openstack/compute/main.tf27
1 files changed, 27 insertions, 0 deletions
diff --git a/openlab/modules/openstack/compute/main.tf b/openlab/modules/openstack/compute/main.tf
new file mode 100644
index 0000000..1e08737
--- /dev/null
+++ b/openlab/modules/openstack/compute/main.tf
@@ -0,0 +1,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
+}