2024-07-11 22:20:45 +02:00
|
|
|
---
|
2024-10-31 18:27:31 +01:00
|
|
|
- name: Shutdown the VM
|
|
|
|
community.general.shutdown:
|
2024-11-01 23:58:52 +01:00
|
|
|
vars:
|
|
|
|
ansible_connection: ssh
|
2024-10-31 18:27:31 +01:00
|
|
|
|
2024-10-31 01:12:51 +01:00
|
|
|
- name: Clean vCenter VM
|
2024-03-19 23:02:50 +01:00
|
|
|
delegate_to: localhost
|
2024-10-30 23:10:53 +01:00
|
|
|
become: false
|
2024-10-31 01:12:51 +01:00
|
|
|
block:
|
|
|
|
- name: Remove CD-ROM from VM in vCenter
|
|
|
|
when: hypervisor == "vmware"
|
|
|
|
failed_when: false
|
|
|
|
community.vmware.vmware_guest:
|
|
|
|
hostname: "{{ hypervisor_url }}"
|
|
|
|
username: "{{ hypervisor_username }}"
|
|
|
|
password: "{{ hypervisor_password }}"
|
|
|
|
validate_certs: false
|
|
|
|
datacenter: "{{ hypervisor_cluster }}"
|
|
|
|
name: "{{ hostname }}"
|
|
|
|
cdrom:
|
|
|
|
- controller_number: 0
|
|
|
|
unit_number: 0
|
|
|
|
controller_type: sata
|
|
|
|
type: iso
|
|
|
|
iso_path: "{{ boot_iso }}"
|
|
|
|
state: absent
|
|
|
|
- controller_number: 0
|
|
|
|
unit_number: 1
|
|
|
|
controller_type: sata
|
|
|
|
type: iso
|
|
|
|
iso_path: "{{ rhel_iso | default(omit) }}"
|
|
|
|
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
|