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

57 lines
1.6 KiB
YAML
Raw Permalink Normal View History

---
2024-10-06 10:17:45 +00:00
# task/main file for nomad
- name: "Nomad | Set reload-check & restart-check variable"
ansible.builtin.set_fact:
_nomad_service_need_daemon_reload: false
_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
when: _nomad_service_need_daemon_reload
- name: "Nomad | Start service: {{ nomad_service_name }}"
ansible.builtin.service:
name: "{{ nomad_service_name }}"
state: restarted
throttle: 1
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