vm-win from gitlab

This commit is contained in:
Manuel Romero
2022-01-31 16:03:02 +01:00
parent 5b6724b7eb
commit ca83f73b4f
2 changed files with 31 additions and 1 deletions

View File

@@ -73,7 +73,7 @@ resource "azurerm_windows_virtual_machine" "vm" {
https = false
timeout = "3m"
}
source = "${path.module}/scripts"
source = "${path.module}/main"
destination = "C:/provision"
}
@@ -89,6 +89,7 @@ resource "azurerm_windows_virtual_machine" "vm" {
}
inline = [
"powershell.exe -File C:/provision/prep-files.ps1",
"powershell.exe -File C:/provision/bootstrap.ps1"
]
}

View File

@@ -0,0 +1,29 @@
Param(
[string] $repo="qmi-cloud-tf-modules",
[string] $branch="master",
[string] $scenario="vm-win",
[string] $path="scripts"
)
$pathIs="$scenario/$path"
$DownloadUrl="https://gitlab.com/qmi/$repo/-/archive/$branch/$repo-$branch.zip?path=$pathIs"
Write-Host "--- Boostrap# Downloading repository files from branch ($branch)..."
New-Item -ItemType Directory -Force -Path C:\Temp | Out-Null
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DownloadUrl, "C:\Temp\$scenario.zip")
Expand-Archive "C:\Temp\$scenario.zip" -DestinationPath "C:\Temp" -Force
New-Item -ItemType Directory -Force -Path C:\Provision | Out-Null
Copy-Item -Path "C:\Temp\$repo-$branch-$scenario-scripts\$scenario\$path\*" -Destination "C:\Provision" -Recurse -Force
Remove-Item "C:\Temp\$repo-$branch-$scenario-scripts" -Recurse
Remove-Item "C:\Temp\$scenario.zip" -Recurse