Files
CoM-c2itall/Linode/cleanup.yml
T
2025-04-11 09:56:44 -04:00

44 lines
1.5 KiB
YAML

# Linode/cleanup.yml
---
- name: Clean up Linode infrastructure
hosts: localhost
connection: local
gather_facts: false
vars_files:
- vars.yaml
vars:
cleanup_redirector: "{{ (redirector_name is defined and redirector_name != '') | ternary(true, false) }}"
cleanup_c2: "{{ (c2_name is defined and c2_name != '') | ternary(true, false) }}"
confirm_cleanup: "{{ confirm_cleanup | default(true) }}"
tasks:
- name: Validate required Linode token
assert:
that:
- linode_token is defined and linode_token != ""
fail_msg: "Linode API token is required. Set linode_token in vars.yaml or via --linode-token."
- name: Cleanup resources notice
debug:
msg: |
===============================================
CLEANUP CONFIRMATION REQUIRED
===============================================
The following resources will be PERMANENTLY DELETED:
{% if cleanup_redirector %}
- Redirector instance: {{ redirector_name }}
{% endif %}
{% if cleanup_c2 %}
- C2 instance: {{ c2_name }}
{% endif %}
when: confirm_cleanup | bool
- name: Confirm cleanup
pause:
prompt: "Type 'yes' to confirm deletion or 'no' to abort"
register: confirmation
when: confirm_cleanup | bool
- name: Exit if not confirmed
meta: end_play
when: confirm_cleanup | bool and confirmation.user_input != 'yes'