2022-09-16 23:46:37 +00:00
|
|
|
---
|
2022-11-18 16:58:20 +00:00
|
|
|
- name: Stop Nomad
|
|
|
|
hosts: nomad_instances
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Stop Nomad
|
|
|
|
systemd:
|
|
|
|
name: nomad
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Stop Vault
|
2023-01-07 22:08:55 +00:00
|
|
|
hosts: vault_instances
|
2023-03-17 18:46:20 +00:00
|
|
|
gather_facts: false
|
2022-11-18 16:58:20 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Stop Vault
|
|
|
|
systemd:
|
|
|
|
name: vault
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
2022-11-15 07:10:16 +00:00
|
|
|
- name: Recover Consul
|
2022-09-16 23:46:37 +00:00
|
|
|
hosts: consul_instances
|
2023-03-17 18:46:20 +00:00
|
|
|
gather_facts: false
|
2022-09-16 23:46:37 +00:00
|
|
|
|
|
|
|
tasks:
|
2022-09-28 04:29:00 +00:00
|
|
|
- name: Stop Consul
|
2022-09-16 23:46:37 +00:00
|
|
|
systemd:
|
|
|
|
name: consul
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Get node-id
|
|
|
|
slurp:
|
|
|
|
src: /opt/consul/node-id
|
|
|
|
register: consul_node_id
|
|
|
|
become: true
|
|
|
|
|
2022-11-10 18:15:30 +00:00
|
|
|
- name: Node Info
|
2022-09-16 23:46:37 +00:00
|
|
|
debug:
|
2022-11-10 18:15:30 +00:00
|
|
|
msg: |
|
2023-01-07 22:03:31 +00:00
|
|
|
node_id: {{ consul_node_id.content | b64decode }}
|
2022-11-10 18:15:30 +00:00
|
|
|
address: {{ ansible_default_ipv4.address }}
|
2022-09-16 23:46:37 +00:00
|
|
|
|
|
|
|
- name: Save
|
|
|
|
copy:
|
|
|
|
dest: "/opt/consul/raft/peers.json"
|
2022-11-10 18:15:30 +00:00
|
|
|
# I used to have reject('equalto', inventory_hostname) in the loop, but I'm not sure if I should
|
2022-09-16 23:46:37 +00:00
|
|
|
content: |
|
|
|
|
[
|
2022-11-10 18:15:30 +00:00
|
|
|
{% for host in ansible_play_hosts -%}
|
2022-09-16 23:46:37 +00:00
|
|
|
{
|
2023-01-07 22:03:31 +00:00
|
|
|
"id": "{{ hostvars[host].consul_node_id.content | b64decode }}",
|
2022-09-16 23:46:37 +00:00
|
|
|
"address": "{{ hostvars[host].ansible_default_ipv4.address }}:8300",
|
|
|
|
"non_voter": false
|
|
|
|
}{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor -%}
|
|
|
|
]
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Restart Consul
|
|
|
|
systemd:
|
|
|
|
name: consul
|
|
|
|
state: restarted
|
|
|
|
become: true
|
2022-11-18 16:58:20 +00:00
|
|
|
|
|
|
|
- name: Start Vault
|
2023-01-07 22:08:55 +00:00
|
|
|
hosts: vault_instances
|
2023-03-17 18:46:20 +00:00
|
|
|
gather_facts: false
|
2022-11-18 16:58:20 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Start Vault
|
|
|
|
systemd:
|
|
|
|
name: vault
|
|
|
|
state: started
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Start Nomad
|
|
|
|
hosts: nomad_instances
|
2023-03-17 18:46:20 +00:00
|
|
|
gather_facts: false
|
2022-11-18 16:58:20 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Start Nomad
|
|
|
|
systemd:
|
|
|
|
name: nomad
|
|
|
|
state: started
|
|
|
|
become: true
|