0

Is there any drawback of using LVM disks in terraform managed virtual machines?

Currently I come to the project where all disks are simple linux disks, but terraform is unable to resize them up without destroying them (data loss). And as everything grows there is from time to time need for that.

I use terraform with vsphere provider for virtual machines and saltstack for filesystem creation.

My idea was to move everything to LVM disks... I wonder is there any fallout from using LVM with terraform? Could it be done better than combining terraform/saltstack?

Snippets of my terraform code:

  disk {
    label        = "disk-lvm"
    unit_number  = 2
    attach       = true
    path         = "storage/my-lvm.vmdk"
    disk_sharing = "sharingNone"
    datastore_id = data.vsphere_datastore.shared_vm.id
  }

And saltstack, disk seens as /dev/sdc

/dev/sdc:
  lvm.pv_present

data_vg:
  lvm.vg_present:
  - devices: /dev/sdc

lv_data:
  lvm.lv_present:
  - vgname: d_vg
  - size: 300.9G

Mount my-lvm storage:
  mount.mounted:
    - name: /data
    - device: /dev/mapper/d_vg-lv_data
    - fstype: xfs
    - opts:
        - defaults
    - mkmnt: True
    - persist: True
Wojtas.Zet
  • 391
  • 1
  • 3
  • 8
  • could you share your terraform code? – c4f4t0r Jul 21 '20 at 12:27
  • I did - I edited the question above. What I am trying to accomplish is: Have easily and safely expandable disks on my terraform/saltstack managed VMs. Do I do it optimally? Is there a better way? Would above have any major drawbacks? – Wojtas.Zet Jul 21 '20 at 14:26
  • look like correct, anyway, specify the size of the disk and every time you change some attribute, you could use terraform plan and check if that is desired state – c4f4t0r Jul 21 '20 at 14:40

0 Answers0