Volumes
resource "hcloud_server" "helloServer" { server_type = "cx22" ... } resource "hcloud_volume" "volume01" { name = "volume1" size = 10 server_id = hcloud_server.helloServer.id automount = true format = "xfs" } |
df ... /mnt/HC_Volume_100723816 |
No. 15
Partitions and mounting
Q: |
This is actually a series of exercises learning about partitions, the underlying file systems and mount procedures rather than an actual question.
|
output "volume_device" { value = hcloud_volume.volume01.linux_device description = "The volume's device" } |
terraform apply
...
volume_device = "/dev/disk/by-id/scsi-0HC_Volume_102626366" |
Desired /dev/disk/by-id/scsi-0HC_Volume_102626366 /volume01 xfs rw,defaults 0 2 |
resource "hcloud_server" "helloServer" { ... user_data = templatefile("tpl/userData.yml", { ... volume01Id = hcloud_volume.volume01.id }) } resource "hcloud_volume" "volume01" { server_id = hcloud_server.helloServer.id ... } |
Problem: Cyclic dependency helloServer <--> volume01 |
main.tf |
userData.yml.tpl |
---|---|
resource "hcloud_volume" "vol01" { size = 10 ... } resource "hcloud_server" "hello" { user_data = templatefile("userData.yml.tpl", { device=hcloud_volume.vol01.linux_device }) ... } resource "hcloud_volume_attachment" "main" { volume_id=hcloud_volume.vol01.id server_id=hcloud_server.hello.id } |
|
echo ${device} /${name} xfs rw,defaults 0 2 >> /etc/fstab |
No. 16
Mount point's name specification
Q: |
In Partitions and mounting the mount
point's name had been auto generated by
Cloud-init e.g,
|