Created
January 25, 2018 17:01
-
-
Save divgo/b0a35c9b3a2e995905c2fb045079a304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "dsc_key" { | |
default = "dsc_registration_key_from_portal" | |
} | |
variable "dsc_endpoint" { | |
default = "dsc_registration_url_from_portal" | |
} | |
variable dsc_config { | |
default = "node_configuration_you_want_applied__can_leave_blank" | |
} | |
variable dsc_mode { | |
default = "applyAndMonitor" | |
} | |
resource "azurerm_virtual_machine_extension" "dsc" { | |
name = "DevOpsDSC" | |
location = "${var.location}" | |
resource_group_name = "${var.resource_group_name}" | |
virtual_machine_name = "${var.vm_name}" | |
publisher = "Microsoft.Powershell" | |
type = "DSC" | |
type_handler_version = "2.73" | |
depends_on = ["azurerm_virtual_machine.virtual_machine"] | |
settings = <<SETTINGS | |
{ | |
"WmfVersion": "latest", | |
"ModulesUrl": "https://eus2oaasibizamarketprod1.blob.core.windows.net/automationdscpreview/RegistrationMetaConfigV2.zip", | |
"ConfigurationFunction": "RegistrationMetaConfigV2.ps1\\RegistrationMetaConfigV2", | |
"Privacy": { | |
"DataCollection": "" | |
}, | |
"Properties": { | |
"RegistrationKey": { | |
"UserName": "PLACEHOLDER_DONOTUSE", | |
"Password": "PrivateSettingsRef:registrationKeyPrivate" | |
}, | |
"RegistrationUrl": "${var.dsc_endpoint}", | |
"NodeConfigurationName": "${var.dsc_config}", | |
"ConfigurationMode": "${var.dsc_mode}", | |
"ConfigurationModeFrequencyMins": 15, | |
"RefreshFrequencyMins": 30, | |
"RebootNodeIfNeeded": false, | |
"ActionAfterReboot": "continueConfiguration", | |
"AllowModuleOverwrite": false | |
} | |
} | |
SETTINGS | |
protected_settings = <<PROTECTED_SETTINGS | |
{ | |
"Items": { | |
"registrationKeyPrivate" : "${var.dsc_key}" | |
} | |
} | |
PROTECTED_SETTINGS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The one thing i would like to add is the following:
depends_on = ["azurerm_virtual_machine.virtual_machine"] is only if you are creating a VM at the same time of adding the extension,
type_handler_version = "2.77" is the latest DSC --ver
and in the variable dsc_config { } it is better to specify a config name cos it defies the purpose