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

main for ohpc instance creation

parent b6688ded
No related branches found
No related tags found
No related merge requests found
variable "ohpc_instance_name" {default = "ohpc"}
variable "image_ohpc" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "flavor" {default = "m1.medium"}
variable "keypair_name" {default = "os-gen-keypair"}
variable "internal_net" {default = "clusternet"}
variable "external_net" {default = "dmznet"}
variable "floating_ip_ohpc" {type = string}
variable "host_prefix" {default = "164.111.161.%s"}
variable "ohpc_user" {default = "centos"}
variable "ssh_private_key" {default = "~/.ssh/id_rsa"}
# 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)
}
}
\ 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