Skip to content
Snippets Groups Projects
Commit b6688ded authored by Ryan Jones's avatar Ryan Jones
Browse files

Merge branch 'make-modular' of...

Merge branch 'make-modular' of https://gitlab.rc.uab.edu/rrand11/terraform-openstack into make-modular

pull from repo to push change
parents 0a91a3b8 896d944d
No related branches found
No related tags found
No related merge requests found
variable "compute_node_count" {default = 2}
variable "external_net" {default = "dmznet"}
variable "external_subnet_id" {default = "string"}
variable "flavor" {default = "m1.medium"}
variable "floating_ip_ohpc" {type = string}
variable "floating_ip_ood" {type = string}
variable "host_prefix" {default = "164.111.161.%s"}
variable "image_ohpc" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "image_ood" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "image_compute" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "internal_net" {default = "clusternet"}
variable "internal_subnet_id" {default = "string"}
variable "keypair_name" {default = "os-gen-keypair"}
variable "ohpc_instance_name" {default = "ohpc"}
variable "ohpc_user" {default = "centos"}
variable "ood_instance_name" { default = "ood"}
variable "ood_user" {default = "centos"}
variable "ssh_private_key" {default = "~/.ssh/id_rsa"}
variable "ssh_public_key" {default = "~/.ssh/id_rsa.pub"}
resource "openstack_compute_keypair_v2" "keypair" {
name = var.keypair-name
public_key = file(var.ssh-public-key)
name = var.keypair_name
public_key = file(var.ssh_public_key)
}
# creates details for the OHPC instance using variables defined in vars.tf
# creates details for the OHPC instance
resource "openstack_compute_instance_v2" "ohpc" {
depends_on = [var.external-subnet-id]
name = var.ohpc-instance-name
depends_on = [var.external_subnet_id]
name = var.ohpc_instance_name
image_name = var.image_ohpc
flavor_name = var.flavor
key_pair = openstack_compute_keypair_v2.keypair.name
......@@ -14,30 +35,30 @@ resource "openstack_compute_instance_v2" "ohpc" {
# defines the networks of the instance
network {
name = var.external-net
name = var.external_net
}
network {
name = var.internal-net
name = var.internal_net
}
}
# associates floating ip with the OHPC instance and run the ansible playbook
# associates floating ip with the OHPC instance
resource "openstack_compute_floatingip_associate_v2" "ohpc" {
floating_ip = var.floating-ip-ohpc
floating_ip = var.floating_ip_ohpc
instance_id = openstack_compute_instance_v2.ohpc.id
# defines ssh connection
connection {
host = format(var.host-prefix,element(split(".", var.floating-ip-ohpc),3,),)
user = var.ohpc-user
private_key = file(var.ssh-private-key)
host = format(var.host_prefix,element(split(".", var.floating_ip_ohpc),3,),)
user = var.ohpc_user
private_key = file(var.ssh_private_key)
}
}
# creates details for the OOD instance using variables defined in vars.tf
# creates details for the OOD instance
resource "openstack_compute_instance_v2" "ood" {
depends_on = [var.internal-subnet-id]
name = var.ood-instance-name
depends_on = [var.internal_subnet-id]
name = var.ood_instance_name
image_name = var.image_ood
flavor_name = var.flavor
key_pair = openstack_compute_keypair_v2.keypair.name
......@@ -45,29 +66,29 @@ resource "openstack_compute_instance_v2" "ood" {
# defines the networks of the instance
network {
name = var.external-net
name = var.external_net
}
network {
name = var.internal-net
name = var.internal_net
}
}
# associates floating ip with the OOD instance and run the ansible playbook
# associates floating ip with the OOD instance
resource "openstack_compute_floatingip_associate_v2" "ood" {
floating_ip = var.floating-ip-ood
floating_ip = var.floating_ip_ood
instance_id = openstack_compute_instance_v2.ood.id
# defines ssh connection
connection {
host = format(var.host-prefix,element(split(".", var.floating-ip-ood),3,),)
user = var.ood-user
private_key = file(var.ssh-private-key)
host = format(var.host-prefix,element(split(".", var.floating_ip_ood),3,),)
user = var.ood_user
private_key = file(var.ssh_private_key)
}
}
# creates compute node
resource "openstack_compute_instance_v2" "c0" {
depends_on = [var.internal-subnet-id]
depends_on = [var.internal_subnet_id]
name = "c${count.index}"
image_name = var.image_compute
flavor_name = var.flavor
......@@ -77,10 +98,10 @@ resource "openstack_compute_instance_v2" "c0" {
# defines the networks of the instance
network {
name = var.internal-net
name = var.internal_net
}
}
output "ssh_host"{
value = format(var.host-prefix,element(split(".", var.floating-ip-ood),3,),)
value = format(var.host_prefix,element(split(".", var.floating_ip_ood),3,),)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment