Background
I am trying to use Azure Automation to configure some Azure Windows VMs as DNS servers.
I would like to use Terraform to configure the Automation Account, DSC Configuration and DSC Node Configuration, but I'm stuck on the DSC Node Configuration.
I have the following, which works, but only if I manually compile it by clicking in the Portal:
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
}
I want to automate the compilation, so I tried:
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?"
}
Problem
I don't have a strong background with this, so am not sure I have understood it properly. I don't know what content_embedded
for the nodeconfiguration
is supposed to contain.
Should I remove the Node
block from the dsc_configuration
and move it into the dsc_nodeconfiguration
? Or perhaps the contents of the node block (i.e. excluding the Node 'localhost' {}
wrapper)?
(I am not really sure if "localhost" is even a good name for what the node represents).
For example, something like:
resource "azurerm_automation_dsc_nodeconfiguration" "node" {
content_embedded = "Node 'localhost' { WindowsFeature DNS {...} }"
...
}
or
resource "azurerm_automation_dsc_nodeconfiguration" "node" {
content_embedded = "WindowsFeature DNS {...}"`
...
}
or something else?
I feel like I have tried a few of these options but the feedback loop is pretty slow so it's possible I hit the right answer and got tripped up by another mistake whilst I was debugging!
Does anyone have a working example please or can perhaps explain how it works?