Skip to content

Commit

Permalink
Migrate to AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
beksultan committed Aug 8, 2024
1 parent 05755e7 commit aa530cb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
chmod 700 ~/.ssh
ssh-keyscan 35.194.84.89 >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
echo "${{ secrets.OPENCHAIN_DEPLOY_KEY }}" | tr -d '\r' > ansible/key.pem
echo "${{ secrets.OPENCHAIN_DEPLOY_KEY_AWS }}" | tr -d '\r' > ansible/key.pem
chmod 600 ansible/key.pem
- name: Deploy
uses: docker://openplatform/ansible
Expand Down
4 changes: 2 additions & 2 deletions ansible/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#ssh -i ansible/key.pem -o StrictHostKeyChecking=no [email protected] 'ls -la'
#ssh -i ansible/key.pem -o StrictHostKeyChecking=no [email protected] 'ls -la'
#ssh -i ansible/key.pem -o StrictHostKeyChecking=no [email protected] 'ls -la'
ssh -i ansible/key.pem -o StrictHostKeyChecking=no [email protected] 'ls -la'
ssh -i ansible/key.pem -o StrictHostKeyChecking=no [email protected] 'ls -la'

mkdir ansible/host_vars
#for i in `seq 1 11`; do eval echo "key: \${{ secrets.SERVER${i} }}" >> ansible/host_vars/server${i}; done
#for i in `seq 1 11`; do eval echo "key: \$SERVER${i}" >> ansible/host_vars/server${i}; done
# For 2 containers on one host.
#for i in `seq 12 22`; do j=$(($i - 11)); eval echo "key2: \$SERVER${i}" >> ansible/host_vars/server${j}; done
ansible-playbook --private-key=ansible/key.pem -i ansible/inventory -f 11 -e "del_volume=${DELETE_VOLUME}" -e "image_tag=${IMAGE_TAG}" -e "count=11" -e "user_login=ubuntu" ansible/deploy.yml
ansible-playbook --private-key=ansible/key.pem -i ansible/inventory -f 11 -e "del_volume=${DELETE_VOLUME}" -e "image_tag=${IMAGE_TAG}" -e "count=11" -e "user_login=ec2-user" ansible/deploy.yml
16 changes: 8 additions & 8 deletions ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
state: absent
with_items:
- { name: openchain }
- { name: openchain-2 }
- { name: openchain-3 }
# - { name: openchain-2 }
# - { name: openchain-3 }
- name: Remove the embedded DB volumes
docker_volume:
name: "{{ item.name }}"
state: absent
with_items:
- { name: db_volume }
- { name: db_volume-2 }
- { name: db_volume-3 }
# - { name: db_volume-2 }
# - { name: db_volume-3 }
# when: del_volume
- name: Create a volumes for embedded DB
docker_volume:
name: "{{ item.name }}"
with_items:
- { name: db_volume }
- { name: db_volume-2 }
- { name: db_volume-3 }
# - { name: db_volume-2 }
# - { name: db_volume-3 }
- name: Delete all images
shell: docker image prune -a --force
- name: Re-create openchain containers
Expand All @@ -48,7 +48,7 @@
restart_policy: always
with_items:
- { name: openchain, db_volume: db_volume, app_port: 9090, api_port: 9190, secret_key: "4ec209b805ed3dab43dd626f016f7276b896a2cf38ff7796a40eb9ee32228afe" }
- { name: openchain-2, db_volume: db_volume-2, app_port: 9091, api_port: 9191, secret_key: "60113219c767c72b7b758645d1f55573a00ec3bf835fb3511be01d17839a994d" }
- { name: openchain-3, db_volume: db_volume-3, app_port: 9092, api_port: 9192, secret_key: "5f610a0cebb0685cd0ef3e354cb0893c39b372abcf851a676c05ddf25d991ed8" }
# - { name: openchain-2, db_volume: db_volume-2, app_port: 9091, api_port: 9191, secret_key: "60113219c767c72b7b758645d1f55573a00ec3bf835fb3511be01d17839a994d" }
# - { name: openchain-3, db_volume: db_volume-3, app_port: 9092, api_port: 9192, secret_key: "5f610a0cebb0685cd0ef3e354cb0893c39b372abcf851a676c05ddf25d991ed8" }
- name: Delete old images
shell: docker image prune -a --force --filter "until=24h"
2 changes: 1 addition & 1 deletion ansible/inventory
Original file line number Diff line number Diff line change
@@ -1 +1 @@
server ansible_host=34.145.185.53
server ansible_host=ec2-54-87-74-220.compute-1.amazonaws.com

0 comments on commit aa530cb

Please sign in to comment.