3d3c1af237
- 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
57 lines
1.3 KiB
YAML
57 lines
1.3 KiB
YAML
---
|
|
# 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
|