Skip to content

Commit

Permalink
azure: known issue data disk with terraform (#296)
Browse files Browse the repository at this point in the history
* azure: known issue data disk with terraform

Documenting the problem with terraform's linux virtual machine and data disks

* Update azure.md
  • Loading branch information
TimoKramer authored Mar 21, 2024
1 parent 977c2cd commit a9b1823
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions content/docs/latest/installing/cloud/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,59 @@ When you make a change to `cl/machine-mynode.yaml.tmpl` and run `terraform apply

You can find this Terraform module in the repository for [Flatcar Terraform examples](https://github.com/flatcar/flatcar-terraform/tree/main/azure).

### Known issues

With Terraform version 3.x it [is currently not possible to partition and format data disks](https://github.com/hashicorp/terraform-provider-azurerm/issues/6117)
for a `azurerm_linux_virtual_machine` with ignition's storage configuration. It might be possible to use the deprecated `azurerm_virtual_machine` module.
Another workaround is to use a systemd unit to run a script that does partitioning and formatting for you. Here is an example on how to create a
single partition with an ext4 filesystem:
```
systemd:
units:
- name: partition-drive.service
enabled: true
contents: |
[Unit]
Description="Partition drive"
Before=docker.service
ConditionFirstBoot=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/bin/partition-drive.sh
[Install]
WantedBy=first-boot-complete.target
storage:
files:
- path: /opt/bin/partition-drive.sh
mode: 0700
contents:
inline: |
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
disk_device="/dev/disk/azure/scsi1/lun10"
partition="/dev/disk/azure/scsi1/lun10-part1"
until [[ -e $disk_device ]]; do echo "Waiting for device" && sleep 1; done
if [[ -n $(lsblk -no NAME $disk_device | sed -n '2,$p') ]]; then
echo "Disk $disk_device is partitioned."
else
echo 'type=83' | sfdisk /dev/disk/azure/scsi1/lun10
fi
sleep 3
if [[ -n $(lsblk -no FSTYPE $partition) ]]; then
echo "Partition $partition already formatted."
else
mkfs.ext4 -F /dev/disk/azure/scsi1/lun10-part1
fi
```

[flatcar-user]: https://groups.google.com/forum/#!forum/flatcar-linux-user
[etcd-docs]: https://etcd.io/docs
[quickstart]: ../
Expand Down

0 comments on commit a9b1823

Please sign in to comment.