This commit is contained in:
n0mad1k
2025-04-11 10:12:48 -04:00
parent a7490bd655
commit 7962c574de
3 changed files with 172 additions and 68 deletions
+1 -1
View File
@@ -77,7 +77,7 @@
name: "c2"
groups: "c2servers"
ansible_host: "{{ c2_ip }}"
ansible_user: "{{ ssh_user }}"
ansible_user: "root" # Hard-coded instead of using ssh_user
ansible_ssh_private_key_file: "{{ ssh_key_path | replace('.pub', '') }}"
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
+39 -10
View File
@@ -1,5 +1,5 @@
# Linode/cleanup.yml
---
# Linode/cleanup.yml
- name: Clean up Linode infrastructure
hosts: localhost
connection: local
@@ -22,23 +22,52 @@
debug:
msg: |
===============================================
CLEANUP CONFIRMATION REQUIRED
CLEANUP OPERATION
===============================================
The following resources will be PERMANENTLY DELETED:
{% if cleanup_redirector %}
The following resources will be DELETED PERMANENTLY:
{% if cleanup_redirector and redirector_name is defined %}
- Redirector instance: {{ redirector_name }}
{% endif %}
{% if cleanup_c2 %}
{% if cleanup_c2 and c2_name is defined %}
- C2 instance: {{ c2_name }}
{% endif %}
when: confirm_cleanup | bool
- name: Confirm cleanup
- name: Confirm cleanup operation
pause:
prompt: "Type 'yes' to confirm deletion or 'no' to abort"
prompt: "\n>>> Type 'yes' to confirm deletion or press Ctrl+C to abort <<<"
register: confirmation
when: confirm_cleanup | bool
- name: Exit if not confirmed
- name: Skip cleanup if not confirmed
meta: end_play
when: confirm_cleanup | bool and confirmation.user_input != 'yes'
when: confirm_cleanup | bool and (confirmation.user_input | default('')) != 'yes'
- name: Delete redirector instance
community.general.linode_v4:
access_token: "{{ linode_token }}"
label: "{{ redirector_name }}"
state: absent
when: cleanup_redirector and redirector_name is defined and redirector_name != ""
register: redirector_deletion
ignore_errors: yes
- name: Delete C2 instance
community.general.linode_v4:
access_token: "{{ linode_token }}"
label: "{{ c2_name }}"
state: absent
when: cleanup_c2 and c2_name is defined and c2_name != ""
register: c2_deletion
ignore_errors: yes
- name: Report cleanup status
debug:
msg: |
Cleanup results:
{% if redirector_deletion is defined %}
- Redirector {{ redirector_name }}: {{ redirector_deletion.changed | ternary('Deleted', 'Not found/Could not delete') }}
{% endif %}
{% if c2_deletion is defined %}
- C2 {{ c2_name }}: {{ c2_deletion.changed | ternary('Deleted', 'Not found/Could not delete') }}
{% endif %}