SWITCH: 从 Ansible 切换到 Terraform 管理 Nomad 配置
Some checks failed
Some checks failed
- 创建 nomad-config Terraform 模块 - 声明式管理 Nomad 节点配置 - 更新 GitOps 工作流使用 Terraform - 避免配置漂移,确保主客观统一 - 目标: 通过 IaC 修复 5个异常节点
This commit is contained in:
51
infrastructure/opentofu/modules/nomad-config/main.tf
Normal file
51
infrastructure/opentofu/modules/nomad-config/main.tf
Normal file
@@ -0,0 +1,51 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
nomad = {
|
||||
source = "hashicorp/nomad"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Nomad 节点配置资源
|
||||
resource "nomad_node_pool" "default" {
|
||||
name = "default"
|
||||
description = "Default node pool for all nodes"
|
||||
}
|
||||
|
||||
# 定义需要修复的节点
|
||||
locals {
|
||||
nomad_nodes = {
|
||||
ch4 = {
|
||||
address = "ch4.tailnet-68f9.ts.net"
|
||||
datacenter = "dc1"
|
||||
node_class = ""
|
||||
}
|
||||
hcp1 = {
|
||||
address = "hcp1.tailnet-68f9.ts.net"
|
||||
datacenter = "dc1"
|
||||
node_class = ""
|
||||
}
|
||||
warden = {
|
||||
address = "warden.tailnet-68f9.ts.net"
|
||||
datacenter = "dc1"
|
||||
node_class = ""
|
||||
}
|
||||
ash1d = {
|
||||
address = "ash1d.tailnet-68f9.ts.net"
|
||||
datacenter = "dc1"
|
||||
node_class = ""
|
||||
}
|
||||
ash2e = {
|
||||
address = "ash2e.tailnet-68f9.ts.net"
|
||||
datacenter = "dc1"
|
||||
node_class = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 输出节点信息
|
||||
output "nomad_nodes" {
|
||||
value = local.nomad_nodes
|
||||
description = "Nomad 节点配置信息"
|
||||
}
|
||||
21
infrastructure/opentofu/modules/nomad-config/variables.tf
Normal file
21
infrastructure/opentofu/modules/nomad-config/variables.tf
Normal file
@@ -0,0 +1,21 @@
|
||||
variable "nomad_address" {
|
||||
description = "Nomad 集群地址"
|
||||
type = string
|
||||
default = "http://semaphore.tailnet-68f9.ts.net:4646"
|
||||
}
|
||||
|
||||
variable "consul_servers" {
|
||||
description = "Consul 服务器列表"
|
||||
type = list(string)
|
||||
default = [
|
||||
"ash3c.tailnet-68f9.ts.net:8500",
|
||||
"ch4.tailnet-68f9.ts.net:8500",
|
||||
"warden.tailnet-68f9.ts.net:8500"
|
||||
]
|
||||
}
|
||||
|
||||
variable "datacenter" {
|
||||
description = "Nomad 数据中心"
|
||||
type = string
|
||||
default = "dc1"
|
||||
}
|
||||
Reference in New Issue
Block a user