refactor: try extracting main script into separate template file
This commit is contained in:
@@ -34,9 +34,14 @@ resource "coder_script" "windows-rdp" {
|
|||||||
agent_id = var.agent_id
|
agent_id = var.agent_id
|
||||||
display_name = "windows-rdp"
|
display_name = "windows-rdp"
|
||||||
icon = "https://svgur.com/i/158F.svg" # TODO: add to Coder icons
|
icon = "https://svgur.com/i/158F.svg" # TODO: add to Coder icons
|
||||||
|
|
||||||
script = templatefile("${path.module}/windows-installation.tftpl", {
|
script = templatefile("${path.module}/windows-installation.tftpl", {
|
||||||
CODER_USERNAME = var.admin_username,
|
admin_username = var.admin_username
|
||||||
CODER_PASSWORD = var.admin_password,
|
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
|
run_on_start = true
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ function Set-AdminPassword {
|
|||||||
[string]$adminPassword
|
[string]$adminPassword
|
||||||
)
|
)
|
||||||
# Set admin password
|
# 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
|
# Enable admin user
|
||||||
Get-LocalUser -Name "${var.admin_username}" | Enable-LocalUser
|
Get-LocalUser -Name "${admin_username}" | Enable-LocalUser
|
||||||
}
|
}
|
||||||
|
|
||||||
function Configure-RDP {
|
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.
|
# Always copy the file in case we change it.
|
||||||
@'
|
@'
|
||||||
${templatefile("${path.module}/devolutions-patch.js", {
|
${patch_file_contents}
|
||||||
CODER_USERNAME : var.admin_username,
|
|
||||||
CODER_PASSWORD : var.admin_password,
|
|
||||||
})}
|
|
||||||
'@ | Set-Content "$root\coder.js"
|
'@ | Set-Content "$root\coder.js"
|
||||||
|
|
||||||
# Only inject the src if we have not before.
|
# 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
|
Configure-RDP
|
||||||
Install-DevolutionsGateway
|
Install-DevolutionsGateway
|
||||||
Patch-Devolutions-HTML
|
Patch-Devolutions-HTML
|
||||||
|
|||||||
Reference in New Issue
Block a user