-
Notifications
You must be signed in to change notification settings - Fork 0
/
linode_destroy.yml
45 lines (36 loc) · 1.13 KB
/
linode_destroy.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
---
- hosts: localhost
connection: local
vars_prompt:
- name: prompt_linode_label
prompt: What is the label of the linode you want to delete?
private: no
tasks:
- name: Deleting {{ prompt_linode_label }}!
ansible.builtin.debug:
msg: 'Deleting {{ prompt_linode_label }}, hope that is what you wanted'
- name: pip install linode_api4
pip:
name: linode_api4
- name: Ensure linode is missing (delete if present)
linode_v4:
label: "{{ prompt_linode_label }}"
access_token: "{{ maximum_ethics_linode_token }}"
state: absent
# https://docs.ansible.com/ansible/latest/modules/known_hosts_module.html
- name: Remove hostname from ~/.ssh/known_hosts
known_hosts:
name: '{{ prompt_linode_label }}'
state: absent
- name: Remove lines with unwanted occurrences of hostname
lineinfile:
path: "{{ inventory_directory }}/hosts"
regexp: '^{{ prompt_linode_label }}$'
state: absent
become: true
- name: Remove from /etc/hosts
lineinfile:
path: "/etc/hosts"
regexp: '{{ prompt_linode_label }}$'
state: absent
become: true