Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rrand11/terraform-openstack
  • louistw/terraform-openstack
  • chirag24/terraform-openstack
  • mmoo97/terraform-openstack
  • jpr/terraform-openstack
  • ravi89/terraform-openstack
  • noe121/terraform-openstack
  • ishan747/terraform-openstack
  • clint93/terraform-openstack
  • ravi89/terraform_openstack
  • krish94/terraform-openstack
  • rc/terraform-openstack
12 results
Show changes
Commits on Source (60)
......@@ -142,7 +142,51 @@ production-deploy:
stage: deploy
tags: [build]
script:
- echo "swap the floating IP between prod and newly deployed instances"
- export prod_instance_id=$(openstack floating ip show $prod_floating_ip -c port_details -f value | awk -F', ' '{print $2}' | awk -F"'" '{print $2}')
- export prod_volume=$(openstack server show $prod_instance_id -c volumes_attached -f value | awk -F"'" '{print $4}')
- export prod_queue_volume=$(openstack server show $prod_instance_id -c volumes_attached -f value | awk -F"'" '{print $4}' | awk 'NR==2')
- |
eval $(ssh-agent -s)
chmod 400 "${SSH_PRIV_KEY}"
ssh-add "${SSH_PRIV_KEY}"
mkdir ~/.ssh
chmod 700 ~/.ssh
# - ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$prod_floating_ip sudo systemctl stop mariadb
- ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$prod_floating_ip sudo umount /var/lib/mysql && df -h
- ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$prod_floating_ip sudo umount /data/xdmod/queues && df -h
- openstack server remove volume $prod_instance_id $prod_volume
- openstack server remove volume $prod_instance_id $prod_queue_volume
- openstack server stop $prod_instance_id
# Exporting Staging Volume IDs
- export staging_volume=$(openstack server show $instance_id -c volumes_attached -f value | awk -F"'" '{print $4}' | awk 'NR==1')
- export staging_queue_volume=$(openstack server show $instance_id -c volumes_attached -f value | awk -F"'" '{print $4}' | awk 'NR==2')
# Logging Information
- echo "Detaching staging_volume_id=${staging_volume} and staging_queue_volume_id=${staging_queue_volume} from staging_instance_id=${instance_id}"
# Stopping MariaDB Service on Staging Instance
# - ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$staging_floating_ip sudo systemctl stop mariadb
# Unmounting MySQL Data Directories
- ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$staging_floating_ip sudo umount /var/lib/mysql && df -h
- ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$staging_floating_ip sudo umount /data/xdmod/queues && df -h
# Removing Volumes from Server
- openstack server remove volume $instance_id $staging_volume
- openstack server remove volume $instance_id $staging_queue_volume
- echo "Attach prod volume $xdmod-prod-vol-$BUILD_DATE to staging instance $instance_id"
- echo "Attach prod queue volume xdmod-prod-queue-vol-$BUILD_DATE to staging instance $instance_id"
- openstack volume snapshot create --volume $prod_volume xdmod-prod-data-vol-snapshot-$BUILD_DATE
- openstack volume snapshot create --volume $prod_queue_volume xdmod-prod-queue-vol-snapshot-$BUILD_DATE
- openstack volume create --snapshot xdmod-prod-data-vol-snapshot-$BUILD_DATE --size 150 xdmod-prod-vol-$BUILD_DATE
- openstack volume create --snapshot xdmod-prod-queue-vol-snapshot-$BUILD_DATE --size 1 xdmod-prod-queue-vol-$BUILD_DATE
- openstack server add volume $instance_id xdmod-prod-vol-$BUILD_DATE --device /dev/vdb
- openstack server add volume $instance_id xdmod-prod-queue-vol-$BUILD_DATE --device /dev/vdc
- echo "swap the floating IP between prod and staging instances"
- openstack server remove floating ip $prod_instance_id $prod_floating_ip
- openstack server remove floating ip $instance_id $instance_floating_ip
- openstack server add floating ip $instance_id $prod_floating_ip
......
......@@ -14,6 +14,7 @@ provider "openstack" {
}
}
# runs the internal-network module
module "cluster-network" {
internal_net = var.internal_network
......@@ -56,6 +57,7 @@ output "keypair_name" {
data "openstack_networking_network_v2" "external_net" {name = var.external_network}
data "openstack_blockstorage_volume_v3" "disk" {name = var.data_volume}
data "openstack_blockstorage_volume_v3" "disk2" {name = var.xdmod_queue_data_volume}
# 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
......@@ -71,7 +73,10 @@ module "create-ohpc-instance" {
floating_ip_ohpc = module.floating-ip-address.ohpc_address
ohpc_user = var.ohpc_user
ssh_private_key = var.ssh_private_key
vol_id = data.openstack_blockstorage_volume_v3.disk.id
vol_ids = [
data.openstack_blockstorage_volume_v3.disk.id,
data.openstack_blockstorage_volume_v3.disk2.id,
]
}
# runs the ood-instance module - creates ood instance using variables defined above
......@@ -132,34 +137,18 @@ resource "null_resource" "ops" {
private_key = var.ssh_private_key
}
# clone CRI_XCBC on node
provisioner "remote-exec" {
inline = [
"ls -al /CRI_XCBC",
]
}
# moves CRI_XCBC file into directory made above
provisioner "remote-exec" {
inline = [
"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",
]
}
provisioner "remote-exec" {
inline = [
"sudo mount ${module.create-ohpc-instance.device}1 /var/lib/mysql",
"sudo df -h",
"sudo systemctl restart mariadb",
"git clone https://github.com/jprorama/CRI_XCBC.git /CRI_XCBC",
]
}
# compute node registration on ohpc
provisioner "remote-exec" {
inline = [
for node, net in module.nodes.network:
"ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` -e \"{'cod_deploy':'false', '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"
for node, net in module.nodes.network:
"ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` -e \"{'cod_deploy':'false', '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"
]
}
......
......@@ -26,7 +26,10 @@ variable "floating_ip_ohpc" {type = string}
variable "ohpc_user" {}
variable "ssh_private_key" {}
variable "vol_id" {}
variable "vol_ids" {
type = list(string)
default = []
}
# creates details for the OHPC instance
resource "openstack_compute_instance_v2" "ohpc" {
......@@ -37,12 +40,24 @@ resource "openstack_compute_instance_v2" "ohpc" {
security_groups = ["default"]
user_data = <<-EOF
#cloud-config
write_files:
- content: |
10.1.1.10 ohpc ohpc.novalocal
owner: centos:centos
path: /etc/hosts
permissions: 0644
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
EOF
# defines the networks of the instance
......@@ -61,14 +76,15 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
instance_id = openstack_compute_instance_v2.ohpc.id
}
# Attach a volume
# Attach volumes
resource "openstack_compute_volume_attach_v2" "volume_attach" {
count = length(var.vol_ids)
instance_id = openstack_compute_instance_v2.ohpc.id
volume_id = var.vol_id
volume_id = var.vol_ids[count.index]
}
output "xdmod_instance_id" {
value = openstack_compute_instance_v2.ohpc.id
value = openstack_compute_instance_v2.ohpc.id
}
output "ssh_host" {
......@@ -76,5 +92,8 @@ output "ssh_host" {
}
output "device" {
value = openstack_compute_volume_attach_v2.volume_attach.device
value = [
openstack_compute_volume_attach_v2.volume_attach[0].device,
openstack_compute_volume_attach_v2.volume_attach[1].device,
]
}
......@@ -26,6 +26,7 @@ variable "ohpc_user" {default = "centos"}
variable "ood_user" {default = "centos"}
variable "ssh_private_key" {default = "~/.ssh/id_rsa"}
variable "data_volume" {default = ""}
variable "xdmod_queue_data_volume" {default = "xdmod_queue_data_volume"}
# variables for node creation module
variable "image_compute" {default = "compute-v1"}
......