--- - name: Clean vCenter VM when: hypervisor_type == "vmware" delegate_to: localhost become: false block: - name: Remove CD-ROM from VM in vCenter when: hypervisor_type == "vmware" community.vmware.vmware_guest: hostname: "{{ hypervisor_cfg.url }}" username: "{{ hypervisor_cfg.username }}" password: "{{ hypervisor_cfg.password }}" validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}" datacenter: "{{ hypervisor_cfg.datacenter }}" 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 if rhel_iso is defined and rhel_iso | length > 0 else omit }}" state: absent failed_when: false - name: Start VM in vCenter when: hypervisor_type == "vmware" vmware.vmware.vm_powerstate: hostname: "{{ hypervisor_cfg.url }}" username: "{{ hypervisor_cfg.username }}" password: "{{ hypervisor_cfg.password }}" validate_certs: "{{ hypervisor_cfg.validate_certs | bool }}" datacenter: "{{ hypervisor_cfg.datacenter }}" name: "{{ hostname }}" state: powered-on