Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
IamTheFij | af05a96501 | |
IamTheFij | 754c4393f3 |
|
@ -0,0 +1,45 @@
|
||||||
|
---
|
||||||
|
- 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 Id
|
||||||
|
debug:
|
||||||
|
msg: "node_id: {{ nomad_node_id.content }}"
|
||||||
|
|
||||||
|
- name: Address
|
||||||
|
debug:
|
||||||
|
msg: "address: {{ ansible_default_ipv4.address }}"
|
||||||
|
|
||||||
|
- name: Save
|
||||||
|
copy:
|
||||||
|
dest: /var/nomad/server/raft/peers.json
|
||||||
|
content: |
|
||||||
|
[
|
||||||
|
{% for host in ansible_play_hosts|reject('equalto', inventory_hostname) -%}
|
||||||
|
{
|
||||||
|
"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
|
|
@ -6,9 +6,9 @@ resource "nomad_job" "backups" {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get Nomad clients from Consul
|
# Get Nomad clients from Consul
|
||||||
data "consul_service" "nomad" {
|
# data "consul_service" "nomad" {
|
||||||
name = "nomad-client"
|
# name = "nomad-client"
|
||||||
}
|
# }
|
||||||
|
|
||||||
resource "nomad_job" "backups-oneoff" {
|
resource "nomad_job" "backups-oneoff" {
|
||||||
# TODO: Get list of nomad hosts dynamically
|
# TODO: Get list of nomad hosts dynamically
|
||||||
|
|
Loading…
Reference in New Issue