improve VMware cleanup
This commit is contained in:
parent
d92944c345
commit
ccf3193c92
2
main.yml
2
main.yml
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Reboot system
|
- name: Reboot system
|
||||||
when: hypervisor != "libvirt"
|
when: hypervisor == "proxmox"
|
||||||
ansible.builtin.command: reboot
|
ansible.builtin.command: reboot
|
||||||
failed_when: false
|
failed_when: false
|
||||||
changed_when: result.rc == 0
|
changed_when: result.rc == 0
|
||||||
|
@ -22,10 +22,24 @@
|
|||||||
- ide0
|
- ide0
|
||||||
- ide2
|
- ide2
|
||||||
|
|
||||||
- name: Remove CD-ROM from VM in vCenter
|
- name: Clean vCenter VM
|
||||||
when: hypervisor == "vmware"
|
when: hypervisor == "vmware"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
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
|
failed_when: false
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
hostname: "{{ hypervisor_url }}"
|
hostname: "{{ hypervisor_url }}"
|
||||||
@ -48,6 +62,17 @@
|
|||||||
iso_path: "{{ rhel_iso | default(omit) }}"
|
iso_path: "{{ rhel_iso | default(omit) }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Start 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-on
|
||||||
|
|
||||||
- name: Remove Archiso and cloud-init disks
|
- name: Remove Archiso and cloud-init disks
|
||||||
when: hypervisor == "libvirt"
|
when: hypervisor == "libvirt"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
Loading…
Reference in New Issue
Block a user