0
votes

I have used the new terraform module for Linux vmss to include monitoring agents as a custom extension, however, the instance doesn't have the "Latest model" when everything is done and manually restart vmss to get a newer model that works but I don't want manual intervention. The previous module doesn't need to manually re-image to get the newest one. did I miss anything?

the code the extension is

 "azurerm_virtual_machine_scale_set_extension" "oms" {
 name                         = "OmsAgentForLinux"
 depends_on                   = [azurerm_linux_virtual_machine_scale_set.vmss]
 virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.vmss.id
 publisher                    = "Microsoft.EnterpriseCloud.Monitoring"
 type                         = "OmsAgentForLinux"
 type_handler_version         = "1.11"
  settings = <<-BASE_SETTINGS
 {
  "workspaceId" : "xxxx"
 }
 BASE_SETTINGS

 protected_settings = <<-PROTECTED_SETTINGS
 {
 "workspaceKey" : "xxxxx"
  }
 PROTECTED_SETTINGS
 }

Module for creating azure vmss

  resource "azurerm_linux_virtual_machine_scale_set" "example" {
  name                = "example-vmss"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  sku                 = "Standard_F2"
  instances           = 1
  admin_username      = "administer"

 admin_ssh_key {
 username   = "administer"
 public_key = file("~/.ssh/id_rsa.pub")
  }

 source_image_reference {
 publisher = "Canonical"
 offer     = "UbuntuServer"
 version   = "latest"
  }

 os_disk {
  storage_account_type = "Standard_LRS"
 caching              = "ReadWrite"
  }

  network_interface {
  name    = "example"
  primary = true

    ip_configuration {
    name      = "internal"
    primary   = true
    subnet_id = azurerm_subnet.internal.id
     }
     }
    }

the old module does not specify OS

 "azurerm_virtual_machine" "demovm"
1

1 Answers

0
votes

It's expected behavior as by default the upgrade policy is set to manual. In this mode, when you update the scale set model, nothing happens to existing VMs.

From how to add an extension to all VMs in my virtual machine scale set,

If update policy is set to automatic, redeploying the template with the new extension properties updates all VMs.

If update policy is set to manual, first update the extension, and then manually update all instances in your VMs.

In this case, if you don't want manual intervention, you may try to use automatic upgrade policy.

References: