2024-07-19 21:32:24 +00:00
|
|
|
---
|
2024-10-06 10:17:45 +00:00
|
|
|
# task/main file for nomad
|
2024-07-19 21:32:24 +00:00
|
|
|
- name: "Nomad | Set reload-check & restart-check variable"
|
|
|
|
ansible.builtin.set_fact:
|
2024-11-10 12:32:45 +00:00
|
|
|
_nomad_service_need_daemon_reload: false
|
2024-07-19 21:32:24 +00:00
|
|
|
_nomad_service_need_reload: false
|
|
|
|
_nomad_service_need_restart: false
|
|
|
|
|
|
|
|
- name: "Nomad | Import merge_variables.yml"
|
|
|
|
ansible.builtin.include_tasks: merge_variables.yml
|
|
|
|
|
|
|
|
- name: "Nomad | Import prerequisites.yml"
|
|
|
|
ansible.builtin.include_tasks: prerequisites.yml
|
|
|
|
|
|
|
|
- name: "Nomad | Import install.yml"
|
|
|
|
ansible.builtin.include_tasks: install.yml
|
|
|
|
|
|
|
|
- name: "Nomad | Import configure.yml"
|
|
|
|
ansible.builtin.include_tasks: configure.yml
|
|
|
|
|
|
|
|
- name: "Nomad | Populate service facts"
|
|
|
|
ansible.builtin.service_facts:
|
|
|
|
|
|
|
|
- name: "Nomad | Set restart-check variable"
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
_nomad_service_need_restart: true
|
|
|
|
when: ansible_facts.services[nomad_service_name~'.service'].state != 'running'
|
|
|
|
|
|
|
|
- name: "Nomad | Enable service: {{ nomad_service_name }}"
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ nomad_service_name }}"
|
|
|
|
enabled: true
|
|
|
|
|
|
|
|
- name: "Nomad | Reload systemd daemon"
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: true
|
2024-11-10 12:32:45 +00:00
|
|
|
when: _nomad_service_need_daemon_reload
|
2024-07-19 21:32:24 +00:00
|
|
|
|
|
|
|
- name: "Nomad | Start service: {{ nomad_service_name }}"
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ nomad_service_name }}"
|
|
|
|
state: restarted
|
|
|
|
throttle: 1
|
2024-11-10 12:32:45 +00:00
|
|
|
when:
|
|
|
|
- nomad_start_service
|
|
|
|
- _nomad_service_need_restart
|
|
|
|
|
|
|
|
- name: "Nomad | Reload service: {{ nomad_service_name }}"
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ nomad_service_name }}"
|
|
|
|
state: reloaded
|
|
|
|
throttle: 1
|
|
|
|
when:
|
|
|
|
- nomad_start_service
|
|
|
|
- _nomad_service_need_reload
|
|
|
|
- not _nomad_service_need_restart
|