# import the Azure credentials from the environment (export them before building the image) variable "azure_client_id" { default = env("AZURE_CLIENT_ID") } variable "azure_subscription_id" { default = env("AZURE_SUBSCRIPTION_ID") } variable "azure_secret" { default = env("AZURE_SECRET") } # tell packer to use the Azure plugin packer { required_plugins { azure = { version = ">= 1.0.0" source = "github.com/hashicorp/azure" } } } source "azure-arm" "node_exporter_image" { client_id = "${var.azure_client_id}" subscription_id = "${var.azure_subscription_id}" client_secret = "${var.azure_secret}" # the image has to go into the same resource group as the scale set managed_image_resource_group_name = "tnglab" managed_image_name = "node_exporter_test" os_type = "Linux" image_publisher = "Canonical" image_offer = "0001-com-ubuntu-server-jammy" image_sku = "22_04-lts-gen2" # adjust location to your needs location = "West Europe" # sufficient for building the image vm_size = "Standard_B2s" } # build the image build { name = "xmrig-build" sources = [ "source.azure-arm.node_exporter_image" ] provisioner "shell" { environment_vars = [ ] inline = [ # the Ubuntu cloud image does some magic on boot. Wait for that to finish "cloud-init status --wait" # first, update the package index "sudo apt update", # now install the node_exporter "sudo apt install -y prometheus-node-exporter", ] } }