-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathvm-extensions.tf
148 lines (123 loc) · 6.27 KB
/
vm-extensions.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
##########################################################
## Install IIS role on spoke-1
##########################################################
resource "azurerm_virtual_machine_extension" "install-iis-spoke-1-vm" {
name = "install-iis-spoke-1-vm"
virtual_machine_id = azurerm_windows_virtual_machine.spoke-1-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Add-WindowsFeature Web-Server; powershell -ExecutionPolicy Unrestricted Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"
}
SETTINGS
}
##########################################################
## Install IIS role on spoke-2
##########################################################
resource "azurerm_virtual_machine_extension" "install-iis-spoke-2-vm" {
name = "install-iis-spoke-2-vm"
virtual_machine_id = azurerm_windows_virtual_machine.spoke-2-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Add-WindowsFeature Web-Server; powershell -ExecutionPolicy Unrestricted Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"
}
SETTINGS
}
##########################################################
## Install IIS role on spoke-3
##########################################################
resource "azurerm_virtual_machine_extension" "install-iis-spoke-3-vm" {
name = "install-iis-spoke-3-vm"
virtual_machine_id = azurerm_windows_virtual_machine.spoke-3-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Add-WindowsFeature Web-Server; powershell -ExecutionPolicy Unrestricted Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"
}
SETTINGS
}
##########################################################
## Install IIS role on spoke-4
##########################################################
resource "azurerm_virtual_machine_extension" "install-iis-spoke-4-vm" {
name = "install-iis-spoke-4-vm"
virtual_machine_id = azurerm_windows_virtual_machine.spoke-4-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Add-WindowsFeature Web-Server; powershell -ExecutionPolicy Unrestricted Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"
}
SETTINGS
}
##########################################################
## Install IIS role on onprem
##########################################################
resource "azurerm_virtual_machine_extension" "install-iis-onprem-vm" {
name = "install-iis-spoke-onprem-vm"
virtual_machine_id = azurerm_windows_virtual_machine.onprem-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Add-WindowsFeature Web-Server; powershell -ExecutionPolicy Unrestricted Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"
}
SETTINGS
}
##########################################################
## Install ADDC role on spoke-addc-vm
##########################################################
resource "azurerm_virtual_machine_extension" "install-spoke-addc-vm" {
name = "install-spoke-addc-vm"
virtual_machine_id = azurerm_windows_virtual_machine.spoke-addc-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted -File addc.ps1",
"fileUris":["https://gist.githubusercontent.com/mddazure/fc3db37583cbfc80852f68a6b38bdc35/raw/d07b82133582199d2032b4d153bc3c696f88644f/addc.ps1"]
}
SETTINGS
}
##########################################################
## Enable routing on nva-iptables-vm
##########################################################
resource "azurerm_virtual_machine_extension" "enable-routing-nva-iptables-vm" {
name = "enable-routing-nva-iptables-vm"
virtual_machine_id = azurerm_linux_virtual_machine.nva-iptables-vm.id
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.1"
settings = <<SETTINGS
{
"script": "c3VkbyBjaG1vZCA3NzcgL2V0Yy9zeXNjdGwuY29uZgplY2hvICJuZXQuaXB2NC5pcF9mb3J3YXJkID0gMSIgPiAvZXRjL3N5c2N0bC5jb25mCnN1ZG8gc3lzY3RsIC1wIC9ldGMvc3lzY3RsLmNvbmYKc3VkbyBpcHRhYmxlcyAtdCBuYXQgLUEgUE9TVFJPVVRJTkcgLWQgMTAuMC4wLjAvOCAtaiBBQ0NFUFQKc3VkbyBpcHRhYmxlcyAtdCBuYXQgLUEgUE9TVFJPVVRJTkcgLWQgMTcyLjE2LjAuMC8xMiAtaiBBQ0NFUFQKc3VkbyBpcHRhYmxlcyAtdCBuYXQgLUEgUE9TVFJPVVRJTkcgLWQgMTkyLjE2OC4wLjAvMTYgLWogQUNDRVBUCnN1ZG8gaXB0YWJsZXMgLXQgbmF0IC1BIFBPU1RST1VUSU5HIC1vIGV0aDAgLWogTUFTUVVFUkFERQ=="
}
SETTINGS
}
/*
##########################################################
## Install ADDC role on spoke-addc-vm
##########################################################
resource "azurerm_virtual_machine_extension" "install-spoke-addc-vm" {
name = "install-spoke-addc-vm"
virtual_machine_id = azurerm_virtual_machine.spoke-addc-vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"commandToExecute":"powershell -ExecutionPolicy Unrestricted Install-WindowsFeature -Name AD-Domain-Services; powershell -ExecutionPolicy Unrestricted Install-ADDSForest -DomainName micro-hack.local -SafeModeAdministratorPassword (ConvertTo-SecureString -String \"microhack-12345%\" -AsPlainText -Force) -Force -SkipPreChecks"
}
SETTINGS
}
*/