From 07492b5b57308ea51aaec6881977fcad165e87c2 Mon Sep 17 00:00:00 2001 From: Sandwich Date: Fri, 20 Feb 2026 23:02:24 +0100 Subject: [PATCH] refactor(cleanup): add configurable verify_boot, boot_timeout, and remove_on_failure defaults --- roles/cleanup/defaults/main.yml | 6 ++++++ roles/cleanup/tasks/virtual.yml | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/roles/cleanup/defaults/main.yml b/roles/cleanup/defaults/main.yml index 2145505..cdeb7b0 100644 --- a/roles/cleanup/defaults/main.yml +++ b/roles/cleanup/defaults/main.yml @@ -1,4 +1,10 @@ --- +# Post-reboot verification +cleanup_verify_boot: true +cleanup_boot_timeout: 300 +cleanup_remove_on_failure: true + +# Libvirt paths cleanup_libvirt_image_dir: >- {{ system_cfg.path diff --git a/roles/cleanup/tasks/virtual.yml b/roles/cleanup/tasks/virtual.yml index aed1ce9..0c9df8f 100644 --- a/roles/cleanup/tasks/virtual.yml +++ b/roles/cleanup/tasks/virtual.yml @@ -28,19 +28,21 @@ - name: Check VM accessibility after reboot when: + - cleanup_verify_boot | bool - system_cfg.type == "virtual" - cleanup_post_reboot_can_connect | bool block: - name: Attempt to connect to VM delegate_to: "{{ inventory_hostname }}" ansible.builtin.wait_for_connection: - timeout: 300 + timeout: "{{ cleanup_boot_timeout }}" register: cleanup_vm_connection_check failed_when: false changed_when: false - name: VM failed to boot - initiate cleanup when: + - cleanup_remove_on_failure | bool - cleanup_vm_connection_check is defined - cleanup_vm_connection_check.failed | bool - virtualization_vm_created_in_run | default(false) | bool