-
Notifications
You must be signed in to change notification settings - Fork 3
/
mailcow-delete-server.yml
60 lines (54 loc) · 1.81 KB
/
mailcow-delete-server.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Delete Server
gather_facts: false
connection: local
hosts: 127.0.0.1
tasks:
- name: Install hcloud pip library
pip:
name: hcloud
state: present
- name: Gather hcloud server infos
hcloud_server_info:
api_token: "{{ vault__hcloud__token }}"
register: hetzner_cloud_stats
- name: Delete mailcow integration test server
hetzner.hcloud.hcloud_server:
name: "{{ item.name }}"
location: "{{ item.datacenter }}"
state: absent
api_token: "{{ vault__hcloud__token }}"
when: "'{{ ci_hcloud_server_name }}' in item.name"
loop: "{{ hetzner_cloud_stats.hcloud_server_info }}"
no_log: yes
- name: Delete SSH Key from hcloud
hetzner.hcloud.hcloud_ssh_key:
name: "{{ item.name }}"
state: absent
api_token: "{{ vault__hcloud__token }}"
when: "'{{ ci_hcloud_server_name }}' in item.name"
loop: "{{ hetzner_cloud_stats.hcloud_server_info }}"
no_log: yes
- name: "Delete a record for {{ mailcow__hostname }}"
community.general.cloudflare_dns:
state: absent
zone: "{{ mailcow__dns_zone }}"
record: "{{ mailcow__hostname_local_part }}"
type: A
api_token: "{{ vault__cloudflare__apitoken }}"
- name: "Delete aaaa record for {{ mailcow__hostname }}"
community.general.cloudflare_dns:
state: absent
zone: "{{ mailcow__dns_zone }}"
record: "{{ mailcow__hostname_local_part }}"
type: AAAA
api_token: "{{ vault__cloudflare__apitoken }}"
- name: "Delete mx record for {{ mailcow__hostname }}"
community.general.cloudflare_dns:
state: absent
zone: "{{ mailcow__dns_zone }}"
record: "{{ mailcow__test_domain_local_part }}"
priority: 10
type: MX
value: "{{ mailcow__hostname }}"
api_token: "{{ vault__cloudflare__apitoken }}"