120 lines
No EOL
3.8 KiB
HCL
120 lines
No EOL
3.8 KiB
HCL
# Cloud-init Configuration
|
|
# Selects template based on agent_framework variable
|
|
|
|
# Hermes Agent cloud-init
|
|
data "cloudinit_config" "hermes" {
|
|
count = var.agent_framework == "hermes" ? 1 : 0
|
|
|
|
gzip = false
|
|
base64_encode = true
|
|
|
|
part {
|
|
filename = "cloud-config.yaml"
|
|
content_type = "text/cloud-config"
|
|
content = templatefile("${path.module}/templates/userdata-hermes.tpl", {
|
|
# Server configuration
|
|
server_name = var.server_name
|
|
admin_user = local.effective_admin_user
|
|
location = var.location_hetzner
|
|
|
|
# Agent configuration
|
|
agent_name = var.agent_name
|
|
primary_model = var.primary_model
|
|
primary_model_name = var.primary_model_name
|
|
fallback_models = var.fallback_models
|
|
docker_enabled = var.docker_enabled
|
|
|
|
# SSH configuration
|
|
ssh_port = var.ssh_port
|
|
ssh_allowed_ips = var.ssh_allowed_ips
|
|
admin_ssh_keys = var.admin_ssh_keys
|
|
|
|
# API keys
|
|
venice_api_key = var.venice_api_key
|
|
venice_base_url = var.venice_base_url
|
|
brave_search_api_key = var.brave_search_api_key
|
|
|
|
# Discord
|
|
discord_bot_token = var.discord_bot_token
|
|
discord_server_id = var.discord_server_id
|
|
discord_user_id = var.discord_user_id
|
|
discord_home_channel = var.discord_home_channel
|
|
discord_allowed_users = var.discord_allowed_users
|
|
discord_auto_thread = var.discord_auto_thread
|
|
gateway_allow_all_users = var.gateway_allow_all_users
|
|
|
|
# Gateway
|
|
gateway_token = var.gateway_token != "" ? var.gateway_token : random_password.gateway_token[0].result
|
|
gateway_allowed_users = var.gateway_allowed_users
|
|
})
|
|
}
|
|
}
|
|
|
|
# OpenClaw cloud-init
|
|
data "cloudinit_config" "openclaw" {
|
|
count = var.agent_framework == "openclaw" ? 1 : 0
|
|
|
|
gzip = false
|
|
base64_encode = true
|
|
|
|
part {
|
|
filename = "cloud-config.yaml"
|
|
content_type = "text/cloud-config"
|
|
content = templatefile("${path.module}/templates/userdata-openclaw.tpl", {
|
|
# Server configuration
|
|
server_name = var.server_name
|
|
admin_user = local.effective_admin_user
|
|
|
|
# SSH configuration
|
|
ssh_port = var.ssh_port
|
|
ssh_allowed_ips = var.ssh_allowed_ips
|
|
admin_ssh_keys = var.admin_ssh_keys
|
|
|
|
# OpenClaw configuration
|
|
openclaw_version = "lts"
|
|
node_version = "22"
|
|
agent_name = var.agent_name
|
|
agent_timezone = "UTC"
|
|
|
|
# System configuration
|
|
enable_swap = true
|
|
swap_size = 2
|
|
enable_fail2ban = true
|
|
enable_unattended_upgrades = true
|
|
|
|
# Tailscale
|
|
enable_tailscale = var.enable_tailscale
|
|
tailscale_auth_key = var.tailscale_auth_key
|
|
|
|
# API keys
|
|
venice_api_key = var.venice_api_key
|
|
default_model = var.primary_model
|
|
brave_search_api_key = var.brave_search_api_key
|
|
|
|
# Discord
|
|
discord_bot_token = var.discord_bot_token
|
|
discord_server_id = var.discord_server_id
|
|
discord_user_id = var.discord_user_id
|
|
discord_home_channel = var.discord_home_channel
|
|
discord_allowed_users = var.discord_allowed_users
|
|
discord_auto_thread = var.discord_auto_thread
|
|
|
|
# Inference models configuration
|
|
primary_model = var.primary_model
|
|
fallback_models = jsonencode(var.fallback_models)
|
|
models_config = file("${path.module}/models/venice.json")
|
|
})
|
|
}
|
|
}
|
|
|
|
# Random password for gateway token if not provided
|
|
resource "random_password" "gateway_token" {
|
|
count = var.agent_framework == "hermes" && var.gateway_token == "" ? 1 : 0
|
|
length = 32
|
|
special = false
|
|
}
|
|
|
|
# Output selected userdata
|
|
locals {
|
|
userdata = var.agent_framework == "hermes" ? data.cloudinit_config.hermes[0].rendered : data.cloudinit_config.openclaw[0].rendered
|
|
} |