feat(tasks): refactor boundary configuration and add wrapper path variable

This commit is contained in:
35C4n0r 2026-04-30 21:07:36 +05:30
parent c4931afbf4
commit 6c1613d1a9
No known key found for this signature in database
GPG Key ID: 5B71E5C9D18D5675

View File

@ -98,12 +98,6 @@ variable "agentapi" {
default = {} default = {}
} }
variable "enable_boundary" {
type = bool
description = "Whether to enable Boundary for this agent. If false, the Boundary module will not be included and Boundary will not be installed, but the start script will still run."
default = false
}
variable "cli_app_display_name" { variable "cli_app_display_name" {
type = string type = string
description = "Display name for the CLI app. Only applicable if `enable_agentapi` is false." description = "Display name for the CLI app. Only applicable if `enable_agentapi` is false."
@ -115,24 +109,21 @@ variable "cli_app_display_name" {
} }
} }
variable "boundary" { variable "enable_boundary" {
description = <<-EOT type = bool
Boundary configuration: description = "Whether to enable Boundary for this agent. If false, the Boundary module will not be included and Boundary will not be installed, but the start script will still run."
- `version`: Boundary version. When `use_binary_directly` is true, a release version should be provided or 'latest' for the latest release. default = false
- `compile_from_source`: Whether to compile boundary from source instead of using the official install script. }
- `use_binary_directly`: Whether to use boundary binary directly instead of coder boundary subcommand.
- `pre_install_script`: Custom script to run before installing Boundary. variable "boundary_wrapper_path" {
- `post_install_script`: Custom script to run after installing Boundary. type = string
- `module_directory`: Directory where the Boundary module files are stored. description = "Path to the Boundary CLI wrapper script. Only applicable if `enable_boundary` is true."
EOT default = ""
type = object({
version = optional(string, "latest") validation {
compile_from_source = optional(bool, false) condition = var.enable_boundary == false || (var.enable_boundary == true && var.boundary_wrapper_path != "")
use_binary_directly = optional(bool, false) error_message = "boundary_wrapper_path must be set when enable_boundary is true."
pre_install_script = optional(string, null) }
post_install_script = optional(string, null)
module_directory = optional(string, "$HOME/.coder-modules/coder/boundary")
})
} }
locals { locals {
@ -146,6 +137,7 @@ locals {
export_merged_variables = merge(local.export_variables, { export_merged_variables = merge(local.export_variables, {
"ARG_ENABLE_AGENTAPI" = var.enable_agentapi "ARG_ENABLE_AGENTAPI" = var.enable_agentapi
"ARG_ENABLE_BOUNDARY" = var.enable_boundary "ARG_ENABLE_BOUNDARY" = var.enable_boundary
"ARG_BOUNDARY_WRAPPER_PATH" = var.boundary_wrapper_path
}) })
default_app_slugs = { default_app_slugs = {
@ -207,20 +199,6 @@ resource "coder_app" "non_agentapi_cli" {
slug = local.cli_app_slug slug = local.cli_app_slug
} }
module "boundary" {
count = var.enable_boundary ? 1 : 0
source = "git::https://github.com/coder/registry.git//registry/coder/modules/boundary?ref=35C4n0r/feat-boundary-module"
agent_id = var.agent_id
compile_boundary_from_source = var.boundary.compile_from_source
use_boundary_directly = var.boundary.use_binary_directly
boundary_version = var.boundary.version
pre_install_script = var.boundary.pre_install_script
post_install_script = var.boundary.post_install_script
module_directory = var.boundary.module_directory
}
output "task_app_id" { output "task_app_id" {
description = "The app ID for the task's web app, if created." description = "The app ID for the task's web app, if created."
value = try(module.agentapi[0].task_app_id, coder_app.non_agentapi_cli[0].id) value = try(module.agentapi[0].task_app_id, coder_app.non_agentapi_cli[0].id)