2022-11-10 21:34:01 +00:00
|
|
|
# Stops Consul, Vault, and Nomad and clears all data from their data dirs
|
2022-09-28 04:28:37 +00:00
|
|
|
---
|
|
|
|
- name: Delete Consul data
|
|
|
|
hosts: consul_instances
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Stop consul
|
|
|
|
systemd:
|
|
|
|
name: consul
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Stop vault
|
|
|
|
systemd:
|
2022-11-10 21:34:01 +00:00
|
|
|
name: vault
|
2022-09-28 04:28:37 +00:00
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Remove data dir
|
|
|
|
file:
|
|
|
|
path: /opt/consul
|
|
|
|
state: absent
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Delete Nomad data
|
|
|
|
hosts: nomad_instances
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Stop nomad
|
|
|
|
systemd:
|
|
|
|
name: nomad
|
|
|
|
state: stopped
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Kill nomad
|
|
|
|
shell:
|
|
|
|
cmd: systemctl kill nomad
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Stop all containers
|
|
|
|
shell:
|
|
|
|
cmd: docker ps -a | awk '/^[0-9abcdef]/{print $1}' | xargs -r docker stop
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Remove all containers
|
|
|
|
shell:
|
|
|
|
cmd: docker ps -a | awk '/^[0-9abcdef]/{print $1}' | xargs -r docker rm
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Unmount secrets
|
|
|
|
shell:
|
|
|
|
cmd: mount | awk '/nomad/ {print $3}' | xargs -n1 -r umount
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Remove data dir
|
|
|
|
file:
|
|
|
|
path: /var/nomad
|
|
|
|
state: absent
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Remove data dir
|
|
|
|
file:
|
|
|
|
path: /opt/nomad/data
|
|
|
|
state: absent
|
|
|
|
become: true
|