refactor: try extracting main script into separate template file

mes/rdp-glitch-repro^2
Parkreiner 10 months ago
parent a8580fe6b9
commit b23d85327c

@ -34,9 +34,14 @@ resource "coder_script" "windows-rdp" {
agent_id = var.agent_id
display_name = "windows-rdp"
icon = "https://svgur.com/i/158F.svg" # TODO: add to Coder icons
script = templatefile("${path.module}/windows-installation.tftpl", {
CODER_USERNAME = var.admin_username,
CODER_PASSWORD = var.admin_password,
admin_username = var.admin_username
admin_password = var.admin_password
patch_file_contents = templatefile("${path.module}/devolutions-patch.js", {
CODER_USERNAME = var.admin_username
CODER_PASSWORD = var.admin_password
})
})
run_on_start = true

@ -3,9 +3,9 @@ function Set-AdminPassword {
[string]$adminPassword
)
# Set admin password
Get-LocalUser -Name "${var.admin_username}" | Set-LocalUser -Password (ConvertTo-SecureString -AsPlainText $adminPassword -Force)
Get-LocalUser -Name "${admin_username}" | Set-LocalUser -Password (ConvertTo-SecureString -AsPlainText $adminPassword -Force)
# Enable admin user
Get-LocalUser -Name "${var.admin_username}" | Enable-LocalUser
Get-LocalUser -Name "${admin_username}" | Enable-LocalUser
}
function Configure-RDP {
@ -69,10 +69,7 @@ $patch = '<script defer id="coder-patch" src="coder.js"></script>'
# Always copy the file in case we change it.
@'
${templatefile("${path.module}/devolutions-patch.js", {
CODER_USERNAME : var.admin_username,
CODER_PASSWORD : var.admin_password,
})}
${patch_file_contents}
'@ | Set-Content "$root\coder.js"
# Only inject the src if we have not before.
@ -82,7 +79,7 @@ if ($isPatched -eq $null) {
}
}
Set-AdminPassword -adminPassword "${var.admin_password}"
Set-AdminPassword -adminPassword "${admin_password}"
Configure-RDP
Install-DevolutionsGateway
Patch-Devolutions-HTML

Loading…
Cancel
Save