Initial IaC setup: Nomad, Consul, Terraform, Ansible
- Ansible roles for Nomad and Consul installation - Nomad job specs for Traefik and monitoring stack - Terraform configuration for Nomad job management - Enterprise naming convention inventory - HashiCorp stack deployment playbook
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# Hobbs.farm Production Environment
|
||||
# Terraform configuration for Nomad job management
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.5.0"
|
||||
|
||||
required_providers {
|
||||
nomad = {
|
||||
source = "hashicorp/nomad"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
consul = {
|
||||
source = "hashicorp/consul"
|
||||
version = "~> 2.18"
|
||||
}
|
||||
}
|
||||
|
||||
# Backend configuration for state storage
|
||||
# Uncomment when ready to use remote state
|
||||
# backend "consul" {
|
||||
# address = "hf-pdocker-01.hobbs.farm:8500"
|
||||
# scheme = "http"
|
||||
# path = "terraform/hobbs-iac/prod"
|
||||
# }
|
||||
}
|
||||
|
||||
# Provider configurations
|
||||
provider "nomad" {
|
||||
address = "http://hf-pdocker-01.hobbs.farm:4646"
|
||||
# secret_id = var.nomad_token # Uncomment after ACL setup
|
||||
}
|
||||
|
||||
provider "consul" {
|
||||
address = "hf-pdocker-01.hobbs.farm:8500"
|
||||
datacenter = "hf-dc1"
|
||||
}
|
||||
|
||||
# Variables
|
||||
variable "environment" {
|
||||
default = "prod"
|
||||
}
|
||||
|
||||
variable "datacenter" {
|
||||
default = "hf-dc1"
|
||||
}
|
||||
|
||||
# Deploy Nomad jobs
|
||||
resource "nomad_job" "traefik" {
|
||||
jobspec = file("${path.module}/../../nomad-jobs/traefik.nomad")
|
||||
|
||||
hcl2 {
|
||||
enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "nomad_job" "monitoring" {
|
||||
jobspec = file("${path.module}/../../nomad-jobs/monitoring.nomad")
|
||||
|
||||
hcl2 {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
depends_on = [nomad_job.traefik]
|
||||
}
|
||||
|
||||
# Consul KV for configuration
|
||||
resource "consul_keys" "config" {
|
||||
datacenter = var.datacenter
|
||||
|
||||
key {
|
||||
path = "hobbs/config/environment"
|
||||
value = var.environment
|
||||
}
|
||||
|
||||
key {
|
||||
path = "hobbs/config/datacenter"
|
||||
value = var.datacenter
|
||||
}
|
||||
|
||||
key {
|
||||
path = "hobbs/config/domain"
|
||||
value = "hobbs.farm"
|
||||
}
|
||||
}
|
||||
|
||||
# Outputs
|
||||
output "nomad_address" {
|
||||
value = "http://hf-pdocker-01.hobbs.farm:4646"
|
||||
}
|
||||
|
||||
output "consul_address" {
|
||||
value = "http://hf-pdocker-01.hobbs.farm:8500"
|
||||
}
|
||||
|
||||
output "traefik_job_id" {
|
||||
value = nomad_job.traefik.id
|
||||
}
|
||||
Reference in New Issue
Block a user