I'm provisioning a VM on Azure using this terraform code:
resource "azurerm_linux_virtual_machine" "vm" {
name = "vm"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
network_interface_ids = [azurerm_network_interface.nic.id]
size = "Standard_NV6ads_A10_v5"
admin_username = "ubuntu"
admin_password = "xxxx"
disable_password_authentication = false
custom_data = base64encode(templatefile("custom-data.tpl", {
account_name = azurerm_storage_account.storage_account.name
container_name = azurerm_storage_container.blob_container.name
storage_account_key = azurerm_storage_account.storage_account.primary_access_key
user_name = "ubuntu"
}))
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
disk_size_gb = 50
}
source_image_reference {
publisher = "Canonical"
offer = "ubuntu-24_04-lts"
sku = "server"
version = "latest"
}
identity {
type = "SystemAssigned"
}
}
The custom-data.tpl
script contains only the code to install xrdp:
#!/bin/bash
sudo wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update -y
sudo apt-get install -y ubuntu-desktop xrdp
systemctl enable xrdp
systemctl start xrdp
The thing is, after I log in via rdp I pull code from my git repository and install nvidia drivers. Sometimes after I reboot there's no repo in my home catalog and the drivers are also nowhere to be found. Aren't drives attached to VMs supposed to be persistent? Or maybe I'm doing something wrong?