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,76 @@
|
||||
---
|
||||
# Nomad Installation Role
|
||||
|
||||
- name: Install dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
- apt-transport-https
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- 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 Nomad
|
||||
ansible.builtin.apt:
|
||||
name: "nomad={{ nomad_version }}-1"
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Create Nomad directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: nomad
|
||||
group: nomad
|
||||
mode: '0755'
|
||||
loop:
|
||||
- "{{ nomad_data_dir }}"
|
||||
- "{{ nomad_data_dir }}/data"
|
||||
- /etc/nomad.d
|
||||
|
||||
- name: Configure Nomad
|
||||
ansible.builtin.template:
|
||||
src: nomad.hcl.j2
|
||||
dest: /etc/nomad.d/nomad.hcl
|
||||
owner: nomad
|
||||
group: nomad
|
||||
mode: '0640'
|
||||
notify: Restart Nomad
|
||||
|
||||
- name: Configure Nomad server (if server)
|
||||
ansible.builtin.template:
|
||||
src: server.hcl.j2
|
||||
dest: /etc/nomad.d/server.hcl
|
||||
owner: nomad
|
||||
group: nomad
|
||||
mode: '0640'
|
||||
when: nomad_server | default(false)
|
||||
notify: Restart Nomad
|
||||
|
||||
- name: Configure Nomad client
|
||||
ansible.builtin.template:
|
||||
src: client.hcl.j2
|
||||
dest: /etc/nomad.d/client.hcl
|
||||
owner: nomad
|
||||
group: nomad
|
||||
mode: '0640'
|
||||
when: nomad_client | default(false)
|
||||
notify: Restart Nomad
|
||||
|
||||
- name: Enable and start Nomad
|
||||
ansible.builtin.systemd:
|
||||
name: nomad
|
||||
enabled: yes
|
||||
state: started
|
||||
Reference in New Issue
Block a user