Azure rendering solution deployment framework

This commit is contained in:
Rick Shahid 2023-09-28 07:52:14 -07:00
Родитель 9454ce2fc3
Коммит 0cf7490e3a
6 изменённых файлов: 170 добавлений и 145 удалений

Просмотреть файл

@ -40,16 +40,16 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
fileName = "initialize.sh"
parameters = {
activeDirectory = {
enable = false
domainName = ""
adminPassword = ""
}
autoScale = {
enable = false
fileName = "scale.sh"
@ -102,16 +102,16 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = true
domainName = "artist.studio"
adminPassword = ""
}
extension = {
initialize = {
enable = true
fileName = "initialize.ps1"
parameters = {
activeDirectory = {
enable = true
domainName = "artist.studio"
adminPassword = ""
}
autoScale = {
enable = false
fileName = "scale.ps1"

Просмотреть файл

@ -55,6 +55,13 @@ variable "virtualMachines" {
)
}
)
activeDirectory = object(
{
enable = bool
domainName = string
adminPassword = string
}
)
extension = object(
{
initialize = object(
@ -63,13 +70,6 @@ variable "virtualMachines" {
fileName = string
parameters = object(
{
activeDirectory = object(
{
enable = bool
domainName = string
adminPassword = string
}
)
autoScale = object(
{
enable = bool
@ -99,23 +99,22 @@ variable "virtualMachines" {
locals {
virtualMachines = [
for virtualMachine in var.virtualMachines : merge(
for virtualMachine in var.virtualMachines : merge(virtualMachine,
{
adminLogin = {
userName = virtualMachine.adminLogin.userName != "" ? virtualMachine.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userName = virtualMachine.adminLogin.userName != "" ? virtualMachine.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userPassword = virtualMachine.adminLogin.userPassword != "" ? virtualMachine.adminLogin.userPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
extension = {
initialize = {
parameters = {
activeDirectory = {
adminPassword = virtualMachine.extension.initialize.parameters.activeDirectory.adminPassword != "" ? virtualMachine.extension.initialize.parameters.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
sshPublicKey = virtualMachine.adminLogin.sshPublicKey
passwordAuth = {
disable = virtualMachine.adminLogin.passwordAuth.disable
}
}
},
virtualMachine
activeDirectory = {
enable = virtualMachine.activeDirectory.enable
domainName = virtualMachine.activeDirectory.domainName
adminPassword = virtualMachine.activeDirectory.adminPassword != "" ? virtualMachine.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
)
]
}
@ -197,7 +196,11 @@ resource "azurerm_virtual_machine_extension" "initialize_linux" {
virtual_machine_id = "${azurerm_resource_group.scheduler.id}/providers/Microsoft.Compute/virtualMachines/${each.value.name}"
settings = jsonencode({
script: "${base64encode(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {}))
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
))
)}"
})
depends_on = [
@ -271,7 +274,11 @@ resource "azurerm_virtual_machine_extension" "initialize_windows" {
virtual_machine_id = "${azurerm_resource_group.scheduler.id}/providers/Microsoft.Compute/virtualMachines/${each.value.name}"
settings = jsonencode({
commandToExecute = "PowerShell -ExecutionPolicy Unrestricted -EncodedCommand ${textencodebase64(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {})), "UTF-16LE"
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
)), "UTF-16LE"
)}"
})
depends_on = [

Просмотреть файл

@ -48,6 +48,14 @@ virtualMachineScaleSets = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -75,14 +83,6 @@ virtualMachineScaleSets = [
mount = "scheduler.artist.studio:/Deadline /DeadlineServer nfs defaults 0 0"
}
]
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
terminateNotification = { # https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-terminate-notification
enable = true
delayTimeout = "PT5M"
@ -143,6 +143,14 @@ virtualMachineScaleSets = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -170,14 +178,6 @@ virtualMachineScaleSets = [
mount = "scheduler.artist.studio:/Deadline /DeadlineServer nfs defaults 0 0"
}
]
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
terminateNotification = { # https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-terminate-notification
enable = true
delayTimeout = "PT5M"
@ -238,6 +238,14 @@ virtualMachineScaleSets = [
disable = false
}
}
activeDirectory = {
enable = true
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -265,14 +273,6 @@ virtualMachineScaleSets = [
mount = "mount -o anon \\\\scheduler.artist.studio\\Deadline S:"
}
]
activeDirectory = {
enable = true
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
terminateNotification = { # https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-terminate-notification
enable = true
delayTimeout = "PT5M"
@ -333,6 +333,14 @@ virtualMachineScaleSets = [
disable = false
}
}
activeDirectory = {
enable = true
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -360,14 +368,6 @@ virtualMachineScaleSets = [
mount = "mount -o anon \\\\scheduler.artist.studio\\Deadline S:"
}
]
activeDirectory = {
enable = true
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
terminateNotification = { # https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-terminate-notification
enable = true
delayTimeout = "PT5M"

Просмотреть файл

@ -67,6 +67,16 @@ variable "virtualMachineScaleSets" {
)
}
)
activeDirectory = object(
{
enable = bool
domainName = string
serverName = string
orgUnitPath = string
adminUsername = string
adminPassword = string
}
)
extension = object(
{
initialize = object(
@ -81,16 +91,6 @@ variable "virtualMachineScaleSets" {
mount = string
}
))
activeDirectory = object(
{
enable = bool
domainName = string
serverName = string
orgUnitPath = string
adminUsername = string
adminPassword = string
}
)
terminateNotification = object(
{
enable = bool
@ -122,24 +122,25 @@ variable "virtualMachineScaleSets" {
locals {
virtualMachineScaleSets = [
for virtualMachineScaleSet in var.virtualMachineScaleSets : merge(
for virtualMachineScaleSet in var.virtualMachineScaleSets : merge(virtualMachineScaleSet,
{
adminLogin = {
userName = virtualMachineScaleSet.adminLogin.userName != "" ? virtualMachineScaleSet.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userName = virtualMachineScaleSet.adminLogin.userName != "" ? virtualMachineScaleSet.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userPassword = virtualMachineScaleSet.adminLogin.userPassword != "" ? virtualMachineScaleSet.adminLogin.userPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
extension = {
initialize = {
parameters = {
activeDirectory = {
adminUsername = virtualMachineScaleSet.extension.initialize.parameters.activeDirectory.adminUsername != "" ? virtualMachineScaleSet.extension.initialize.parameters.activeDirectory.adminUsername : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
adminPassword = virtualMachineScaleSet.extension.initialize.parameters.activeDirectory.adminPassword != "" ? virtualMachineScaleSet.extension.initialize.parameters.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
sshPublicKey = virtualMachineScaleSet.adminLogin.sshPublicKey
passwordAuth = {
disable = virtualMachineScaleSet.adminLogin.passwordAuth.disable
}
}
},
virtualMachineScaleSet
activeDirectory = {
enable = virtualMachineScaleSet.activeDirectory.enable
domainName = virtualMachineScaleSet.activeDirectory.domainName
serverName = virtualMachineScaleSet.activeDirectory.serverName
orgUnitPath = virtualMachineScaleSet.activeDirectory.orgUnitPath
adminUsername = virtualMachineScaleSet.activeDirectory.adminUsername != "" ? virtualMachineScaleSet.activeDirectory.adminUsername : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
adminPassword = virtualMachineScaleSet.activeDirectory.adminPassword != "" ? virtualMachineScaleSet.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
)
]
}
@ -214,7 +215,11 @@ resource "azurerm_linux_virtual_machine_scale_set" "farm" {
auto_upgrade_minor_version = true
settings = jsonencode({
script: "${base64encode(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {}))
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
))
)}"
})
}
@ -314,7 +319,11 @@ resource "azurerm_windows_virtual_machine_scale_set" "farm" {
auto_upgrade_minor_version = true
settings = jsonencode({
commandToExecute = "PowerShell -ExecutionPolicy Unrestricted -EncodedCommand ${textencodebase64(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {})), "UTF-16LE"
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
)), "UTF-16LE"
)}"
})
}

Просмотреть файл

@ -39,6 +39,14 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -67,14 +75,6 @@ virtualMachines = [
}
]
pcoipLicenseKey = ""
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
}
}
monitor = {
@ -116,6 +116,14 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -144,14 +152,6 @@ virtualMachines = [
}
]
pcoipLicenseKey = ""
activeDirectory = {
enable = false
domainName = ""
serverName = ""
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
}
}
monitor = {
@ -193,6 +193,14 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -221,14 +229,6 @@ virtualMachines = [
}
]
pcoipLicenseKey = ""
activeDirectory = {
enable = false
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
}
}
monitor = {
@ -270,6 +270,14 @@ virtualMachines = [
disable = false
}
}
activeDirectory = {
enable = false
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
extension = {
initialize = {
enable = true
@ -298,14 +306,6 @@ virtualMachines = [
}
]
pcoipLicenseKey = ""
activeDirectory = {
enable = false
domainName = "artist.studio"
serverName = "WinScheduler"
orgUnitPath = ""
adminUsername = ""
adminPassword = ""
}
}
}
monitor = {

Просмотреть файл

@ -54,6 +54,16 @@ variable "virtualMachines" {
)
}
)
activeDirectory = object(
{
enable = bool
domainName = string
serverName = string
orgUnitPath = string
adminUsername = string
adminPassword = string
}
)
extension = object(
{
initialize = object(
@ -69,16 +79,6 @@ variable "virtualMachines" {
}
))
pcoipLicenseKey = string
activeDirectory = object(
{
enable = bool
domainName = string
serverName = string
orgUnitPath = string
adminUsername = string
adminPassword = string
}
)
}
)
}
@ -96,24 +96,25 @@ variable "virtualMachines" {
locals {
virtualMachines = [
for virtualMachine in var.virtualMachines : merge(
for virtualMachine in var.virtualMachines : merge(virtualMachine,
{
adminLogin = {
userName = virtualMachine.adminLogin.userName != "" ? virtualMachine.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userName = virtualMachine.adminLogin.userName != "" ? virtualMachine.adminLogin.userName : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
userPassword = virtualMachine.adminLogin.userPassword != "" ? virtualMachine.adminLogin.userPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
extension = {
initialize = {
parameters = {
activeDirectory = {
adminUsername = virtualMachine.extension.initialize.parameters.activeDirectory.adminUsername != "" ? virtualMachine.extension.initialize.parameters.activeDirectory.adminUsername : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
adminPassword = virtualMachine.extension.initialize.parameters.activeDirectory.adminUsername != "" ? virtualMachine.extension.initialize.parameters.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
sshPublicKey = virtualMachine.adminLogin.sshPublicKey
passwordAuth = {
disable = virtualMachine.adminLogin.passwordAuth.disable
}
}
},
virtualMachine
activeDirectory = {
enable = virtualMachine.activeDirectory.enable
domainName = virtualMachine.activeDirectory.domainName
serverName = virtualMachine.activeDirectory.serverName
orgUnitPath = virtualMachine.activeDirectory.orgUnitPath
adminUsername = virtualMachine.activeDirectory.adminUsername != "" ? virtualMachine.activeDirectory.adminUsername : try(data.azurerm_key_vault_secret.admin_username[0].value, "")
adminPassword = virtualMachine.activeDirectory.adminPassword != "" ? virtualMachine.activeDirectory.adminPassword : try(data.azurerm_key_vault_secret.admin_password[0].value, "")
}
}
)
]
}
@ -192,7 +193,11 @@ resource "azurerm_virtual_machine_extension" "initialize_linux" {
virtual_machine_id = "${azurerm_resource_group.workstation.id}/providers/Microsoft.Compute/virtualMachines/${each.value.name}"
settings = jsonencode({
script = "${base64encode(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {}))
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
))
)}"
})
depends_on = [
@ -264,7 +269,11 @@ resource "azurerm_virtual_machine_extension" "initialize_windows" {
virtual_machine_id = "${azurerm_resource_group.workstation.id}/providers/Microsoft.Compute/virtualMachines/${each.value.name}"
settings = jsonencode({
commandToExecute = "PowerShell -ExecutionPolicy Unrestricted -EncodedCommand ${textencodebase64(
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters, {})), "UTF-16LE"
templatefile(each.value.extension.initialize.fileName, merge(each.value.extension.initialize.parameters,
{
activeDirectory = each.value.activeDirectory
}
)), "UTF-16LE"
)}"
})
depends_on = [