Newer
Older
# is created in external-network module and called in root module
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.42.0"
}
}
}
variable "ohpc_instance_name" {}
variable "image_ohpc" {}
variable "flavor" {}
# is created in key-pair module and called in root module
# is created in floating-ip module and called in root module
variable "ohpc_user" {}
variable "ssh_private_key" {}
variable "vol_ids" {
type = list(string)
default = []
}
# creates details for the OHPC instance
resource "openstack_compute_instance_v2" "ohpc" {
name = var.ohpc_instance_name
image_name = var.image_ohpc
flavor_name = var.flavor
user_data = <<-EOF
#cloud-config
write_files:
- content: |
10.1.1.10 ohpc ohpc.novalocal
owner: centos:centos
path: /etc/hosts
permissions: '0644'
runcmd:
- |
#!/bin/bash
sudo mkdir -p /data/xdmod/queues
sudo mount /dev/vdb1 /var/lib/mysql
sudo mount /dev/vdc1 /data/xdmod/queues
sudo df -h
sudo systemctl restart mariadb
sudo sed -i -E 's/xdmod..nip.io/xdmod.rc.uab.edu/g' /etc/httpd/conf.d/xdmod.conf
sudo sed -i -E 's/xdmod..nip.io/xdmod.rc.uab.edu/g' /etc/xdmod/simplesamlphp/config/config.php
sudo systemctl restart httpd
# defines the networks of the instance
network {
}
}
# 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
# Attach specific volumes
resource "openstack_compute_volume_attach_v2" "attach_prod_volume" {
instance_id = openstack_compute_instance_v2.ohpc.id
resource "openstack_compute_volume_attach_v2" "attach_prod_queue_volume" {
instance_id = openstack_compute_instance_v2.ohpc.id

Krish Moodbidri
committed
value = openstack_compute_instance_v2.ohpc.id
openstack_compute_volume_attach_v2.attach_prod_volume.device,
openstack_compute_volume_attach_v2.attach_prod_queue_volume.device