diff options
author | EuAndreh <eu@euandre.org> | 2019-06-05 20:22:09 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-05 20:22:09 -0300 |
commit | 58d869f3ca3c980897e62cef55cda4fdf932affb (patch) | |
tree | 275f0bb6ceae93f5de4e6c2ebcfc206023600161 | |
parent | Always destroy infrastructure before applying (diff) | |
download | server-58d869f3ca3c980897e62cef55cda4fdf932affb.tar.gz server-58d869f3ca3c980897e62cef55cda4fdf932affb.tar.xz |
Add volume to VPS
Don't destroy everything on deploy. This would destroy the volume too.
-rw-r--r-- | provision.yaml | 5 | ||||
-rwxr-xr-x | scripts/ci/provision.sh | 4 | ||||
-rw-r--r-- | 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 @@ -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}" +} |