ansible-nas/roles/nomad/tasks/main.yml

58 lines
1.5 KiB
YAML
Raw Normal View History

2022-11-08 23:03:01 +00:00
---
- name: Install and start Nomad
block:
- name: Add Hashicorp GPG key
2023-03-09 20:47:42 +00:00
ansible.builtin.get_url:
2022-11-08 23:03:01 +00:00
url: https://apt.releases.hashicorp.com/gpg
2023-03-09 20:47:42 +00:00
dest: /etc/apt/trusted.gpg.d/hashicorp.asc
mode: '0644'
force: true
2022-11-08 23:03:01 +00:00
- 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
2022-11-10 22:27:02 +00:00
notify: restart nomad
2022-11-08 23:03:01 +00:00
- name: Start Nomad
ansible.builtin.systemd:
name: "{{ nomad_service_name }}"
state: started
enabled: yes
when: nomad_enabled is true
- name: Stop Nomad
block:
2023-01-31 00:13:44 +00:00
- name: Check if Nomad is installed
2023-04-18 20:58:54 +00:00
ansible.builtin.stat:
2023-01-31 00:13:44 +00:00
path: /usr/bin/nomad
register: nomad_install
2023-02-18 15:35:37 +00:00
- name: Stop and Uninstall Nomad
block:
2023-02-05 23:26:12 +00:00
- name: Stop Nomad
ansible.builtin.systemd:
name: "{{ nomad_service_name }}"
state: stopped
enabled: no
daemon_reload: yes
- name: Uninstall Nomad
ansible.builtin.apt:
name: nomad
state: absent
2023-01-31 00:13:44 +00:00
when: nomad_install.stat.exists
2022-11-08 23:03:01 +00:00
when: nomad_enabled is false