Vmware_guest is not changing guest_id

I am having some trouble with the vmware_guest modules.

I deploy an OVA (works fine) but the hardware version and guest_id’s need to be updated.

So came up with this:

- name: Gather guest info for UUID
  community.vmware.vmware_guest_info:
    name: "{{ inventory_hostname | split('.') | first }}"
  delegate_to: localhost
  register: vm_info
  ignore_errors: true

- name: Turn off guest VM using UUID
  community.vmware.vmware_guest:
    uuid: "{{ vm_info.instance.hw_product_uuid }}"
    state: poweredoff
    cluster: mycluster
  when: vm_info.instance is defined
  delegate_to: localhost
  delegate_facts: true

- name: Upgrade VM hardware version
  community.vmware.vmware_guest:
    uuid: "{{ vm_info.instance.hw_product_uuid }}"
    hardware:
      version: latest
    cluster: mycluster
  delegate_to: localhost
  delegate_facts: true

- name: Change Guest ID
  community.vmware.vmware_guest:
    uuid: "{{ vm_info.instance.hw_product_uuid }}"
    guest_id: other6xLinux64Guest
    cluster: mycluster
  delegate_to: localhost
  delegate_facts: true

The Vmware environment is vSphere 8u2 supporting VM version 21.

I used the community.vmware.vmware_vm_config_option to verify I am using the correct and supported guest_id. I double checked against the vmware API documentation in case I was going crazy.

I tried different code, with UUID (above), VM names, with more/less parameters like cluster. I never get an error (it shows changed), but it never actually changes the guest_id.

Any ideas what is going wrong here? Thanks!

Hello,

I just had the chance to try it on a vsphere 7u3 using the community.vmware:=2.9.1 collection. It worked as expected:

    - name: Change Guest ID
      community.vmware.vmware_guest:
        # uuid: "{{ vm_info.instance.hw_product_uuid }}"
        guest_id: other5xLinux64Guest
        hostname: esxi.beri.lab
        username: root
        password: ******
        validate_certs: false
        name: Ubuntu-VM
      delegate_to: localhost
      delegate_facts: true

Anyway, since you’re on 8u2, and I’m on 7u3, there might be differences on how the API treats the guestId config.

I’d try to update the community.vmware collection to its latest version (4.0.1 as of today) if you have not done it yet:

ansible-galaxy collection install community.vmware --force

You might also try to use other5xLinux64Guest or another value instead to see if the problem is related with that specific id (which was added on API 8.0.0.1).

2 Likes

Thanks, I’ll try out your suggestions.

One remark on the difference besides the version, is that you directly target your esx server instead of going through vcenter cluster.

I’ll try that too.

1 Like

Wow oke weirdness!

I updated the vmware collection, reran the update playbook on 1 host and saw all output was green (OK), so unchanged. Puzzling …

Turns out my role worked all along vcenter just didn’t show it immediately (I did refresh :wink: ). I guess it just takes a while or perhaps the guests had to turn on first to reflect the change.

Either way, problem disappeared.

2 Likes

Hahaha welcome to the amazing world of computer science, I guess :sweat_smile:

Thanks for letting us know that you were able to “fix” it, btw. See you around!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.