Forked from
rc / Terraform Openstack
145 commits behind the upstream repository.
-
Ryan Randles Jones authored4244145d
main.tf 4.97 KiB
# These are the defined variables used in all the modules. They are referenced in the modules, and defined here.
# This is where you would change any variable values.
# variables for networks and router
variable "admin_state_up" {default = true}
variable "enable_dhcp" {default = true}
# variable for floating-ip - also used in exrernal network creation
variable "public_network_name" {default = "bright-external-flat-externalnet"}
# variables for keypair module
variable "keypair_name" {default = "os-gen-keypair"}
variable "ssh_public_key" {default = "~/.ssh/id_rsa.pub"}
# variables for instance modules
variable "ohpc_instance_name" {default = "ohpc"}
variable "ood_instance_name" { default = "ood"}
variable "image_ohpc" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "image_ood" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "flavor" {default = "m1.medium"}
variable "internal_net" {default = "clusternet"}
variable "external_net" {default = "dmznet"}
variable "host_prefix" {default = "164.111.161.%s"}
variable "ohpc_user" {default = "centos"}
variable "ood_user" {default = "centos"}
variable "ssh_private_key" {default = "~/.ssh/id_rsa"}
# variables for node creation module
variable "image_compute" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "compute_node_count" {default = 2}
# runs the external-network module
module "dmz-network" {
source = "./external-network"
# Default name var is in the module main file
admin_state_up = var.admin_state_up
enable_dhcp = var.enable_dhcp
public_network_name = var.public_network_name
}
# calls the outputs defined in the external-network module
output "external_network_id" {
value = "${module.dmz-network.external_network_id}"
}
output "router_id" {
value = "${module.dmz-network.router_id}"
}
# runs the internal-network module
module "cluster-network" {
source = "./internal-network"
# Default name var is in the module main file
admin_state_up = var.admin_state_up
enable_dhcp = var.enable_dhcp
}
# calls the outputs defined in the internal-network module
output "internal_network_id" {
value = "${module.cluster-network.internal_network_id}"
}
# runs the floating-ip module - uses public network name defined above
module "floating-ip" {
source = "./floating-ip"
public_network_name = var.public_network_name
}
# calls the outputs defined in the floating-ip module
output "floating_ip_ohpc" {
value = "${module.floating-ip.ohpc_address}"
}
output "floating_ip_ood" {
value = "${module.floating-ip.ood_address}"
}
# runs the key-pair module - imports local public key into openstack and give it the name defined above in the variables
module "keypair" {
source = "./key-pair"
keypair_name = var.keypair_name
ssh_public_key = var.ssh_public_key
}
# calls the outputs defined in the key-pair module
output "keypair_name" {
value = "${module.keypair.keypair_name}"
}
# runs the ohpc-instance module - creates ohpc instance using variables defined above
# calls functions from dmz-network, keypair, and floating-ip modules to get values created there for use
module "ohpc-instance" {
source = "./ohpc-instance"
external_subnet_id = "${module.dmz-network.external_subnet_id}"
ohpc_instance_name = var.ohpc_instance_name
image_ohpc = var.image_ohpc
flavor = var.flavor
key_pair = "${module.keypair.keypair_name}"
external_net = var.external_net
internal_net = var.internal_net
floating_ip_ohpc = "${module.floating-ip.ohpc_address}"
host_prefix = var.host_prefix
ohpc_user = var.ohpc_user
ssh_private_key = var.ssh_private_key
}
# runs the ood-instance module - creates ood instance using variables defined above
# calls functions from cluster-network, keypair, and floating-ip modules to get values created there for use
module "ood-instance" {
source = "./ood-instance"
internal_subnet_id = "${module.cluster-network.internal_subnet_id}"
ood_instance_name = var.ood_instance_name
image_ood = var.image_ood
flavor = var.flavor
key_pair = "${module.keypair.keypair_name}"
internal_net = var.internal_net
external_net = var.external_net
floating_ip_ood = "${module.floating-ip.ood_address}"
host_prefix = var.host_prefix
ood_user = var.ood_user
ssh_private_key = var.ssh_private_key
}
# runs the nodes module - creates nodes using variables defined above
# calls functions from cluster-network and keypair modules to get values created there for use
module "nodes" {
source = "./nodes"
internal_subnet_id = "${module.cluster-network.internal_subnet_id}"
image_compute = var.image_compute
flavor = var.flavor
key_pair = "${module.keypair.keypair_name}"
compute_node_count = var.compute_node_count
internal_net = var.internal_net
}
# calls the outputs defined in the ohpc-instance module
output "ohpc-ssh_host" {
value = "${module.ohpc-instance.ssh_host}"
}
# calls the outputs defined in the ood-instance module
output "ood-ssh_host" {
value = "${module.ood-instance.ssh_host}"
}