From c6f1686db8ed0782ffd90dce17a3c46e23157dcc Mon Sep 17 00:00:00 2001 From: Sandwich Date: Thu, 31 Oct 2024 18:27:31 +0100 Subject: [PATCH] Preper Shutdown so VMware does not corrupt the installation --- main.yml | 8 -------- roles/cleanup/tasks/main.yml | 24 ++++++++---------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/main.yml b/main.yml index fcf8be4..560e050 100644 --- a/main.yml +++ b/main.yml @@ -78,11 +78,3 @@ when: install_type == "virtual" vars: ansible_connection: local - - tasks: - - name: Reboot system - when: hypervisor == "proxmox" - ansible.builtin.command: reboot - failed_when: false - changed_when: result.rc == 0 - register: result diff --git a/roles/cleanup/tasks/main.yml b/roles/cleanup/tasks/main.yml index 258517d..7fa9dbc 100644 --- a/roles/cleanup/tasks/main.yml +++ b/roles/cleanup/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: Shutdown the VM + community.general.shutdown: + - name: Setup Cleanup when: hypervisor == "proxmox" delegate_to: localhost @@ -17,22 +20,16 @@ - ide0 - ide2 + - name: Reboot system + ansible.builtin.command: reboot + failed_when: false + changed_when: false + - name: Clean vCenter VM when: hypervisor == "vmware" delegate_to: localhost become: false block: - - name: Shutdown VM in vCenter - when: hypervisor == "vmware" - community.vmware.vmware_guest_powerstate: - hostname: "{{ hypervisor_url }}" - username: "{{ hypervisor_username }}" - password: "{{ hypervisor_password }}" - validate_certs: false - datacenter: "{{ hypervisor_cluster }}" - name: "{{ hostname }}" - state: powered-off - - name: Remove CD-ROM from VM in vCenter when: hypervisor == "vmware" failed_when: false @@ -73,11 +70,6 @@ delegate_to: localhost become: false block: - - name: Stop the VM - community.libvirt.virt: - name: "{{ hostname }}" - state: shutdown - - name: Remove cloud-init disk ansible.builtin.file: path: "{{ vm_path | default('/var/lib/libvirt/images/') }}{{ hostname }}-cloudinit.iso"