Skip to content
Snippets Groups Projects
Commit d04ff7c5 authored by Ravi Tripathi's avatar Ravi Tripathi
Browse files

Add job for floating ip swap in staging env

parent c32d2edc
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,39 @@ tf-apply:
TF_SUCCESS=true
fi
echo "Terraform success: $TF_SUCCESS"
- export instance_floating_ip=$(terraform output -raw floating_ip_ohpc)
- export instance_id=$(terraform output -raw xdmod_instance_id)
- echo "instance_floating_ip=${instance_floating_ip}" | tee -a $CI_PROJECT_DIR/vars.env
- echo "instance_id=${instance_id}" | tee -a $CI_PROJECT_DIR/vars.env
artifacts:
reports:
dotenv: vars.env
staging-post-deploy:
environment:
name: staging
stage: build
tags: [build]
script:
- export staging_floating_ip="138.26.49.15"
- export old_instance_id=$(openstack floating ip show $staging_floating_ip -c port_details -f value | awk -F', ' '{print $2}' | awk -F"'" '{print $2}')
- echo "staging_floating_ip=${staging_floating_ip}"
- echo "old_instance_id=${old_instance_id}"
- |
if [[ -n "$old_instance_id" ]]; then
openstack server remove floating ip $old_instance_id $staging_floating_ip
openstack server delete $old_instance_id
fi
- openstack server remove floating ip $instance_id $instance_floating_ip
- openstack server add floating ip $instance_id $staging_floating_ip
- openstack floating ip delete $instance_floating_ip
needs:
- job: tf-apply
artifacts: true
rules:
- if: '$TARGET_ENV == "staging"'
clean-up:
stage: cleanup
......
......@@ -108,6 +108,10 @@ output "ohpc-ssh_host" {
value = module.create-ohpc-instance.ssh_host
}
output "xdmod_instance_id" {
value = module.create-ohpc-instance.xdmod_instance_id
}
# calls the outputs defined in the ood-instance module
#output "ood-ssh_host" {
# value = module.create-ood-instance.ssh_host
......@@ -118,7 +122,7 @@ output "ohpc-ssh_host" {
# that lead to inconsistent deploy successes.
resource "null_resource" "ops" {
triggers = {
ohpc_instance = module.create-ohpc-instance.id
ohpc_instance = module.create-ohpc-instance.xdmod_instance_id
compute_instances = join(",", module.nodes.id)
}
......
......@@ -67,7 +67,7 @@ resource "openstack_compute_volume_attach_v2" "volume_attach" {
volume_id = var.vol_id
}
output "id" {
output "xdmod_instance_id" {
value = openstack_compute_instance_v2.ohpc.id
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment