Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save geekzter/7399a3ec12e9f4a39dc4608b74d107d4 to your computer and use it in GitHub Desktop.
Save geekzter/7399a3ec12e9f4a39dc4608b74d107d4 to your computer and use it in GitHub Desktop.
Azure VM scale set cloudinit race condition fix
resource azurerm_virtual_machine_scale_set_extension cloud_config_status {
name = "CloudConfigStatusScript"
virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.linux_agents.id
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
settings = jsonencode({
"commandToExecute" = "/usr/bin/cloud-init status --long --wait ; systemctl status cloud-final.service --full --no-pager --wait"
})
}
resource azurerm_virtual_machine_scale_set_extension linux_log_analytics {
name = "OmsAgentForLinux"
virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.linux_agents.id
publisher = "Microsoft.EnterpriseCloud.Monitoring"
type = "OmsAgentForLinux"
type_handler_version = "1.7"
auto_upgrade_minor_version = true
settings = jsonencode({
"workspaceId" = data.azurerm_log_analytics_workspace.monitor.workspace_id
})
protected_settings = jsonencode({
"workspaceKey" = data.azurerm_log_analytics_workspace.monitor.primary_shared_key
})
provision_after_extensions = [
# Wait for cloud-init to complete before provisioning extensions
azurerm_virtual_machine_scale_set_extension.cloud_config_status.name
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment