【问题标题】:Azure Automation in Terraform DSC Configuration vs Node ConfigurationTerraform DSC 配置与节点配置中的 Azure 自动化
【发布时间】:2020-12-07 11:46:09
【问题描述】:

背景

我正在尝试使用 Azure 自动化将一些 Azure Windows VM 配置为 DNS 服务器。

我想使用 Terraform 来配置自动化帐户、DSC 配置和 DSC 节点配置,但我卡在 DSC 节点配置上。

我有以下工作,但前提是我通过单击门户手动编译它:

resource "azurerm_automation_dsc_configuration" "configuration" {
    name                    = "DNSConfig"
    resource_group_name     = "my_rg"
    location                = "uksouth"
    automation_account_name = "my_aa_account"
    content_embedded = <<-CONTENT
        Configuration DNSConfig
        {
            Node 'localhost'
            {
                WindowsFeature DNS
                {
                    Ensure = 'Present'
                    Name   = 'DNS'
                }

                # plus some more stuff

            }
        }

    CONTENT
}

我想自动化编译,所以我尝试了:

resource "azurerm_automation_dsc_nodeconfiguration" "node" {
    automation_account_name = "my_aa_account"
    resource_group_name     = "my_rg"
    name                    = "DNSConfig.localhost"
    content_embedded        = "# what goes here?"
}

问题

我没有很强的背景知识,所以不确定我是否正确理解了它。我不知道content_embeddednodeconfiguration 应该包含什么。

我应该从dsc_configuration 中删除Node 块并将其移动到dsc_nodeconfiguration 中吗?或者可能是节点块的 contents(即不包括 Node 'localhost' {} 包装器)?

(我不确定“localhost”是否是节点所代表的好名称)。

例如:

resource "azurerm_automation_dsc_nodeconfiguration" "node" {
    content_embedded = "Node 'localhost' { WindowsFeature DNS {...} }"
    ...
}

resource "azurerm_automation_dsc_nodeconfiguration" "node" {
    content_embedded = "WindowsFeature DNS {...}"`
    ...
}

还是别的什么?

我觉得我已经尝试了其中的一些选项,但反馈循环很慢,所以我有可能在调试时找到了正确的答案并被另一个错误绊倒了!

有没有人有一个可行的例子,或者可以解释它是如何工作的?

【问题讨论】:

标签: azure terraform dsc


【解决方案1】:

content_embedded 内你应该包含MOF 文件的内容,参见an example 来自azurerm_automation_dsc_nodeconfiguration 文档。
或者您可以使用 terraform file function 加载 MOF 内容并将其用于您的脚本。请记住以 Unicode 或 UTF-8 格式对 MOF 内容进行编码。

【讨论】:

    猜你喜欢
    • 2021-05-30
    • 2017-09-16
    • 1970-01-01
    • 2020-09-01
    • 2018-11-06
    • 1970-01-01
    • 2017-12-25
    • 2018-11-06
    • 2022-08-05
    相关资源
    最近更新 更多