ansible-nas/roles/nomad/tasks/main.yml
David Stephens c367740b8e Add Nomad
2022-11-08 23:03:01 +00:00

39 lines
1,008 B
YAML

---
- name: Install and start Nomad
block:
- name: Add Hashicorp GPG key
ansible.builtin.apt_key:
url: https://apt.releases.hashicorp.com/gpg
state: present
- name: Add Hashicorp apt repository
ansible.builtin.apt_repository:
repo: "deb https://apt.releases.hashicorp.com {{ ansible_facts['lsb']['codename'] }} main"
state: present
filename: hashicorp
- name: Install Nomad
ansible.builtin.apt:
name: nomad
state: present
- name: Template Nomad config
ansible.builtin.template:
src: nomad.hcl
dest: /etc/nomad.d/nomad.hcl
- name: Start Nomad
ansible.builtin.systemd:
name: "{{ nomad_service_name }}"
state: started
enabled: yes
when: nomad_enabled is true
- name: Stop Nomad
block:
- name: Stop Nomad
ansible.builtin.systemd:
name: "{{ nomad_service_name }}"
state: stopped
enabled: no
when: nomad_enabled is false