aboutsummaryrefslogtreecommitdiffstats
path: root/openlab/modules/openstack/compute/main.tf
diff options
context:
space:
mode:
authoryoonsoonjahng <yoonsoon.jahng@yoppworks.com>2020-09-02 13:06:34 -0400
committeryoonsoonjahng <yoonsoon.jahng@yoppworks.com>2020-09-09 21:07:31 -0400
commitbc47c630d9fdc0e0e75b64a0c3d2311df28cfeaa (patch)
tree23f97a308af22389a46534dba2328e3d4e52e3e0 /openlab/modules/openstack/compute/main.tf
parente291bec2483388ff1b6f2552dd894d7092823a06 (diff)
added initial files
Issue-ID: INT-1698 Change-Id: I3405a7815bc51dbdf2cb61cd2003d46f428f059c Signed-off-by: yoonsoonjahng <yoonsoon.jahng@yoppworks.com>
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
+}