Bertrand Lanson
63f22bb1f9
This feature adds logic to automatically reload the nomad service if tls is enbabled and the certificates have changed. This only tracks certificates copied by the extra_files logic.
57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
---
|
|
# 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
|