From 58d869f3ca3c980897e62cef55cda4fdf932affb Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 5 Jun 2019 20:22:09 -0300 Subject: Add volume to VPS Don't destroy everything on deploy. This would destroy the volume too. --- provision.yaml | 5 +++++ scripts/ci/provision.sh | 4 ---- vps.tf | 13 +++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/provision.yaml b/provision.yaml index 636e6d1..2ff7c6c 100644 --- a/provision.yaml +++ b/provision.yaml @@ -19,6 +19,11 @@ file: path: /home/vps/ state: directory + - name: Create symlink to attached volume + file: + src: /mnt/vps_persistent_volume + dest: /home/vps/volumes + state: link - name: Copy file copy: src={{ item.src }} dest={{ item.dest }} with_items: diff --git a/scripts/ci/provision.sh b/scripts/ci/provision.sh index b72a0f5..1000a55 100755 --- a/scripts/ci/provision.sh +++ b/scripts/ci/provision.sh @@ -18,10 +18,6 @@ envsubst < ./scripts/box/run-backup.env.sh | ssh "$TLD" 'cat > /home/vps/run-bac ssh "$TLD" /home/vps/run-backup.sh echo "Done." -echo "Destroying existing infrastructure..." -terraform destroy -input=false -auto-approve -echo "Done." - echo "Running 'terraform plan' and storing the planfile..." terraform --version terraform init diff --git a/vps.tf b/vps.tf index e278cc1..55a640e 100644 --- a/vps.tf +++ b/vps.tf @@ -42,3 +42,16 @@ resource "digitalocean_floating_ip_assignment" "vps" { ip_address = "${var.floating_ip}" droplet_id = "${digitalocean_droplet.vps.id}" } + +resource "digitalocean_volume" "vps_persistent_volume" { + region = "nyc3" + name = "vps-persistent-volume" + size = 10 + initial_filesystem_type = "ext4" + description = "Persistent disk to store docker volumes contents across droplets being created and destroyed" +} + +resource "digitalocean_volume_attachment" "foobar" { + volume_id = "${digitalocean_volume.vps_persistent_volume.id}" + droplet_id = "${digitalocean_droplet.vps.id}" +} -- cgit v1.2.3