Update recovery scripts
This commit is contained in:
parent
1fad6b691c
commit
51a0b71bd8
@ -15,20 +15,19 @@
|
|||||||
register: consul_node_id
|
register: consul_node_id
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Node Id
|
- name: Node Info
|
||||||
debug:
|
debug:
|
||||||
msg: "node_id: {{ consul_node_id.content }}"
|
msg: |
|
||||||
|
node_id: {{ consul_node_id.content }}
|
||||||
- name: Address
|
address: {{ ansible_default_ipv4.address }}
|
||||||
debug:
|
|
||||||
msg: "address: {{ ansible_default_ipv4.address }}"
|
|
||||||
|
|
||||||
- name: Save
|
- name: Save
|
||||||
copy:
|
copy:
|
||||||
dest: "/opt/consul/raft/peers.json"
|
dest: "/opt/consul/raft/peers.json"
|
||||||
|
# I used to have reject('equalto', inventory_hostname) in the loop, but I'm not sure if I should
|
||||||
content: |
|
content: |
|
||||||
[
|
[
|
||||||
{% for host in ansible_play_hosts|reject('equalto', inventory_hostname) -%}
|
{% for host in ansible_play_hosts -%}
|
||||||
{
|
{
|
||||||
"id": "{{ hostvars[host].consul_node_id.content }}",
|
"id": "{{ hostvars[host].consul_node_id.content }}",
|
||||||
"address": "{{ hostvars[host].ansible_default_ipv4.address }}:8300",
|
"address": "{{ hostvars[host].ansible_default_ipv4.address }}:8300",
|
||||||
|
44
ansible_playbooks/recover-nomad.yaml
Normal file
44
ansible_playbooks/recover-nomad.yaml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
- name: Recovery Nomad
|
||||||
|
hosts: nomad_instances
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Stop Nomad
|
||||||
|
systemd:
|
||||||
|
name: nomad
|
||||||
|
state: stopped
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Get node-id
|
||||||
|
slurp:
|
||||||
|
src: /var/nomad/server/node-id
|
||||||
|
register: nomad_node_id
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Node Info
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
node_id: {{ nomad_node_id.content }}
|
||||||
|
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 -%}
|
||||||
|
{
|
||||||
|
"id": "{{ hostvars[host].nomad_node_id.content }}",
|
||||||
|
"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
|
Loading…
Reference in New Issue
Block a user