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,66 @@
|
||||
---
|
||||
# Install HashiCorp Stack (Nomad, Consul, Vault)
|
||||
# Run: ansible-playbook -i inventory/hosts.yml playbooks/hashicorp-stack.yml
|
||||
|
||||
- name: Install Consul
|
||||
hosts: consul_servers:consul_clients
|
||||
become: yes
|
||||
roles:
|
||||
- consul
|
||||
tags: [consul]
|
||||
|
||||
- name: Install Vault
|
||||
hosts: vault_servers
|
||||
become: yes
|
||||
roles:
|
||||
- vault
|
||||
tags: [vault]
|
||||
|
||||
- name: Install Nomad
|
||||
hosts: nomad_servers:nomad_clients
|
||||
become: yes
|
||||
roles:
|
||||
- nomad
|
||||
tags: [nomad]
|
||||
|
||||
- name: Bootstrap Nomad cluster
|
||||
hosts: nomad_servers[0]
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Wait for Nomad to be ready
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ ansible_host }}:4646/v1/status/leader"
|
||||
method: GET
|
||||
status_code: 200
|
||||
register: nomad_leader
|
||||
until: nomad_leader.status == 200
|
||||
retries: 30
|
||||
delay: 5
|
||||
|
||||
- name: Display Nomad leader
|
||||
ansible.builtin.debug:
|
||||
msg: "Nomad leader: {{ nomad_leader.json }}"
|
||||
tags: [nomad, bootstrap]
|
||||
|
||||
- name: Verify cluster health
|
||||
hosts: nomad_servers[0]
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Check Nomad node status
|
||||
ansible.builtin.command: nomad node status
|
||||
register: nomad_nodes
|
||||
changed_when: false
|
||||
|
||||
- name: Display nodes
|
||||
ansible.builtin.debug:
|
||||
var: nomad_nodes.stdout_lines
|
||||
|
||||
- name: Check Consul members
|
||||
ansible.builtin.command: consul members
|
||||
register: consul_members
|
||||
changed_when: false
|
||||
|
||||
- name: Display Consul members
|
||||
ansible.builtin.debug:
|
||||
var: consul_members.stdout_lines
|
||||
tags: [verify]
|
||||
Reference in New Issue
Block a user