2022-11-10 18:15:30 +00:00
|
|
|
---
|
2022-11-15 07:10:16 +00:00
|
|
|
- name: Recover Nomad
|
2022-11-10 18:15:30 +00:00
|
|
|
hosts: nomad_instances
|
2023-07-26 22:27:46 +00:00
|
|
|
any_errors_fatal: true
|
2022-11-10 18:15:30 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Stop Nomad
|
|
|
|
systemd:
|
|
|
|
name: nomad
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
2023-09-28 04:26:44 +00:00
|
|
|
- name: Remount all shares
|
|
|
|
command: mount -a
|
|
|
|
become: true
|
|
|
|
|
2022-11-10 18:15:30 +00:00
|
|
|
- name: Get node-id
|
|
|
|
slurp:
|
|
|
|
src: /var/nomad/server/node-id
|
|
|
|
register: nomad_node_id
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Node Info
|
|
|
|
debug:
|
|
|
|
msg: |
|
2023-01-07 22:09:19 +00:00
|
|
|
node_id: {{ nomad_node_id.content | b64decode }}
|
2022-11-10 18:15:30 +00:00
|
|
|
address: {{ ansible_default_ipv4.address }}
|
|
|
|
|
|
|
|
- name: Save
|
|
|
|
copy:
|
|
|
|
dest: /var/nomad/server/raft/peers.json
|
|
|
|
# I used to have reject('equalto', inventory_hostname) in the loop, but I'm not sure if I should
|
|
|
|
content: |
|
|
|
|
[
|
|
|
|
{% for host in ansible_play_hosts -%}
|
|
|
|
{
|
2023-01-07 22:09:19 +00:00
|
|
|
"id": "{{ hostvars[host].nomad_node_id.content | b64decode }}",
|
2022-11-10 18:15:30 +00:00
|
|
|
"address": "{{ hostvars[host].ansible_default_ipv4.address }}:4647",
|
|
|
|
"non_voter": false
|
|
|
|
}{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor -%}
|
|
|
|
]
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Restart Nomad
|
|
|
|
systemd:
|
|
|
|
name: nomad
|
|
|
|
state: restarted
|
|
|
|
become: true
|