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,6 @@
|
||||
---
|
||||
- name: Restart Consul
|
||||
ansible.builtin.systemd:
|
||||
name: consul
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
# Consul Installation Role
|
||||
|
||||
- name: Add HashiCorp GPG key
|
||||
ansible.builtin.apt_key:
|
||||
url: https://apt.releases.hashicorp.com/gpg
|
||||
state: present
|
||||
|
||||
- name: Add HashiCorp repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main"
|
||||
state: present
|
||||
filename: hashicorp
|
||||
|
||||
- name: Install Consul
|
||||
ansible.builtin.apt:
|
||||
name: "consul={{ consul_version }}-1"
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Create Consul directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: consul
|
||||
group: consul
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ consul_data_dir }}"
|
||||
- "{{ consul_data_dir }}/data"
|
||||
- /etc/consul.d
|
||||
|
||||
- name: Configure Consul
|
||||
ansible.builtin.template:
|
||||
src: consul.hcl.j2
|
||||
dest: /etc/consul.d/consul.hcl
|
||||
owner: consul
|
||||
group: consul
|
||||
mode: '0640'
|
||||
notify: Restart Consul
|
||||
|
||||
- name: Configure Consul server (if server)
|
||||
ansible.builtin.template:
|
||||
src: server.hcl.j2
|
||||
dest: /etc/consul.d/server.hcl
|
||||
owner: consul
|
||||
group: consul
|
||||
mode: '0640'
|
||||
when: consul_server | default(false)
|
||||
notify: Restart Consul
|
||||
|
||||
- name: Enable and start Consul
|
||||
ansible.builtin.systemd:
|
||||
name: consul
|
||||
enabled: yes
|
||||
state: started
|
||||
@@ -0,0 +1,34 @@
|
||||
# Consul Configuration
|
||||
# Managed by Ansible
|
||||
|
||||
datacenter = "{{ datacenter }}"
|
||||
data_dir = "{{ consul_data_dir }}/data"
|
||||
node_name = "{{ inventory_hostname }}"
|
||||
|
||||
bind_addr = "{{ ansible_host }}"
|
||||
client_addr = "0.0.0.0"
|
||||
|
||||
ui_config {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# DNS settings
|
||||
dns_config {
|
||||
allow_stale = true
|
||||
}
|
||||
|
||||
# Service mesh
|
||||
connect {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
# Telemetry
|
||||
telemetry {
|
||||
prometheus_retention_time = "24h"
|
||||
disable_hostname = true
|
||||
}
|
||||
|
||||
# Performance
|
||||
performance {
|
||||
raft_multiplier = 1
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Consul Server Configuration
|
||||
|
||||
server = true
|
||||
bootstrap_expect = {{ consul_bootstrap_expect | default(1) }}
|
||||
|
||||
# Raft settings
|
||||
raft_protocol = 3
|
||||
|
||||
# Autopilot
|
||||
autopilot {
|
||||
cleanup_dead_servers = true
|
||||
last_contact_threshold = "200ms"
|
||||
max_trailing_logs = 250
|
||||
server_stabilization_time = "10s"
|
||||
}
|
||||
Reference in New Issue
Block a user