Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15f6c5b126 | ||
|
|
4605c4f8be | ||
|
|
c62cb51c2d | ||
|
|
339530f952 | ||
|
|
30c9966d1c | ||
|
|
a24792c279 | ||
|
|
60eaba761e | ||
|
|
538feb10eb | ||
|
|
589c0bc7bb | ||
|
|
b1d0cad7f1 | ||
|
|
4dd7e6a02c | ||
|
|
00c3385aa0 | ||
|
|
6a8f980d05 | ||
|
|
0ed37bbfdc | ||
|
|
38a17a38df | ||
|
|
5a47d57d92 | ||
|
|
73cbeca7c1 | ||
|
|
01c8bfdcee | ||
|
|
15c03dfd4c | ||
|
|
0c7985c188 | ||
|
|
f99af254dd | ||
|
|
05acfb8673 | ||
|
|
19f8da742d | ||
|
|
0df688e641 | ||
|
|
a86a328b88 | ||
|
|
1387c15194 | ||
|
|
2125c15b4e | ||
|
|
7d35ce588e | ||
|
|
40843fd65c | ||
|
|
3042b873e1 | ||
|
|
d2eb231002 | ||
|
|
1902175e0b | ||
|
|
750ed46bc1 | ||
|
|
f18d5129e7 | ||
|
|
d410e5a24f | ||
|
|
8864aa4b79 | ||
|
|
c74fa8f2bd |
@@ -5,9 +5,9 @@ resource "azurerm_monitor_diagnostic_setting" "example" {
|
||||
|
||||
log_analytics_workspace_id = var.log_analytics_workspace_id
|
||||
|
||||
log {
|
||||
enabled_log {
|
||||
category = "ApplicationGatewayAccessLog"
|
||||
enabled = true
|
||||
enabled= true
|
||||
|
||||
retention_policy {
|
||||
enabled = true
|
||||
@@ -15,7 +15,7 @@ resource "azurerm_monitor_diagnostic_setting" "example" {
|
||||
}
|
||||
}
|
||||
|
||||
log {
|
||||
enabled_log {
|
||||
category = "ApplicationGatewayFirewallLog"
|
||||
enabled = true
|
||||
|
||||
|
||||
@@ -15,12 +15,15 @@ locals {
|
||||
aurora = (var.engine == "aurora-mysql") ? true : (var.engine == "aurora-postgresql") ? true : false
|
||||
vpc_id = (var.region == "eu-west-1") ? var.vpc_id_eu : (var.region == "us-east-1") ? var.vpc_id_us : var.vpc_id_ap
|
||||
subnet_ids = (var.region == "eu-west-1") ? var.subnet_ids_eu : (var.region == "us-east-1") ? var.subnet_ids_us : var.subnet_ids_ap
|
||||
port = (var.engine == "oracle-se2") ? "1521" : (var.engine == "postgres") ? "5432" : (var.engine == "aurora-postgresql") ? "5432" : (var.engine == "sqlserver-ex") ? "1433" : "3306"
|
||||
|
||||
name = (var.engine == "sqlserver-ex") ? null : (var.engine == "oracle-se2") ? "ora${local.provid5}" : "qmi${var.provision_id}"
|
||||
license = (local.aurora == true) ? "general-public-license" : (var.engine == "mariadb") ? "general-public-license" : (var.engine == "postgres") ? "postgresql-license" : (var.engine == "mysql") ? "general-public-license" : "license-included"
|
||||
engine_version = (var.engine == "oracle-se2") ? "19.0.0.0.ru-2021-04.rur-2021-04.r1" : (var.engine == "postgres") ? "13.3" : (var.engine == "mysql") ? "8.0.25" : (var.engine == "aurora-postgresql") ? "14.5" : (var.engine == "aurora-mysql") ? "5.7.mysql_aurora.2.10.0" : (var.engine == "sqlserver-ex") ? "15.00.4073.23.v1" : "10.5" #mariaDB
|
||||
major_engine_version = (var.engine == "oracle-se2") ? "19" : (var.engine == "postgres") ? "13" : (var.engine == "mysql") ? "8.0" : (var.engine == "aurora-postgresql") ? "12" : (var.engine == "aurora-mysql") ? "5.7" : (var.engine == "sqlserver-ex") ? "15.00" : "10.5" #mariaDB
|
||||
family = (var.engine == "oracle-se2") ? "oracle-se2-19" : (var.engine == "postgres") ? "postgres13" : (var.engine == "mysql") ? "mysql8.0" : (var.engine == "aurora-postgresql") ? "aurora-postgresql12" : (var.engine == "aurora-mysql") ? "aurora-mysql5.7" : (var.engine == "sqlserver-ex") ? "sqlserver-ex-15.0" : "mariadb10.5" #mariaDB
|
||||
|
||||
port = var.port[var.engine]
|
||||
engine_version = var.engine_version[var.engine]
|
||||
major_engine_version = var.major_engine_version[var.engine]
|
||||
family = var.family[var.engine]
|
||||
|
||||
tags = {
|
||||
Deployment = "QMI PoC"
|
||||
"Cost Center" = "3100"
|
||||
|
||||
@@ -38,21 +38,6 @@ variable "engine" {
|
||||
description = "Accepted values are mysql, sqlserver-ex, postgres, oracle-se2, aurora-mysql, aurora-postgresql, mariadb"
|
||||
}
|
||||
|
||||
variable "engine_version" {
|
||||
default = "8.0.25"
|
||||
description = "Not currently used"
|
||||
}
|
||||
|
||||
variable "major_eng" {
|
||||
default = "8.0"
|
||||
description = "Not currently used"
|
||||
}
|
||||
|
||||
variable "family" {
|
||||
default = "mysql8.0"
|
||||
description = "Not currently used"
|
||||
}
|
||||
|
||||
variable "instance_size" {
|
||||
default = "db.t3.large"
|
||||
}
|
||||
@@ -60,3 +45,64 @@ variable "instance_size" {
|
||||
variable "storage" {
|
||||
default = "20"
|
||||
}
|
||||
|
||||
variable "engine_version" {
|
||||
type = map
|
||||
|
||||
default = {
|
||||
"mysql" = "8.0.32"
|
||||
"postgres" = "13.3"
|
||||
"oracle-se2" = "19.0.0.0.ru-2023-04.rur-2023-04.r1"
|
||||
"sqlserver-ex" = "15.00.4236.7.v1"
|
||||
"mariadb" = "10.5"
|
||||
"aurora-mysql" = "8.0.mysql_aurora.3.02.3" #"5.7.mysql_aurora.2.11.2"
|
||||
"aurora-postgresql" = "14.5"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
variable "major_engine_version" {
|
||||
type = map
|
||||
|
||||
default = {
|
||||
"mysql" = "8.0"
|
||||
"postgres" = "13"
|
||||
"oracle-se2" = "19"
|
||||
"sqlserver-ex" = "15.00"
|
||||
"mariadb" = "10.5"
|
||||
# for script compatibility only
|
||||
"aurora-mysql" = "not_used"
|
||||
"aurora-postgresql" = "not_used"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
variable "family" {
|
||||
type = map
|
||||
|
||||
default = {
|
||||
"mysql" = "mysql8.0"
|
||||
"postgres" = "postgres13"
|
||||
"oracle-se2" = "oracle-se2-19"
|
||||
"sqlserver-ex" = "sqlserver-ex-15.0"
|
||||
"mariadb" = "mariadb10.5"
|
||||
# for script compatibility only
|
||||
"aurora-mysql" = "not_used"
|
||||
"aurora-postgresql" = "not_used"
|
||||
}
|
||||
}
|
||||
|
||||
variable "port" {
|
||||
type = map
|
||||
|
||||
default = {
|
||||
"mysql" = "3306"
|
||||
"postgres" = "5432"
|
||||
"oracle-se2" = "1521"
|
||||
"sqlserver-ex" = "1433"
|
||||
"mariadb" = "3306"
|
||||
"aurora-mysql" = "3306"
|
||||
"aurora-postgresql" = "5432"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,13 +95,17 @@ resource "databricks_group_member" "i-am-admin-aor" {
|
||||
|
||||
resource "databricks_secret_scope" "scopeapp" {
|
||||
|
||||
count = (var.sku == "premium")? 1 : 0
|
||||
|
||||
name = "${var.cluster_name}scope"
|
||||
}
|
||||
resource "databricks_secret" "publishing_api" {
|
||||
|
||||
count = (var.sku == "premium")? 1 : 0
|
||||
|
||||
key = "accesskey"
|
||||
string_value = var.app_reg_secret
|
||||
scope = databricks_secret_scope.scopeapp.name
|
||||
scope = databricks_secret_scope.scopeapp[0].name
|
||||
}
|
||||
|
||||
resource "databricks_sql_endpoint" "sqlep" {
|
||||
@@ -116,6 +120,8 @@ resource "databricks_sql_endpoint" "sqlep" {
|
||||
|
||||
resource "databricks_sql_global_config" "this" {
|
||||
|
||||
count = (var.sku == "premium")? 1 : 0
|
||||
|
||||
security_policy = "DATA_ACCESS_CONTROL"
|
||||
data_access_config = {
|
||||
"spark.hadoop.fs.azure.account.auth.type.${var.storage_account_name}.dfs.core.windows.net" : "OAuth",
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
address_prefix = "10.0.2.0/24"
|
||||
}*/
|
||||
|
||||
resource "azurerm_public_ip" "publicip" {
|
||||
/*resource "azurerm_public_ip" "publicip" {
|
||||
|
||||
count = var.isExternal? 1 : 0
|
||||
|
||||
@@ -80,7 +80,7 @@ resource "azurerm_public_ip" "publicip" {
|
||||
location = var.location
|
||||
allocation_method = "Dynamic"
|
||||
domain_name_label = lower(var.prefix)
|
||||
}
|
||||
}*/
|
||||
|
||||
resource "azurerm_network_interface" "nic" {
|
||||
name = "${var.prefix}-nic"
|
||||
@@ -92,7 +92,6 @@ resource "azurerm_network_interface" "nic" {
|
||||
name = "${var.prefix}-ip-cfg"
|
||||
subnet_id = var.subnet_id
|
||||
private_ip_address_allocation = "Dynamic"
|
||||
public_ip_address_id = var.isExternal? azurerm_public_ip.publicip[0].id : null
|
||||
}
|
||||
|
||||
tags = {
|
||||
|
||||
@@ -8,12 +8,4 @@ output "private_ip_address" {
|
||||
|
||||
output "ip_configuration_name" {
|
||||
value = "${var.prefix}-ip-cfg"
|
||||
}
|
||||
|
||||
output "public_ip_address" {
|
||||
value = var.isExternal? azurerm_public_ip.publicip[0].ip_address : null
|
||||
}
|
||||
|
||||
output "fqdn" {
|
||||
value = var.isExternal? azurerm_public_ip.publicip[0].fqdn : null
|
||||
}
|
||||
@@ -24,12 +24,4 @@ output "nic_private_ip_address" {
|
||||
|
||||
output "nic_ip_configuration_name" {
|
||||
value = module.qmi-nic.ip_configuration_name
|
||||
}
|
||||
|
||||
output "nic_fqdn" {
|
||||
value = var.isExternal? module.qmi-nic.fqdn : null
|
||||
}
|
||||
|
||||
output "nic_public_ip_address" {
|
||||
value = var.isExternal? module.qmi-nic.public_ip_address : null
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
resource "random_id" "randomMachineId" {
|
||||
keepers = {
|
||||
# Generate a new ID only when a new resource group is defined
|
||||
resource_group = var.resource_group_name
|
||||
}
|
||||
|
||||
byte_length = 3
|
||||
}
|
||||
|
||||
resource "random_password" "password" {
|
||||
length = 16
|
||||
special = false
|
||||
override_special = "_"
|
||||
upper = true
|
||||
lower = true
|
||||
min_lower = 2
|
||||
min_upper = 2
|
||||
min_special = 0
|
||||
min_numeric = 2
|
||||
}
|
||||
|
||||
locals {
|
||||
virtual_machine_name = "${var.prefix}-${random_id.randomMachineId.hex}"
|
||||
admin_username = var.admin_username
|
||||
admin_password = random_password.password.result
|
||||
}
|
||||
|
||||
module "qmi-nic" {
|
||||
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//qmi-nic"
|
||||
|
||||
prefix = local.virtual_machine_name
|
||||
location = var.location
|
||||
subnet_id = var.subnet_id
|
||||
|
||||
resource_group_name = var.resource_group_name
|
||||
user_id = var.user_id
|
||||
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_machine" "vm" {
|
||||
name = local.virtual_machine_name
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
network_interface_ids = [module.qmi-nic.id]
|
||||
vm_size = var.vm_type
|
||||
|
||||
delete_os_disk_on_termination = true
|
||||
delete_data_disks_on_termination = true
|
||||
|
||||
storage_image_reference {
|
||||
# this is the Oracle linux image I found.
|
||||
# az vm image list --all --publisher Oracle -o table
|
||||
publisher = "Oracle"
|
||||
offer = "Oracle-Linux"
|
||||
sku = "77"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
storage_os_disk {
|
||||
name = "${local.virtual_machine_name}-osdisk"
|
||||
caching = "ReadWrite"
|
||||
create_option = "FromImage"
|
||||
managed_disk_type = var.managed_disk_type
|
||||
disk_size_gb = var.disk_size_gb
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
disable_password_authentication = false
|
||||
}
|
||||
|
||||
os_profile {
|
||||
computer_name = local.virtual_machine_name
|
||||
admin_username = local.admin_username
|
||||
admin_password = local.admin_password
|
||||
}
|
||||
|
||||
tags = {
|
||||
Deployment = "QMI PoC"
|
||||
"Cost Center" = "3100"
|
||||
"ProvId" = var.provId != null? var.provId : null
|
||||
"QMI_user" = var.user_id != null? var.user_id : null
|
||||
"24x7" = var.is_24x7 == true? "" : null
|
||||
"ShutdownTime": var.is_24x7 == false? var.shutdownTime : null
|
||||
"StartupTime": var.is_24x7 == false? var.startupTime : null
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
output "virtual_machine_id" {
|
||||
value = azurerm_virtual_machine.vm.id
|
||||
}
|
||||
|
||||
output "virtual_machine_name" {
|
||||
value = "${var.prefix}-${random_id.randomMachineId.hex}"
|
||||
}
|
||||
|
||||
output "admin_username" {
|
||||
value = var.admin_username
|
||||
}
|
||||
|
||||
output "admin_password" {
|
||||
value = random_password.password.result
|
||||
}
|
||||
|
||||
output "nic_id" {
|
||||
value = module.qmi-nic.id
|
||||
}
|
||||
|
||||
output "nic_private_ip_address" {
|
||||
value = module.qmi-nic.private_ip_address
|
||||
}
|
||||
|
||||
output "nic_ip_configuration_name" {
|
||||
value = module.qmi-nic.ip_configuration_name
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
variable "subnet_id" {
|
||||
default = "/subscriptions/62ebff8f-c40b-41be-9239-252d6c0c8ad9/resourceGroups/QMI-infra-vnet/providers/Microsoft.Network/virtualNetworks/QMI-Automation-Vnet/subnets/QMI-VM-Deployments"
|
||||
}
|
||||
|
||||
variable "prefix" {
|
||||
description = "The Prefix used for all resources in this example"
|
||||
default = "QMI-ORACLELINUX"
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
default = "East US"
|
||||
}
|
||||
|
||||
variable "resource_group_name" {
|
||||
}
|
||||
|
||||
variable "vm_type" {
|
||||
default = "Standard_DS3_v2"
|
||||
}
|
||||
|
||||
variable "managed_disk_type" {
|
||||
default = "Premium_LRS"
|
||||
}
|
||||
|
||||
variable "disk_size_gb" {
|
||||
default = "128"
|
||||
}
|
||||
|
||||
variable "admin_username" {
|
||||
default = "qmi"
|
||||
}
|
||||
|
||||
variable "user_id" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "provId" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "is_24x7"{
|
||||
type = bool
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "shutdownTime"{
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "startupTime"{
|
||||
default = null
|
||||
}
|
||||
|
||||
# variable "subnet_id" {
|
||||
# default = "/subscriptions/1f3d4c1d-6509-4c52-8dee-c15fb83f2920/resourceGroups/lkn-rg/providers/Microsoft.Network/virtualNetworks/lkn-vn/subnets/default"
|
||||
# }
|
||||
@@ -37,47 +37,37 @@ module "qmi-nic" {
|
||||
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_machine" "vm" {
|
||||
name = local.virtual_machine_name
|
||||
location = var.location
|
||||
resource_group_name = var.resource_group_name
|
||||
network_interface_ids = [module.qmi-nic.id]
|
||||
vm_size = var.vm_type
|
||||
resource "azurerm_linux_virtual_machine" "vm" {
|
||||
name = local.virtual_machine_name
|
||||
resource_group_name = var.resource_group_name
|
||||
location = var.location
|
||||
size = var.vm_type
|
||||
admin_username = local.admin_username
|
||||
admin_password = local.admin_password
|
||||
disable_password_authentication = false
|
||||
|
||||
network_interface_ids = [
|
||||
module.qmi-nic.id,
|
||||
]
|
||||
|
||||
delete_os_disk_on_termination = true
|
||||
delete_data_disks_on_termination = true
|
||||
os_disk {
|
||||
name = "${local.virtual_machine_name}-osdisk"
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = var.managed_disk_type
|
||||
disk_size_gb = var.disk_size_gb
|
||||
}
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
# this is the Oracle linux image I found.
|
||||
# az vm image list --all --publisher Oracle -o table
|
||||
source_image_reference {
|
||||
publisher = "Oracle"
|
||||
offer = "Oracle-Linux"
|
||||
sku = "81"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
storage_os_disk {
|
||||
name = "${local.virtual_machine_name}-osdisk"
|
||||
caching = "ReadWrite"
|
||||
create_option = "FromImage"
|
||||
managed_disk_type = var.managed_disk_type
|
||||
disk_size_gb = var.disk_size_gb
|
||||
}
|
||||
|
||||
os_profile_linux_config {
|
||||
disable_password_authentication = false
|
||||
}
|
||||
|
||||
os_profile {
|
||||
computer_name = local.virtual_machine_name
|
||||
admin_username = local.admin_username
|
||||
admin_password = local.admin_password
|
||||
}
|
||||
|
||||
tags = {
|
||||
Deployment = "QMI PoC"
|
||||
"Cost Center" = "3100"
|
||||
@@ -94,7 +84,7 @@ module "linux-common" {
|
||||
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//linux-common"
|
||||
|
||||
depends_on = [
|
||||
azurerm_virtual_machine.vm
|
||||
azurerm_linux_virtual_machine.vm
|
||||
]
|
||||
|
||||
os_type = "centos"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
output "virtual_machine_id" {
|
||||
value = azurerm_virtual_machine.vm.id
|
||||
value = azurerm_linux_virtual_machine.vm.id
|
||||
}
|
||||
|
||||
output "virtual_machine_name" {
|
||||
@@ -27,5 +27,5 @@ output "nic_ip_configuration_name" {
|
||||
}
|
||||
|
||||
output "principal_id" {
|
||||
value = azurerm_virtual_machine.vm.identity.0.principal_id
|
||||
value = azurerm_linux_virtual_machine.vm.identity.0.principal_id
|
||||
}
|
||||
@@ -38,12 +38,4 @@ output "mysql_demo_password" {
|
||||
value = "Qlik1234!"
|
||||
}
|
||||
|
||||
output "nic_fqdn" {
|
||||
value = var.isExternal? module.qmi-nic.fqdn : null
|
||||
}
|
||||
|
||||
output "nic_public_ip_address" {
|
||||
value = var.isExternal? module.qmi-nic.public_ip_address : null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ resource "random_password" "password" {
|
||||
override_special = "_!@"
|
||||
upper = true
|
||||
lower = true
|
||||
numeric = true
|
||||
min_numeric = 2
|
||||
min_lower = 2
|
||||
min_upper = 2
|
||||
min_special = 2
|
||||
@@ -24,6 +26,8 @@ resource "random_password" "qlikpassword" {
|
||||
override_special = "_!@"
|
||||
upper = true
|
||||
lower = true
|
||||
numeric = true
|
||||
min_numeric = 2
|
||||
min_lower = 2
|
||||
min_upper = 2
|
||||
min_special = 2
|
||||
@@ -86,37 +90,6 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
|
||||
source_image_id = var.image_reference
|
||||
|
||||
|
||||
provisioner "file" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "10m"
|
||||
}
|
||||
source = "${path.module}/scripts"
|
||||
destination = "C:/provision"
|
||||
}
|
||||
|
||||
/*provisioner "remote-exec" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "10m"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/prep-files.ps1"
|
||||
]
|
||||
}*/
|
||||
|
||||
tags = {
|
||||
Deployment = "QMI PoC"
|
||||
"Cost Center" = "3100"
|
||||
@@ -129,13 +102,42 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
}
|
||||
|
||||
|
||||
/*resource "azurerm_virtual_machine_extension" "prepfiles" {
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
]
|
||||
|
||||
name = "vm-extension-prepfiles"
|
||||
virtual_machine_id = azurerm_windows_virtual_machine.vm.id
|
||||
|
||||
publisher = "Microsoft.Compute"
|
||||
type = "CustomScriptExtension"
|
||||
type_handler_version = "1.10"
|
||||
auto_upgrade_minor_version = true
|
||||
|
||||
settings = <<SETTINGS
|
||||
{
|
||||
"fileUris": [
|
||||
"https://gitlab.com/qmi/qmi-cloud-tf-modules/-/raw/master/vm-qs/main/prep-files.ps1"
|
||||
],
|
||||
"commandToExecute": "start powershell.exe -NoProfile -ExecutionPolicy unrestricted -File prep-files.ps1"
|
||||
}
|
||||
SETTINGS
|
||||
}*/
|
||||
|
||||
|
||||
resource "null_resource" "vm-qs-post" {
|
||||
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
]
|
||||
|
||||
/*provisioner "local-exec" {
|
||||
command = "echo 'Waiting 20 seconds for PrepFiles to finish'; sleep 20;"
|
||||
}*/
|
||||
|
||||
provisioner "remote-exec" {
|
||||
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
@@ -147,24 +149,10 @@ resource "null_resource" "vm-qs-post" {
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/bootstrap-qs.ps1 -ModuleName vm-qs"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "10m"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/qs-post-cfg.ps1 -Hostname ${var.resource_group_name}.qmi.qlik-poc.com -Serial ${local.serial} -Control ${local.control} -CertPwd \"${local.cert_password}\" -QlikUserPwd ${local.qlikpassword}",
|
||||
"powershell.exe -File C:/provision/q-WebConnectors.ps1",
|
||||
"powershell -NoProfile -File C:\\Temp\\prep-files.ps1 -scenario vm-qs",
|
||||
"powershell -NoProfile -File C:\\provision\\bootstrap-qs.ps1 -ModuleName vm-qs",
|
||||
"powershell -NoProfile -File C:\\provision\\qs-post-cfg.ps1 -Hostname ${var.resource_group_name}.qmi.qlik-poc.com -Serial ${local.serial} -Control ${local.control} -CertPwd \"${local.cert_password}\" -QlikUserPwd ${local.qlikpassword}",
|
||||
"powershell -NoProfile -File C:\\provision\\q-WebConnectors.ps1",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,6 @@ output "nic_private_ip_address" {
|
||||
value = module.qmi-nic.private_ip_address
|
||||
}
|
||||
|
||||
output "nic_fqdn" {
|
||||
value = var.isExternal? module.qmi-nic.fqdn : null
|
||||
}
|
||||
|
||||
output "nic_public_ip_address" {
|
||||
value = var.isExternal? module.qmi-nic.public_ip_address : null
|
||||
}
|
||||
|
||||
output "nic_ip_configuration_name" {
|
||||
value = module.qmi-nic.ip_configuration_name
|
||||
}
|
||||
@@ -62,19 +62,41 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
"ShutdownTime": var.is_24x7 == false? var.shutdownTime : null
|
||||
"StartupTime": var.is_24x7 == false? var.startupTime : null
|
||||
}
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "3m"
|
||||
|
||||
resource "azurerm_virtual_machine_extension" "prepfiles" {
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
]
|
||||
|
||||
name = "vm-extension-prepfiles"
|
||||
virtual_machine_id = azurerm_windows_virtual_machine.vm.id
|
||||
|
||||
publisher = "Microsoft.Compute"
|
||||
type = "CustomScriptExtension"
|
||||
type_handler_version = "1.10"
|
||||
auto_upgrade_minor_version = true
|
||||
|
||||
settings = <<SETTINGS
|
||||
{
|
||||
"fileUris": [
|
||||
"https://gitlab.com/qmi/qmi-cloud-tf-modules/-/raw/master/vm-win/main/prep-files.ps1"
|
||||
],
|
||||
"commandToExecute": "start powershell.exe -ExecutionPolicy unrestricted -File prep-files.ps1"
|
||||
}
|
||||
source = "${path.module}/main"
|
||||
destination = "C:/provision"
|
||||
SETTINGS
|
||||
}
|
||||
|
||||
resource "null_resource" "vm-post" {
|
||||
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm,
|
||||
azurerm_virtual_machine_extension.prepfiles
|
||||
]
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "echo 'Waiting 20 seconds for PrepFiles to finish'; sleep 20;"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
@@ -89,7 +111,6 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/prep-files.ps1",
|
||||
"powershell.exe -File C:/provision/bootstrap.ps1"
|
||||
]
|
||||
}
|
||||
@@ -109,6 +130,7 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
"powershell.exe -File C:/provision/q-user-setup.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +139,7 @@ module "win-common" {
|
||||
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//win-common"
|
||||
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
null_resource.vm-post
|
||||
]
|
||||
|
||||
private_ip_address = module.qmi-nic.private_ip_address
|
||||
|
||||
111
vm-win2/main.tf
111
vm-win2/main.tf
@@ -35,6 +35,51 @@ module "qmi-nic" {
|
||||
user_id = var.user_id
|
||||
}
|
||||
|
||||
resource "azurerm_windows_virtual_machine" "vm" {
|
||||
name = local.virtual_machine_name
|
||||
resource_group_name = var.resource_group_name
|
||||
location = var.location
|
||||
size = var.vm_type
|
||||
admin_username = local.admin_username
|
||||
admin_password = local.admin_password
|
||||
network_interface_ids = [ module.qmi-nic.id ]
|
||||
|
||||
os_disk {
|
||||
name = "${local.virtual_machine_name}-osdisk"
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = var.managed_disk_type
|
||||
disk_size_gb = var.disk_size_gb
|
||||
}
|
||||
|
||||
source_image_id = var.image_reference
|
||||
|
||||
tags = {
|
||||
"Deployment" = "QMI PoC"
|
||||
"Cost Center" = "3100"
|
||||
"ProvId" = var.provId != null? var.provId : null
|
||||
"QMI_user" = var.user_id != null? var.user_id : null
|
||||
"24x7" = var.is_24x7 == true? "" : null
|
||||
"ShutdownTime": var.is_24x7 == false? var.shutdownTime : null
|
||||
"StartupTime": var.is_24x7 == false? var.startupTime : null
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "30m"
|
||||
}
|
||||
source = "${path.module}/main"
|
||||
destination = "C:/tmp/provision"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
resource "azurerm_windows_virtual_machine" "vm" {
|
||||
name = local.virtual_machine_name
|
||||
resource_group_name = var.resource_group_name
|
||||
@@ -83,19 +128,40 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
"ShutdownTime": var.is_24x7 == false? var.shutdownTime : null
|
||||
"StartupTime": var.is_24x7 == false? var.startupTime : null
|
||||
}
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
connection {
|
||||
type = "winrm"
|
||||
host = module.qmi-nic.private_ip_address
|
||||
user = local.admin_username
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "3m"
|
||||
resource "azurerm_virtual_machine_extension" "prepfiles" {
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
]
|
||||
|
||||
name = "vm-extension-prepfiles"
|
||||
virtual_machine_id = azurerm_windows_virtual_machine.vm.id
|
||||
|
||||
publisher = "Microsoft.Compute"
|
||||
type = "CustomScriptExtension"
|
||||
type_handler_version = "1.10"
|
||||
auto_upgrade_minor_version = true
|
||||
|
||||
settings = <<SETTINGS
|
||||
{
|
||||
"fileUris": [
|
||||
"https://gitlab.com/qmi/qmi-cloud-tf-modules/-/raw/master/vm-win/main/prep-files.ps1"
|
||||
],
|
||||
"commandToExecute": "start powershell.exe -NoProfile -ExecutionPolicy unrestricted -File prep-files.ps1"
|
||||
}
|
||||
source = "${path.module}/main"
|
||||
destination = "C:/provision"
|
||||
SETTINGS
|
||||
}
|
||||
*/
|
||||
|
||||
resource "null_resource" "vm-post" {
|
||||
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
]
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "echo 'Waiting 20 seconds for PrepFiles to finish'; sleep 20;"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
@@ -106,12 +172,12 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "3m"
|
||||
timeout = "30m"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/prep-files.ps1",
|
||||
"powershell.exe -File C:/provision/bootstrap.ps1"
|
||||
"powershell.exe -NoProfile -File C:/tmp/provision/prep-files.ps1",
|
||||
"powershell.exe -NoProfile -File C:/provision/bootstrap.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -123,13 +189,14 @@ resource "azurerm_windows_virtual_machine" "vm" {
|
||||
password = local.admin_password
|
||||
port = 5985
|
||||
https = false
|
||||
timeout = "3m"
|
||||
timeout = "30m"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/q-user-setup.ps1"
|
||||
"powershell.exe -NoProfile -File C:/provision/q-user-setup.ps1"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +205,9 @@ module "win-common" {
|
||||
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//win-common"
|
||||
|
||||
depends_on = [
|
||||
azurerm_windows_virtual_machine.vm
|
||||
azurerm_windows_virtual_machine.vm,
|
||||
null_resource.vm-post
|
||||
|
||||
]
|
||||
|
||||
private_ip_address = module.qmi-nic.private_ip_address
|
||||
@@ -162,13 +231,13 @@ resource "null_resource" "post-win-common" {
|
||||
insecure = true
|
||||
use_ntlm = false
|
||||
https = false
|
||||
timeout = "10m"
|
||||
timeout = "30m"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"powershell.exe -File C:/provision/win-common/chrome-install.ps1",
|
||||
"powershell.exe -File C:/provision/win-common/onedrive-install.ps1",
|
||||
"powershell.exe -File C:/provision/win-common/vscode-install.ps1",
|
||||
"powershell.exe -NoProfile -File C:/provision/win-common/chrome-install.ps1",
|
||||
"powershell.exe -NoProfile -File C:/provision/win-common/onedrive-install.ps1",
|
||||
"powershell.exe -NoProfile -File C:/provision/win-common/vscode-install.ps1",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user