mirror of
https://github.com/davestephens/ansible-nas
synced 2025-01-13 03:58:47 +00:00
57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
---
|
|
- name: Install and start Nomad
|
|
block:
|
|
- name: Add Hashicorp GPG key
|
|
ansible.builtin.get_url:
|
|
url: https://apt.releases.hashicorp.com/gpg
|
|
dest: /etc/apt/trusted.gpg.d/hashicorp.asc
|
|
mode: '0644'
|
|
force: true
|
|
|
|
- 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
|
|
notify: restart nomad
|
|
|
|
- name: Start Nomad
|
|
ansible.builtin.systemd:
|
|
name: "{{ nomad_service_name }}"
|
|
state: started
|
|
enabled: yes
|
|
when: nomad_enabled is true
|
|
|
|
- name: Stop Nomad
|
|
block:
|
|
- name: Check if Nomad is installed
|
|
ansible.builtin.stat:
|
|
path: /usr/bin/nomad
|
|
register: nomad_install
|
|
|
|
- name: Stop and Uninstall Nomad
|
|
block:
|
|
- 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
|
|
|
|
when: nomad_install.stat.exists
|
|
when: nomad_enabled is false
|