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,117 @@
|
||||
# Hobbs.farm Infrastructure as Code
|
||||
|
||||
Enterprise-grade infrastructure management using HashiCorp stack + Ansible.
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ HOBBS.FARM IaC │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
||||
│ │ TERRAFORM │────▶│ ANSIBLE │────▶│ NOMAD │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ │ • Infra │ │ • Config │ │ • Deploy │ │
|
||||
│ │ • State │ │ • Install │ │ • Scale │ │
|
||||
│ │ • DNS │ │ • Secure │ │ • Monitor │ │
|
||||
│ └───────────┘ └───────────┘ └───────────┘ │
|
||||
│ │ │ │ │
|
||||
│ └────────────────┴────────────────┘ │
|
||||
│ │ │
|
||||
│ ┌───────────────────────┴───────────────────────┐ │
|
||||
│ │ HASHICORP STACK │ │
|
||||
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
|
||||
│ │ │ NOMAD │ │ CONSUL │ │ VAULT │ │ │
|
||||
│ │ │ orchest │◄─┤ service │◄─┤ secrets │ │ │
|
||||
│ │ │ ration │ │ mesh │ │ mgmt │ │ │
|
||||
│ │ └─────────┘ └─────────┘ └─────────┘ │ │
|
||||
│ └───────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
│ ┌─────────────────────────────────────────────────┐ │
|
||||
│ │ HOSTS │ │
|
||||
│ │ hf-pdocker-01 (primary) hf-pdocker-02 (secondary) │
|
||||
│ │ 192.168.86.192 192.168.86.45 │
|
||||
│ └─────────────────────────────────────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
hobbs-iac/
|
||||
├── terraform/ # Infrastructure provisioning
|
||||
│ ├── environments/ # Per-environment configs
|
||||
│ │ └── prod/
|
||||
│ ├── modules/ # Reusable modules
|
||||
│ └── nomad-jobs/ # Nomad job definitions (HCL)
|
||||
├── ansible/ # Configuration management
|
||||
│ ├── inventory/ # Host inventory
|
||||
│ ├── playbooks/ # Automation playbooks
|
||||
│ ├── roles/ # Ansible roles
|
||||
│ └── group_vars/ # Variables
|
||||
├── nomad/ # Nomad-specific configs
|
||||
│ ├── jobs/ # Job specifications
|
||||
│ ├── policies/ # ACL policies
|
||||
│ └── templates/ # Job templates
|
||||
├── consul/ # Consul configs
|
||||
│ ├── config/ # Consul configuration
|
||||
│ └── policies/ # ACL policies
|
||||
├── vault/ # Vault configs
|
||||
│ ├── policies/ # Access policies
|
||||
│ └── secrets/ # Secret definitions (encrypted)
|
||||
└── scripts/ # Utility scripts
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Bootstrap Hosts (Ansible)
|
||||
```bash
|
||||
cd ansible
|
||||
ansible-playbook -i inventory/hosts.yml playbooks/bootstrap.yml
|
||||
```
|
||||
|
||||
### 2. Install HashiCorp Stack
|
||||
```bash
|
||||
ansible-playbook -i inventory/hosts.yml playbooks/hashicorp-stack.yml
|
||||
```
|
||||
|
||||
### 3. Initialize Terraform
|
||||
```bash
|
||||
cd terraform/environments/prod
|
||||
terraform init
|
||||
terraform plan
|
||||
terraform apply
|
||||
```
|
||||
|
||||
### 4. Deploy Services
|
||||
```bash
|
||||
# Deploy all Nomad jobs
|
||||
nomad job run ../nomad-jobs/traefik.nomad
|
||||
nomad job run ../nomad-jobs/monitoring.nomad
|
||||
# ... etc
|
||||
```
|
||||
|
||||
## Naming Convention
|
||||
|
||||
See [Naming Convention Standard](docs/naming-convention.md)
|
||||
|
||||
| Type | Format | Example |
|
||||
|------|--------|---------|
|
||||
| Physical | `hf-p<function>-##` | `hf-pdocker-01` |
|
||||
| Virtual | `hf-v<function>-##` | `hf-vapp-01` |
|
||||
| Container | `hf-c<function>-##` | `hf-cproxy-01` |
|
||||
| Network | `hf-n<function>-##` | `hf-nfw-01` |
|
||||
| Storage | `hf-s<function>-##` | `hf-snas-01` |
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Ansible 2.15+
|
||||
- Terraform 1.5+
|
||||
- Nomad 1.6+
|
||||
- Consul 1.16+
|
||||
- Vault 1.15+
|
||||
|
||||
## License
|
||||
|
||||
Private - Hobbs.farm internal use only
|
||||
Reference in New Issue
Block a user