VMware module to change CD rom from iso to client

104 views
Skip to first unread message

Kris Smith

unread,
Oct 23, 2023, 9:46:58 AM10/23/23
to Ansible Project
So we have a workiing deploment for our VM's using AAP.  What I am trying to do is as the last step after everything is done, is change the cd from the bootable iso file we use to kickstart everything, back to client device. I cannot figure out how..

What I have attempted to do (since I really don't know scripting) is edit one of the existing yml files which turns the VM on after all the infoblox and firewall objects are created..

Is there even a way using Ansible to just wait 30 min after the VM is powered on for it to do the full deploy, then set the CD-ROM back to client device?

---
- name: Create a new Virtual Machine in VMware
  hosts: localhost
  gather_facts: false
  vars:
    vcenter_hostname: '{{ lookup("env","VMWARE_HOST") }}'
    vcenter_username: '{{ lookup("env","VMWARE_USER") }}'
    vcenter_password: '{{ lookup("env","VMWARE_PASSWORD") }}'
  tasks:
    - name: "Look up the VM called {{ vm_name }} in the inventory"
      vmware.vmware_rest.vcenter_vm_info:
        filter_names:
        - "{{ vm_name }}"
      register: search_result
     
    - name: Collect information about a specific VM
      vmware.vmware_rest.vcenter_vm_info:
        vm: '{{ search_result.value[0].vm }}'
      register: test_vm1_info

    # - name: Pause for 30 for build to complete
    #   ansible.builtin.pause:
    #     minutes: 30

    - name: Set CD-ROM to Client Device
      community.vmware.vmware_guest:
        cdrom:
          type: client
        name: '{{ test_vm1_info.id }}'

Will McDonald

unread,
Oct 23, 2023, 10:30:36 AM10/23/23
to ansible...@googlegroups.com
This is pretty much what wait_for and wait_for_connection are designed to handle.


If you can key off a condition that indicates the provisioning has complete (i.e. we can SSH in, or validate from an API, or check a log entry), then you could continue through to switch the connected device.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4b377d13-1200-403c-a786-1748d47a56a1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages