Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terraform Openstack
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
Terraform Openstack
Commits
21ccd2d3
Commit
21ccd2d3
authored
1 year ago
by
Krish Moodbidri
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/feat-test-xdmod-queue-vol' into feat-integration-testing
parents
0b3e4cb0
681d9290
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
Integration Testing: Sequential Merge and Validation of Four Feature Branches (PR #43,#44, #45,#46)
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+45
-1
45 additions, 1 deletion
.gitlab-ci.yml
main.tf
+5
-1
5 additions, 1 deletion
main.tf
ohpc-instance/main.tf
+12
-5
12 additions, 5 deletions
ohpc-instance/main.tf
vars.tf
+1
-0
1 addition, 0 deletions
vars.tf
with
63 additions
and
7 deletions
.gitlab-ci.yml
+
45
−
1
View file @
21ccd2d3
...
@@ -142,7 +142,51 @@ production-deploy:
...
@@ -142,7 +142,51 @@ production-deploy:
stage
:
deploy
stage
:
deploy
tags
:
[
build
]
tags
:
[
build
]
script
:
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 $prod_instance_id $prod_floating_ip
-
openstack server remove floating ip $instance_id $instance_floating_ip
-
openstack server remove floating ip $instance_id $instance_floating_ip
-
openstack server add floating ip $instance_id $prod_floating_ip
-
openstack server add floating ip $instance_id $prod_floating_ip
...
...
This diff is collapsed.
Click to expand it.
main.tf
+
5
−
1
View file @
21ccd2d3
...
@@ -57,6 +57,7 @@ output "keypair_name" {
...
@@ -57,6 +57,7 @@ output "keypair_name" {
data
"openstack_networking_network_v2"
"external_net"
{
name
=
var
.
external_network
}
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"
"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
# 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
# calls functions from dmz-network, import-keypair, and floating-ip-address modules to get values created there for use
...
@@ -72,7 +73,10 @@ module "create-ohpc-instance" {
...
@@ -72,7 +73,10 @@ module "create-ohpc-instance" {
floating_ip_ohpc
=
module
.
floating-ip-address
.
ohpc_address
floating_ip_ohpc
=
module
.
floating-ip-address
.
ohpc_address
ohpc_user
=
var
.
ohpc_user
ohpc_user
=
var
.
ohpc_user
ssh_private_key
=
var
.
ssh_private_key
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
# runs the ood-instance module - creates ood instance using variables defined above
...
...
This diff is collapsed.
Click to expand it.
ohpc-instance/main.tf
+
12
−
5
View file @
21ccd2d3
...
@@ -26,7 +26,10 @@ variable "floating_ip_ohpc" {type = string}
...
@@ -26,7 +26,10 @@ variable "floating_ip_ohpc" {type = string}
variable
"ohpc_user"
{}
variable
"ohpc_user"
{}
variable
"ssh_private_key"
{}
variable
"ssh_private_key"
{}
variable
"vol_id"
{}
variable
"vol_ids"
{
type
=
list
(
string
)
default
=
[]
}
# creates details for the OHPC instance
# creates details for the OHPC instance
resource
"openstack_compute_instance_v2"
"ohpc"
{
resource
"openstack_compute_instance_v2"
"ohpc"
{
...
@@ -73,14 +76,15 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
...
@@ -73,14 +76,15 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
instance_id
=
openstack_compute_instance_v2
.
ohpc
.
id
instance_id
=
openstack_compute_instance_v2
.
ohpc
.
id
}
}
# Attach
a
volume
# Attach volume
s
resource
"openstack_compute_volume_attach_v2"
"volume_attach"
{
resource
"openstack_compute_volume_attach_v2"
"volume_attach"
{
count
=
length
(
var
.
vol_ids
)
instance_id
=
openstack_compute_instance_v2
.
ohpc
.
id
instance_id
=
openstack_compute_instance_v2
.
ohpc
.
id
volume_id
=
var
.
vol_id
volume_id
=
var
.
vol_id
s
[
count
.
index
]
}
}
output
"xdmod_instance_id"
{
output
"xdmod_instance_id"
{
value
=
openstack_compute_instance_v2
.
ohpc
.
id
value
=
openstack_compute_instance_v2
.
ohpc
.
id
}
}
output
"ssh_host"
{
output
"ssh_host"
{
...
@@ -88,5 +92,8 @@ output "ssh_host" {
...
@@ -88,5 +92,8 @@ output "ssh_host" {
}
}
output
"device"
{
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
,
]
}
}
This diff is collapsed.
Click to expand it.
vars.tf
+
1
−
0
View file @
21ccd2d3
...
@@ -26,6 +26,7 @@ variable "ohpc_user" {default = "centos"}
...
@@ -26,6 +26,7 @@ variable "ohpc_user" {default = "centos"}
variable
"ood_user"
{
default
=
"centos"
}
variable
"ood_user"
{
default
=
"centos"
}
variable
"ssh_private_key"
{
default
=
"~/.ssh/id_rsa"
}
variable
"ssh_private_key"
{
default
=
"~/.ssh/id_rsa"
}
variable
"data_volume"
{
default
=
""
}
variable
"data_volume"
{
default
=
""
}
variable
"xdmod_queue_data_volume"
{
default
=
"xdmod_queue_data_volume"
}
# variables for node creation module
# variables for node creation module
variable
"image_compute"
{
default
=
"compute-v1"
}
variable
"image_compute"
{
default
=
"compute-v1"
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment