Created
January 21, 2018 17:28
-
-
Save divgo/01d5e008251f04e101bfb761de8de533 to your computer and use it in GitHub Desktop.
Revisions
-
divgo created this gist
Jan 21, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ variable "dsc_key" { default = "your_azure_automation_key" } variable "dsc_endpoint" { default= "your_azure_automation_endpoint_url" } variable "storage_account_key" { default = "your_storage_account_key_where_scripts_saved" } variable dsc_config { default = "" } 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 { "ModulesUrl":"", "SasToken":"", "WmfVersion": "latest", "Privacy": { "DataCollection": "" }, "ConfigurationFunction":"" } SETTINGS } resource "azurerm_virtual_machine_extension" "register_for_dsc" { name = "register_for_dsc" location = "${var.location}" resource_group_name = "${var.resource_group_name}" virtual_machine_name = "${var.vm_name}" publisher = "Microsoft.Compute" type = "CustomScriptExtension" type_handler_version = "1.8" depends_on = ["azurerm_virtual_machine_extension.dsc"] settings = <<SETTINGS { "fileUris": [ "https://your_storage_account.blob.core.windows.net/scripts/DscMetaConfigs.ps1", "https://your_storage_account.blob.core.windows.net/scripts/Execute_DscScripts.ps1" ] } SETTINGS protected_settings = <<PROTECTED_SETTINGS { "commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ./Execute_DscScripts.ps1 ${var.dsc_key} ${var.dsc_endpoint} ${var.dsc_config}", "storageAccountName": "your_storage_account", "storageAccountKey": "${var.storage_account_key}" } PROTECTED_SETTINGS }