Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure: known issue data disk with terraform #296

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading