From 54fd61c887f266f8e2e6b1419a86fc6681116069 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 5 Jun 2019 16:38:53 -0300 Subject: Use Ansible instead of Bash for provisioning The deployment is not quite working, and I'm unable to test right now: DigitalOcean is returning 503 for my requests. As of this commit, I can run =ansible-playbook provider.yml= more than once and it will actually be idempotent. Notes: - SSH fingerprint are now taken from the public key file instead of manually supplying it in the terraform template using the =digitalocean_ssh_key= resource; - use Ansible instead of ad-hoc Bash scripts for provisioning the Droplets created by Terraform; - use the =filename.env.extension= to create the concrete files in CI; - use the =user_data= to add the know SSH key pair to the newly created Droplet; - add =rotate-ssh-keys.sh= utils; --- deploy.sh | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100755 deploy.sh (limited to 'deploy.sh') diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 9172803..0000000 --- a/deploy.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" - -apt_wait() { - local i=0 - tput sc - while fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ; do - case $((i % 4)) in - 0 ) j="-" ;; - 1 ) j="\\" ;; - 2 ) j="|" ;; - 3 ) j="/" ;; - esac - tput rc - echo -en "\r[$j] Waiting for other software managers to finish..." - sleep 0.5 - ((i=i+1)) - done -} - -apt_wait - -echo "Ubuntu update and install docker-compose..." -ssh "$TLD" sudo apt-get update -ssh "$TLD" sudo apt-get upgrade -y -ssh "$TLD" sudo apt-get install -y docker-compose -ssh "$TLD" sudo apt-get autoremove -y -echo "Done." - -echo "Copy over files..." -ssh "$TLD" mkdir -p /home/vps/ -ssh "$TLD" 'grep /home/vps/ /root/.profile || echo "cd /home/vps/" >> /root/.profile' -scp ./scripts/box/bash-aliases.sh "$TLD":/root/.bash_aliases -envsubst < docker-compose.yaml | ssh "$TLD" 'cat > /home/vps/docker-compose.yaml' -echo "Done." - -echo "Restart docker-compose" -ssh "$TLD" "cd /home/vps/ && docker-compose pull" -ssh "$TLD" "cd /home/vps/ && docker-compose up -d" -echo "Done." -- cgit v1.2.3