terminal-labs / sample-states

A collection of Sample SaltStack States
Other
3 stars 2 forks source link

Mount block storage on digitalocean #43

Open smitty42 opened 6 years ago

smitty42 commented 6 years ago

Issue by nixjdm Monday Aug 28, 2017 at 22:39 GMT Originally opened as https://github.com/terminal-labs/rambo/issues/72


smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 05:09 GMT


the docs on DO work perfectly

https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean

sudo parted /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 mklabel gpt sudo parted -a opt /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01 mkpart primary ext4 0% 100% sudo mkfs.ext4 /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 sudo mkdir -p /mnt/volume-nyc1-01-part1 echo '/dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-01-part1 /mnt/volume-nyc1-01-part1 ext4 defaults,nofail,discard 0 2' | sudo tee -a /etc/fstab sudo mount -a

we could just do the above in salt via cmd.run

or maybe this works https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.disk.html

smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 06:04 GMT


I think we should use grains to inform a vm what extra blocks disk to use. that way it will be easier to attach block storage on all the providers.

we could make a salt state that reads grains and makes the needed api calls to setup the block disk.

smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 06:13 GMT


the creation of new empty block storage on each "rambo up" can be done in the highstate. the attachment of long term storage blocks with data already in them needs to be done in something like the main vagrantfile.

smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 17:14 GMT


this command will list the volumes.

curl -X GET -H "Content-Type: application/json" -u "[your api token]:" "https://api.digitalocean.com/v2/volumes?region=nyc1"

smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 17:16 GMT


all the DO api calls need resource ids, names won't work. we need a system that can parse json and the correlate vms id with their names. look like we need to make a custom salt execution module.

smitty42 commented 6 years ago

Comment by verhulstm Tuesday Aug 29, 2017 at 17:24 GMT


I may have found a bug in DO's api. the attach call reports that it is in-progress forever.

however, attaching the block dev in the gui portal manually does work.

i filed a ticket