refactor ♻️: Refactored all task files to use centralized helper functions from tasks/helpers.yml, improving code consistency, maintainability, and idempotency.

All task files now use centralized helper functions, ensuring idempotency across all stages. Code is cleaner, more maintainable, and no breaking changes were introduced.
This commit is contained in:
2025-11-18 20:24:43 +01:00
parent 833ceb93d4
commit d171a4a7b9
5 changed files with 33 additions and 252 deletions

View File

@@ -147,3 +147,20 @@
- "/var/lib/vz/snippets/{{ target_vm_id }}-sshkey.pub"
when: helper_task == "cleanup_snippets"
##################################################################
# CHECK IF DISK IS ATTACHED
##################################################################
- name: "[HELPER] Check if disk is attached to VM"
block:
- name: "[HELPER] Query VM config for disk attachment"
ansible.builtin.shell: "qm config {{ target_vm_id }} | grep -q '^scsi0:'"
changed_when: false
failed_when: false
register: disk_check
- name: "[HELPER] Set fact: disk_attached"
ansible.builtin.set_fact:
disk_attached: "{{ disk_check.rc == 0 }}"
when: helper_task == "check_disk_attached"