add support for kasm config
This commit is contained in:
parent
b58bfebcf3
commit
18d447f779
@ -54,6 +54,12 @@ variable "subdomain" {
|
||||
description = "Is subdomain sharing enabled in your cluster?"
|
||||
}
|
||||
|
||||
variable "kasm_config" {
|
||||
type = map(any)
|
||||
default = {}
|
||||
description = "Additional KasmVNC configuration options. Can be used to set DLP policies and other advanced settings. See https://kasmweb.com/docs/develop/how_to/kasmvnc_dlp_policies.html for details."
|
||||
}
|
||||
|
||||
resource "coder_script" "kasm_vnc" {
|
||||
agent_id = var.agent_id
|
||||
display_name = "KasmVNC"
|
||||
|
||||
@ -205,6 +205,8 @@ else
|
||||
fi
|
||||
|
||||
echo "Writing KasmVNC config to $kasm_config_file"
|
||||
|
||||
# Create base config
|
||||
$SUDO tee "$kasm_config_file" > /dev/null << EOF
|
||||
network:
|
||||
protocol: http
|
||||
@ -218,6 +220,32 @@ network:
|
||||
public_ip: 127.0.0.1
|
||||
EOF
|
||||
|
||||
# Add additional KasmVNC configuration if provided
|
||||
if [[ -n "${KASM_CONFIG}" && "${KASM_CONFIG}" != "{}" ]]; then
|
||||
# Check if jq is available
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "WARNING: jq is not installed. Cannot parse additional KasmVNC configuration."
|
||||
echo "WARNING: Install jq or provide configuration in the correct format."
|
||||
else
|
||||
# Create a temporary file for the additional config
|
||||
TEMP_CONFIG_FILE=$(mktemp)
|
||||
|
||||
# Parse the JSON and convert to YAML format
|
||||
echo '${KASM_CONFIG}' | jq -r 'to_entries | .[] |
|
||||
if .value | type == "object" then
|
||||
.key + ":\n" + (.value | to_entries | map(" " + .key + ": " + (.value | tostring)) | join("\n"))
|
||||
else
|
||||
.key + ": " + (.value | tostring)
|
||||
end' > "$TEMP_CONFIG_FILE"
|
||||
|
||||
# Append the additional config to the main config file
|
||||
$SUDO tee -a "$kasm_config_file" > /dev/null < "$TEMP_CONFIG_FILE"
|
||||
|
||||
# Clean up
|
||||
rm "$TEMP_CONFIG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# This password is not used since we start the server without auth.
|
||||
# The server is protected via the Coder session token / tunnel
|
||||
# and does not listen publicly
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user