DEV-553: added remove hcloud volumes at the end of restore playbook
parent
659943ccc5
commit
1a529cf787
@ -0,0 +1,39 @@
|
||||
---
|
||||
|
||||
- name: "Getting all hcloud volumes for {{ inventory_hostname }}"
|
||||
hcloud_volume_info:
|
||||
api_token: "{{ hetzner_authentication_ansible }}"
|
||||
label_selector: "stage={{ stage }},bound_on={{ inventory_hostname }}"
|
||||
register: hcloud_volumes_found
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: "Getting all hcloud volumes for {{ inventory_hostname }}"
|
||||
debug:
|
||||
msg: "{{ hcloud_volumes_found }}"
|
||||
|
||||
- name: "Setting all hcloud volumes for {{ inventory_hostname }}"
|
||||
set_fact:
|
||||
hcloud_volumes: "{{ hcloud_volumes_found.hcloud_volume_info | json_query(jmesquery) }}"
|
||||
vars:
|
||||
jmesquery: "[*].name"
|
||||
|
||||
- name: "remove delete protection for all hcloud volumes for {{ inventory_hostname }}"
|
||||
hcloud_volume:
|
||||
api_token: "{{ hetzner_authentication_ansible }}"
|
||||
name: "{{ item }}"
|
||||
delete_protection: no
|
||||
delegate_to: 127.0.0.1
|
||||
loop: "{{ hcloud_volumes }}"
|
||||
|
||||
- name: "Delete all hcloud volumes for {{ inventory_hostname }}"
|
||||
hcloud_volume:
|
||||
api_token: "{{ hetzner_authentication_ansible }}"
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
delegate_to: 127.0.0.1
|
||||
loop: "{{ hcloud_volumes }}"
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue