From c635b33f4a5845561dd4fc11be9d785b19295ced Mon Sep 17 00:00:00 2001
From: Krish Moodbidri <krish94@uab.edu>
Date: Fri, 30 May 2025 13:34:47 -0500
Subject: [PATCH] Update 2 files

- /ansible/accountservices.yml
- /.gitlab-ci.yml
---
 .gitlab-ci.yml              | 53 +++++++++++++++++++++++++++++++++++++
 ansible/accountservices.yml |  8 ++++++
 2 files changed, 61 insertions(+)
 create mode 100644 ansible/accountservices.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 25048fe..06876c1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -426,3 +426,56 @@ deploy_ood_node:
   rules:
     - if: $PIPELINE_TARGET == "deploy" && $OOD_IMAGE_ID
       when: always
+
+deploy_account_services_:
+  stage: deploy
+  environment:
+    name: $ENV
+  tags:
+    - build
+  script:
+    - openstack image set --accept f10c29db-362e-440a-97b2-0230c316369f || true
+    - FAILED=false
+    - |
+      cat > user_data.txt <<EOF
+      #!/bin/bash
+      cat >> /etc/NetworkManager/conf.d/90-dns-none.conf<<EEOF
+      [main]
+      dns=none
+      EEOF
+      systemctl reload NetworkManager
+      echo "$DEV_KEY" >> /root/.ssh/authorized_keys
+      ip route replace default via ${DEFAULT_GATEWAY_IP} dev eth0
+      git clone ${CI_REPOSITORY_URL} /tmp/${CI_PROJECT_NAME}
+      cd /tmp/${CI_PROJECT_NAME}
+      git checkout ${CI_COMMIT_REF_NAME}
+      cat >> ansible/hosts<<EEOF
+      [$ENV]
+      127.0.0.1
+      EEOF
+      ansible-playbook -c local -i ansible/hosts --extra-vars="$EXTRA_VARS" ansible/accountservices.yml | tee -a /tmp/ansible.log
+      rm -rf /tmp/${CI_PROJECT_NAME}
+      EOF
+    - |
+      export cmd="openstack server create"
+      cmd+=" -c id -f value --image f10c29db-362e-440a-97b2-0230c316369f"
+      cmd+=" --flavor $INSTANCE_FLAVOR"
+      for security_group in ${SECURITY_GROUP_LIST[@]};
+      do
+        cmd+=" --security-group $security_group"
+      done
+      cmd+=" --user-data user_data.txt"
+      if [ -n "$PROXY_NETWORK" ];then cmd+=" --network $PROXY_NETWORK"; fi
+      if [ -n "$ACCOUNT_SERVICES_APP_PORT" ];then cmd+=" --port $ACCOUNT_SERVICES_APP_PORT"; fi
+      cmd+=" --wait account-services-app"
+    - export ACCOUNT_SERVICES_APP_INSTANCE_ID=$(bash -c "$cmd")
+    - |
+      # Associate the floating IP(s) with the Account Services App instance
+      for ACCOUNT_SERVICES_APP_FLOATING_IP in ${ACCOUNT_SERVICES_APP_FLOATING_IP_LIST[@]};
+      do
+        echo "Associating FLOATING_IP $ACCOUNT_SERVICES_APP_FLOATING_IP with ACCOUNT_SERVICES_APP_INSTANCE_ID $ACCOUNT_SERVICES_APP_INSTANCE_ID"
+        openstack server add floating ip $ACCOUNT_SERVICES_APP_INSTANCE_ID $ACCOUNT_SERVICES_APP_FLOATING_IP
+      done
+  rules:
+    - if: $PIPELINE_TARGET == "deploy" && $DEPLOY_ACCOUNT_SERVICES_APP == "true"
+      when: always
diff --git a/ansible/accountservices.yml b/ansible/accountservices.yml
new file mode 100644
index 0000000..f3d07fb
--- /dev/null
+++ b/ansible/accountservices.yml
@@ -0,0 +1,8 @@
+---
+- name: Setup node to run account services app
+  hosts: default
+  become: true
+  roles:
+    - { name: 'install_rabbitmq', tags: 'install_rabbitmq' }
+    - { name: 'install_accountapp', tags: 'install_accountapp' }
+
-- 
GitLab