Newer
Older
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
# 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}"
}
module "cluster-network" {
source = "./internal-network"
# Default name var is in the module main file
# 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-address" {
# calls the outputs defined in the floating-ip module
value = "${module.floating-ip-address.ohpc_address}"
value = "${module.floating-ip-address.ood_address}"
# runs the key-pair module - imports local public key into openstack and give it the name defined above in the variables
module "import-keypair" {
keypair_name = var.keypair_name
ssh_public_key = var.ssh_public_key
# calls the outputs defined in the key-pair module
value = "${module.import-keypair.keypair_name}"
# runs the ohpc-instance module - creates ohpc instance using variables defined above
# calls functions from dmz-network, import-keypair, and floating-ip-address modules to get values created there for use
module "create-ohpc-instance" {
external_subnet_id = "${module.dmz-network.external_subnet_id}"
Ryan Randles Jones
committed
source = "./ohpc-instance"
ohpc_instance_name = var.ohpc_instance_name
image_ohpc = var.image_ohpc
flavor = var.flavor
key_pair = "${module.import-keypair.keypair_name}"
external_network = var.external_network
internal_network = var.internal_network
floating_ip_ohpc = "${module.floating-ip-address.ohpc_address}"
host_prefix = var.host_prefix
ohpc_user = var.ohpc_user
# runs the ood-instance module - creates ood instance using variables defined above
# calls functions from cluster-network, import-keypair, and floating-ip-address modules to get values created there for use
module "create-ood-instance" {
internal_subnet_id = "${module.cluster-network.internal_subnet_id}"
Ryan Randles Jones
committed
source = "./ood-instance"
ood_instance_name = var.ood_instance_name
key_pair = "${module.import-keypair.keypair_name}"
internal_network = var.internal_network
external_network = var.external_network
floating_ip_ood = "${module.floating-ip-address.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 import-keypair modules to get values created there for use
internal_subnet_id = "${module.cluster-network.internal_subnet_id}"
source = "./nodes"
image_compute = var.image_compute
flavor = var.flavor
key_pair = "${module.import-keypair.keypair_name}"
internal_network = var.internal_network
# calls the outputs defined in the ohpc-instance module
value = "${module.create-ohpc-instance.ssh_host}"
# calls the outputs defined in the ood-instance module
value = "${module.create-ood-instance.ssh_host}"
}
# compute node post provision
resource "null_resource" "compute_ops" {
triggers = {
ohpc_instance = module.create-ohpc-instance.id
compute_instances = join(",", module.nodes.id)
}
connection {
host = module.create-ohpc-instance.ssh_host
user = var.ohpc_user
private_key = file(var.ssh_private_key)
}
# compute node
provisioner "remote-exec" {
inline = [
for node, net in module.nodes.network:
"ansible-playbook -i /CRI_XCBC/hosts -l `hostname -s` -e \"{'compute_nodes':[{'name':'${node}', 'ip':'${net[0].fixed_ip_v4}', 'mac':'${net[0].mac}', 'vnfs':'', 'sockets':'1', 'corespersocket':'1'}]}\" /CRI_XCBC/site-ops.yaml -b -v"]