2022-07-21 01:00:17 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Deploy nomad configuration
|
2022-08-09 13:00:15 +02:00
|
|
|
block:
|
|
|
|
- name: Deploy nomad configuration
|
|
|
|
template:
|
|
|
|
src: nomad.hcl.j2
|
|
|
|
dest: "{{ nomad_root_dir }}/etc/nomad.hcl"
|
|
|
|
owner: root
|
|
|
|
group: "{{ nomad_user }}"
|
|
|
|
mode: 0640
|
|
|
|
backup: True
|
|
|
|
register: nomad_main_conf
|
|
|
|
notify: restart nomad
|
|
|
|
|
|
|
|
- name: Deploy nomad reloadable configuration
|
|
|
|
template:
|
|
|
|
src: reload.hcl.j2
|
|
|
|
dest: "{{ nomad_root_dir }}/etc/reload.hcl"
|
|
|
|
owner: root
|
|
|
|
group: "{{ nomad_user }}"
|
|
|
|
mode: 0640
|
|
|
|
backup: True
|
|
|
|
register: nomad_reload_conf
|
|
|
|
notify: reload nomad
|
|
|
|
|
|
|
|
- name: Validate configuration
|
|
|
|
command: nomad config validate {{ nomad_root_dir }}/etc/nomad.hcl {{ nomad_root_dir }}/etc/reload.hcl
|
|
|
|
changed_when: False
|
|
|
|
become_user: "{{ nomad_user }}"
|
|
|
|
register: nomad_conf_validation
|
|
|
|
|
|
|
|
rescue:
|
|
|
|
- block:
|
|
|
|
- name: Restore main configuration
|
|
|
|
copy:
|
|
|
|
src: "{{ nomad_main_conf.backup_file }}"
|
|
|
|
dest: "{{ nomad_root_dir }}/etc/nomad.hcl"
|
|
|
|
remote_src: True
|
|
|
|
owner: root
|
|
|
|
group: "{{ nomad_user }}"
|
|
|
|
mode: 0640
|
|
|
|
when: nomad_main_conf.backup_file is defined
|
|
|
|
|
|
|
|
- name: Restore reloadable configuration
|
|
|
|
copy:
|
|
|
|
src: "{{ nomad_reload_conf.backup_file }}"
|
|
|
|
dest: "{{ nomad_root_dir }}/etc/reload.hcl"
|
|
|
|
remote_src: True
|
|
|
|
owner: root
|
|
|
|
group: "{{ nomad_user }}"
|
|
|
|
mode: 0640
|
|
|
|
when: nomad_reload_conf.backup_file is defined
|
|
|
|
|
2022-07-21 01:00:17 +02:00
|
|
|
tags: nomad
|
2022-08-09 13:00:15 +02:00
|
|
|
|
|
|
|
- name: Fail if configuration validation failed
|
|
|
|
fail:
|
|
|
|
msg: "Failed to validate configuration: {{ nomad_conf_validation.stdout }}"
|
|
|
|
when: nomad_conf_validation.rc != 0
|
|
|
|
tags: nomad
|
|
|
|
|