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

create ood instance module

parent 976aea51
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)
}
# creates details for the OHPC instance
resource "openstack_compute_instance_v2" "ohpc" {
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
security_groups = ["default"]
# defines the networks of the instance
network {
name = var.external_net
}
network {
name = var.internal_net
}
}
# associates floating ip with the OHPC instance
resource "openstack_compute_floatingip_associate_v2" "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)
}
}
# creates details for the OOD instance
resource "openstack_compute_instance_v2" "ood" {
......@@ -86,21 +43,7 @@ resource "openstack_compute_floatingip_associate_v2" "ood" {
}
}
# creates compute node
resource "openstack_compute_instance_v2" "c0" {
depends_on = [var.internal_subnet_id]
name = "c${count.index}"
image_name = var.image_compute
flavor_name = var.flavor
key_pair = openstack_compute_keypair_v2.keypair.name
security_groups = ["default"]
count = var.compute_node_count
# defines the networks of the instance
network {
name = var.internal_net
}
}
output "ssh_host"{
value = format(var.host_prefix,element(split(".", var.floating_ip_ood),3,),)
......
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