无法在VM上安装terraform扩展

问题描述 投票:0回答:1

我在使用terraform安装虚拟机扩展 - Azure VM上的VSTS代理时遇到问题。它报告错误如下:

1 error(s) occurred:
2019-05-01T13:11:47.4220106Z 
2019-05-01T13:11:47.4281029Z * azurerm_virtual_machine_extension.tf-vm-erx-bussvc-ext: 1 error(s) occurred:
2019-05-01T13:11:47.4285499Z * azurerm_virtual_machine_extension.tf-vm-erx-bussvc-ext: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter typeHandlerVersion is invalid." Target="typeHandlerVersion"
2019-05-01T13:11:47.4286000Z 

Terraform应用命令行参数如下:

usr/local/bin/terraform apply -var location=australiasoutheast -var interf_base_hostname=erxpreinterf -var mkconn_base_hostname=erxpremkconn -var bussvc_base_hostname=erxprebussvc -var sql_base_hostname=erxpresqldbs -var win_image_publisher=MicrosoftWindowsServer -var sql_image_publisher=MicrosoftSQLServer -var win_image_offer=WindowsServer -var sql_image_offer=SQL2014SP3-WS2012R2 -var win_2012_sku=2012-R2-Datacenter -var win_2016_sku=2016-Datacenter -var sql_sku=sqldev -var interf_vm_size=Standard_D2s_v3 -var mkconn_vm_size=Standard_D2s_v3 -var bussvc_vm_size=Standard_D2s_v3 -var sqldbs_vm_size=Standard_DS3_v2 -var interf_avset=erx-sha-pre-interf-avs-au-se -var mkconn_avset=erx-sha-pre-mkconn-avs-au-se -var bussvc_avset=erx-sha-pre-bussvc-avs-au-se -var sqldbs_avset=erx-sha-pre-sqldbs-avs-au-se -var application_nsg=erx-sha-pre-applic-nsg-au-se -var sql_nsg=erx-sha-pre-sqldbs-nsg-au-se -var username=scmadmin -var password=*** -var TF_LOG=DEBUG -var sqldbs_avset-02=erx-sha-pre-sqldbs-avs-au-se-02 -var builds_base_hostname=erxprebuilds -var builds_vm_size=Standard_B2ms -var linux_image_offer=CentOS -var linux_image_publisher=OpenLogic -var linux_sku=7.5 -var buildserver_nsg=erx-sha-pre-builds-nsg-au-se -var git_username=user.name%40companyname.com.au -var git_pat=n2kk5jmu77qxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5ff33xoc3q -var git_url=azure repo url -var extension_publisher=Microsoft.VisualStudio.Services -var extension_type=TeamServicesAgent -var extension_version=1.26.0.9 -auto-approve
data.azurerm_resource_group.tf-rg-erx-external

正确变量的名称是什么

type:                 "" => "TeamServicesAgent"
type_handler_version: "" => "1.26.0.9"
virtual_machine_name: "" => "erxprebussvc01"

我的azure虚拟机扩展代码如下:

resource "azurerm_virtual_machine_extension" "tf-vm-erx-bussvc-ext" {
  name                 = "${var.bussvc_base_hostname}${format("%02d",count.index+1)}-EXT"
  location             = "${data.azurerm_resource_group.tf-rg-erx-external.location}"
  resource_group_name  = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
  virtual_machine_name = "${var.bussvc_base_hostname}${format("%02d",count.index+1)}"
  publisher            = "${var.extension_publisher}"
  type                 = "${var.extension_type}"
  type_handler_version = "${var.extension_version}"

  settings = <<SETTINGS
    {
      "VstsAccountName":"https://companyname.visualstudio.com/",
      "TeamProject":"Fred",
      "DeploymentGroup": "eRx",
      "Tags": [
                "PreProdAzure","Role"
             ]

    }
SETTINGS
 protected_settings = <<PROTECTED_SETTINGS
    {
        "PATToken": "${var.git_pat}"
    }
PROTECTED_SETTINGS
}
azure-virtual-machine terraform-provider-azure
1个回答
0
投票

解决方法是将type_handler_version变量设置为“1.0”并添加:

autoUpgradeMinorVersion = true

在你的terraform代码中。我想,type_handler_version是无效的。

© www.soinside.com 2019 - 2024. All rights reserved.