-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtfext.tf
81 lines (65 loc) · 2.54 KB
/
tfext.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#Extension: add server to domain
resource "azurerm_virtual_machine_extension" "ADD2AD" {
name = "ADD2AD"
location = azurerm_resource_group.testvm.location
resource_group_name = azurerm_resource_group.testvm.name
virtual_machine_name = azurerm_virtual_machine.InfrastructureServer.name
publisher = "Microsoft.Compute"
type = "JsonADDomainExtension"
type_handler_version = "1.3"
# https://docs.microsoft.com/en-us/windows/desktop/api/lmjoin/nf-lmjoin-netjoindomain
settings = <<SETTINGS
{
"Name": "${var.DomainName}",
"User": "${var.DJoinUser}",
"Restart": "true",
"Options": "3"
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"Password": "${var.ARM_VAR_DJoinSecret}"
}
PROTECTED_SETTINGS
depends_on = [azurerm_virtual_machine.InfrastructureServer]
}
locals {
dsc_mode = "ApplyAndAutoCorrect"
}
#NOTE: Node data must already exist - otherwise the extension will fail with 'No NodeConfiguration was found for the agent.'
resource "azurerm_virtual_machine_extension" "dsc_extension" {
name = "Microsoft.Powershell.DSC"
location t = azurerm_resource_group.testvm.location
resource_group_name = azurerm_resource_group.testvm.name
virtual_machine_name = azurerm_virtual_machine.InfrastructureServer.name
publisher = "Microsoft.Powershell"
type = "DSC"
type_handler_version = "2.77"
auto_upgrade_minor_version = true
#use default extension properties as mentioned here:
#https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-template
settings = <<SETTINGS_JSON
{
"configurationArguments": {
"RegistrationUrl" : "${var.dscaa-server-endpoint}",
"NodeConfigurationName" : "DemoConfig.localhost",
"ConfigurationMode": "${local.dsc_mode}",
"RefreshFrequencyMins": 30,
"ConfigurationModeFrequencyMins": 15,
"RebootNodeIfNeeded": false,
"ActionAfterReboot": "continueConfiguration",
"AllowModuleOverwrite": true
}
}
SETTINGS_JSON
protected_settings = <<PROTECTED_SETTINGS_JSON
{
"configurationArguments": {
"RegistrationKey": {
"userName": "NOT_USED",
"Password": "${var.dscaa-access-key}"
}
}
}
PROTECTED_SETTINGS_JSON
}