【问题标题】:Issue with install DSC extension on Azure VM during deployment using Terraform使用 Terraform 部署期间在 Azure VM 上安装 DSC 扩展的问题
【发布时间】:2019-01-25 19:53:58
【问题描述】:

我正在尝试使用本文中的信息:

https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-template#default-configuration-script

在部署时将 VM 载入 Azure 自动化并应用配置。

我正在使用 Terraform 进行部署,下面是我用于扩展的代码:

resource "azurerm_virtual_machine_extension" "cse-dscconfig" {
  name                    = "${var.vm_name}-dscconfig-cse"
  location                = "${azurerm_resource_group.my_rg.location}"
  resource_group_name     = "${azurerm_resource_group.my_rg.name}"
  virtual_machine_name    = "${azurerm_virtual_machine.my_vm.name}"
  publisher               = "Microsoft.Powershell"
  type                    = "DSC"
  type_handler_version    = "2.76"
  depends_on              = ["azurerm_virtual_machine.my_vm"]

  settings = <<SETTINGS
        {
          "configurationArguments": {
              "RegistrationUrl": "${var.endpoint}",
              "NodeConfigurationName": "VMConfig"
          }
        }
        SETTINGS

  protected_settings = <<PROTECTED_SETTINGS
        {
                "configurationArguments": {
                  "registrationKey": {
                    "userName": "NOT_USED",
                    "Password": "${var.key}"
                  }
                }
        }
        PROTECTED_SETTINGS
}

我在执行时通过运行以下命令并将值传递给 Terraform 来获取 RegistrationURL 值:

$endpoint = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).Endpoint

通过运行以下命令并将值传递给 Terraform,我在执行时获得了 Password 值:

$key = (Get-AzureRmAutomationRegistrationInfo -ResourceGroupName $tf_state_rg -AutomationAccountName $autoAcctName).PrimaryKey

我可以从 VM 上的日志中得知扩展程序正在安装,但从未向自动化帐户注册。

【问题讨论】:

  • 我觉得你应该给它配置包url?
  • @4c74356b41 文档说:“指定节点尝试注册的自动化端点的 URL。”
  • 是的,可能。我从来没有见过这个default configuration script。当我使用 dsc 时,这不是一件事

标签: azure dsc terraform-provider-azure


【解决方案1】:

找出问题所在。文档在某些领域的细节很薄,所以我确实是通过反复试验发现导致问题的原因。我在NodeConfigurationName 属性中有错误的值。文档中关于此属性的内容:Specifies the node configuration in the Automation account to assign to the node. 对 DSC 没有太多经验,我打断了它以表示配置的名称,如 Azure 门户中自动化帐户的 State configuration (DSC) 刀片的 Configurations 部分所示.

NodeConfigurationName 属性真正指的是配置中的Node 定义,它应该是 ConfigurationName.NodeName 的格式。例如,我的配置名称是VMConfig,在配置源中我定义了一个名为localhostNode 块。所以,有了这个……NodeConfigurationName 属性的值应该是VMConfig.localhost

【讨论】:

    猜你喜欢
    • 2019-09-20
    • 2018-10-30
    • 1970-01-01
    • 2022-06-15
    • 2021-12-21
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多