7 Commits

Author SHA1 Message Date
Manuel Romero
4ffde50de5 fixes 2022-04-27 13:50:19 +02:00
Manuel Romero
c7ba210353 fixes 2022-04-27 13:47:30 +02:00
Manuel Romero
94a86a7c90 fix 2022-04-27 13:26:50 +02:00
Manuel Romero
774c830b54 fixes 2022-04-27 13:20:43 +02:00
Manuel Romero
49c9a074d7 fixes 2022-04-27 13:18:44 +02:00
Manuel Romero
90e6b51b07 fixes 2022-04-27 13:17:50 +02:00
Manuel Romero
bf49b1f77a changes to accomodate 'fromsnap' 2022-04-27 13:11:19 +02:00
3 changed files with 74 additions and 44 deletions

View File

@@ -129,12 +129,6 @@ resource "null_resource" "post-vm-fromsnapshot-linux" {
destination = "~"
}
provisioner "local-exec" {
command = "echo 'User/Pass: ${local.admin_username} / ${var.initial_password}'"
}
provisioner "remote-exec" {
connection {
type = "ssh"

View File

@@ -28,7 +28,7 @@ locals {
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"
@@ -40,9 +40,32 @@ module "qmi-nic" {
user_id = var.user_id
isExternal = var.isExternal
}*/
module "vm-qdc-fromsnapshot" {
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//vm-fromsnapshot-linux"
subnet_id = var.subnet_id
location = var.location
resource_group_name = var.resource_group_name
snapshot_id = "/subscriptions/62ebff8f-c40b-41be-9239-252d6c0c8ad9/resourceGroups/QMI-Machines/providers/Microsoft.Compute/snapshots/QDC-Install-VM-Feb2022"
#snapshot_uri = "https://${local.source_container}.blob.core.windows.net/${var.image_reference}"
vm_type = var.vm_type
disk_size_gb = var.disk_size_gb
provId = var.provId
is_24x7 = var.is_24x7
startupTime = var.startupTime
shutdownTime = var.shutdownTime
prefix = var.prefix
admin_username = "qmi"
initial_password = "pcZr_UoJYg05D!Vz"
user_id = var.user_id
}
resource "azurerm_linux_virtual_machine" "vm" {
/*resource "azurerm_linux_virtual_machine" "vm" {
name = local.virtual_machine_name
resource_group_name = var.resource_group_name
location = var.location
@@ -72,13 +95,38 @@ resource "azurerm_linux_virtual_machine" "vm" {
"ShutdownTime": var.is_24x7 == false? var.shutdownTime : null
"StartupTime": var.is_24x7 == false? var.startupTime : null
}
}
*/
module "linux-common" {
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//linux-common"
depends_on = [
module.vm-qdc-fromsnapshot
]
os_type = "centos"
private_ip_address = module.vm-qdc-fromsnapshot.nic_private_ip_address
admin_username = module.vm-qdc-fromsnapshot.admin_username
admin_password = module.vm-qdc-fromsnapshot.admin_password
}
resource "null_resource" "post-qdc-fromsnapshot" {
depends_on = [
module.vm-qdc-fromsnapshot,
module.linux-common
]
provisioner "remote-exec" {
connection {
type = "ssh"
host = module.qmi-nic.private_ip_address
user = local.admin_username
password = local.admin_password
host = module.vm-qdc-fromsnapshot.nic_private_ip_address
user = module.vm-qdc-fromsnapshot.admin_username
password = module.vm-qdc-fromsnapshot.admin_password
timeout = "3m"
#private_key = "${file("~/.ssh/id_rsa")}"
}
@@ -91,9 +139,9 @@ resource "azurerm_linux_virtual_machine" "vm" {
provisioner "file" {
connection {
type = "ssh"
host = module.qmi-nic.private_ip_address
user = local.admin_username
password = local.admin_password
host = module.vm-qdc-fromsnapshot.nic_private_ip_address
user = module.vm-qdc-fromsnapshot.admin_username
password = module.vm-qdc-fromsnapshot.admin_password
timeout = "10m"
#private_key = "${file("~/.ssh/id_rsa")}"
}
@@ -104,34 +152,22 @@ resource "azurerm_linux_virtual_machine" "vm" {
provisioner "remote-exec" {
connection {
type = "ssh"
host = module.qmi-nic.private_ip_address
user = local.admin_username
password = local.admin_password
host = module.vm-qdc-fromsnapshot.nic_private_ip_address
user = module.vm-qdc-fromsnapshot.admin_username
password = module.vm-qdc-fromsnapshot.admin_password
timeout = "3m"
#private_key = "${file("~/.ssh/id_rsa")}"
}
inline = [
"echo ${local.admin_password} | sudo -S chmod a+x /home/${local.admin_username}/scripts/feb2021/*.sh",
"sudo /home/${local.admin_username}/scripts/feb2021/qdc-nextgen-xml.sh '${module.qmi-nic.private_ip_address}' ${var.image_reference}",
"sudo /home/${local.admin_username}/scripts/feb2021/core_env_setup.sh",
"sudo /home/${local.admin_username}/scripts/feb2021/set-license.sh '${data.azurerm_key_vault_secret.license-sept20.value}'"
"echo ${module.vm-qdc-fromsnapshot.admin_password} | sudo -S chmod a+x /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2021/*.sh",
"echo ${module.vm-qdc-fromsnapshot.admin_password} | sudo -S chmod a+x /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2022/*.sh",
"sudo /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2022/qdc-prereqs.sh /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2022/qdc-scenario-config.sh",
"sudo /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2021/qdc-nextgen-xml.sh '${module.vm-qdc-fromsnapshot.nic_private_ip_address}' ${var.image_reference}",
"sudo /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2021/core_env_setup.sh",
"sudo /home/${module.vm-qdc-fromsnapshot.admin_username}/scripts/feb2021/set-license.sh '${data.azurerm_key_vault_secret.license-sept20.value}'"
]
}
}
module "linux-common" {
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//linux-common"
depends_on = [
azurerm_linux_virtual_machine.vm
]
os_type = "centos"
private_ip_address = module.qmi-nic.private_ip_address
admin_username = local.admin_username
admin_password = local.admin_password
}

View File

@@ -1,29 +1,29 @@
output "virtual_machine_id" {
value = azurerm_linux_virtual_machine.vm.id
value = module.vm-qdc-fromsnapshot.virtual_machine_id
}
output "virtual_machine_name" {
value = "${var.prefix}-${random_id.randomMachineId.hex}"
value = module.vm-qdc-fromsnapshot.virtual_machine_name
}
output "admin_username" {
value = var.admin_username
value = module.vm-qdc-fromsnapshot.admin_username
}
output "admin_password" {
value = random_password.password.result
value = module.vm-qdc-fromsnapshot.admin_password
}
output "nic_id" {
value = module.qmi-nic.id
value = module.vm-qdc-fromsnapshot.nic_id
}
output "nic_private_ip_address" {
value = module.qmi-nic.private_ip_address
value = module.vm-qdc-fromsnapshot.nic_private_ip_address
}
output "nic_ip_configuration_name" {
value = module.qmi-nic.ip_configuration_name
value = module.vm-qdc-fromsnapshot.nic_ip_configuration_name
}
output "mysql_root_password" {
@@ -38,12 +38,12 @@ output "mysql_demo_password" {
value = "Qlik1234!"
}
output "nic_fqdn" {
/*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
}
}*/