-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_provision-domain.tf.disable
28 lines (26 loc) · 1.53 KB
/
6_provision-domain.tf.disable
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
// the `exit_code_hack` is to keep the VM Extension resource happy
locals {
// import_command = "Import-Module ADDSDeployment"
password_command = "$password = ConvertTo-SecureString ${var.admin_password} -AsPlainText -Force"
install_ad_command = "Add-WindowsFeature -name ad-domain-services -IncludeManagementTools"
configure_ad_command = "Install-ADDSForest -CreateDnsDelegation:$false -DomainMode 7 -DomainName ${var.active_directory_domain} -DomainNetbiosName ${var.active_directory_netbios_name} -ForestMode 7 -InstallDns:$true -SafeModeAdministratorPassword $password -Force:$true"
shutdown_command = "shutdown -r -t 20"
exit_code_hack = "exit 0"
powershell_command = "${local.password_command}; ${local.install_ad_command}; ${local.configure_ad_command}; ${local.shutdown_command}; ${local.exit_code_hack}"
}
// NOTE: This is Extension for first DomainController
resource "azurerm_virtual_machine_extension" "create-active-directory-forest" {
name = "create-active-directory-forest"
location = "${azurerm_virtual_machine.domain-controler1.location}"
resource_group_name = "${var.RG_Compute}"
virtual_machine_name = "${var.dc1}"
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
depends_on = ["azurerm_virtual_machine.domain-controler1"]
settings = <<SETTINGS
{
"commandToExecute": "powershell.exe -Command \"${local.powershell_command}\""
}
SETTINGS
}