ansible-collections / vmware.vmware_rest

Ansible Collection for VMWare (REST modules)
GNU General Public License v3.0
126 stars 56 forks source link

vmware.vmware_rest.vcenter_ovf_libraryitem - Update existing template #385

Open sepetuks opened 1 year ago

sepetuks commented 1 year ago
SUMMARY

I am trying to update existing OVF template but it looks it is not updating it when I provide library_item_id. All works ok when I need first OVF template to be cloned to library but I do not succed updateing Connten library template with new versions. As per documentation" - library_item_id (str): Identifier of the library item that should be should be updated. (['present']) https://github.com/ansible-collections/vmware.vmware_rest/blob/main/docs/vmware.vmware_rest.vcenter_ovf_libraryitem_module.rst Per documentation I read it should be possible. So I either thats issue with documentation or with code.

ISSUE TYPE
COMPONENT NAME

vmware.vmware_rest.vcenter_ovf_libraryitem

ANSIBLE VERSION
ansible [core 2.13.7]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/henris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/henris/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/henris/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/henris/.local/bin/ansible
  python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection         Version
------------------ -------
vmware.vmware_rest 2.2.0
CONFIGURATION
OS / ENVIRONMENT

vCenter 7.0 Update 3j (20990077)

STEPS TO REPRODUCE
    - name: Export the VM as an OVF on the library (new)
      vmware.vmware_rest.vcenter_ovf_libraryitem:
        vcenter_hostname: "{{ vcenter_hostname }}"
        vcenter_username: "{{ vcenter_username }}"
        vcenter_password: "{{ vcenter_password }}"
        vcenter_validate_certs: false
        vcenter_rest_log_file: '/tmp/rest.log'
        session_timeout: 2900
        source:
          type: VirtualMachine
          id: '{{ vm1_info.id }}'
        target:
          library_id: '{{ library_id }}'
        create_spec:
          name: golden
          description: an OVF example
          flags: []
        state: present
      delegate_to: localhost  
      tags: library

   - name: Export the VM as an OVF on the library (update)
      vmware.vmware_rest.vcenter_ovf_libraryitem:
        vcenter_hostname: "{{ vcenter_hostname }}"
        vcenter_username: "{{ vcenter_username }}"
        vcenter_password: "{{ vcenter_password }}"
        vcenter_validate_certs: false
        vcenter_rest_log_file: '/tmp/rest.log'
        session_timeout: 2900
        source:
          type: VirtualMachine
          id: '{{ vm1_info.id }}'
        target:
          library_id: '{{ library_id }}'
          library_item_id: '{{ library_item_id }}'
        create_spec:
          name: golden
          description: an OVF example2
          flags: []
        state: present
      delegate_to: localhost  
      tags: library
EXPECTED RESULTS

I would expect second task would do OVF template update, but task just finished without actions (no failure)

ACTUAL RESULTS

Second task is always giving status "ok" (I would expect changed)

TASK [Export the VM as an OVF on the library (new)] ********************************************************************
changed: [Template -> localhost]

TASK [Export the VM as an OVF on the library (update)] *****************************************************************
ok: [Template -> localhost]
rgadwagner commented 1 year ago

I'll add the "me too" to this.

1) The documentation identifies library_id as unused if library_item_id is passed in, but without library_id the process fails with invalid values. 2) WHen passing both library_id and library_item_id the process behaves as if ONLY library_id is passed and attempts to create the OVF container object before uploading to it. If the OVF container object exists, ansible returns "green" and does nothing.

smatterchew commented 1 year ago

Ran into the same problem. Sending an updated image to the local CL results in changed: false and the new image isn't exported to the local CL.

[user@ansible] ➤ ansible --version 
ansible [core 2.11.12]
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible/os9_prov_vmw_20230117/lib64/python3.6/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/ansible/os9_prov_vmw_20230117/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
  jinja version = 3.0.3
  libyaml = True

Also using 2.2.0 of the collection:

[user@ansible] ➤ ansible-galaxy collection list | grep vmware_rest
vmware.vmware_rest    2.2.0

I am able to send the image to vCenter and manually "update" the version in the CL.

Workaround for now is to delete the image from the local CL and allow the task to re-create it.

vSphere: vSphere Client version 7.0.3.01100

rgadwagner commented 1 year ago

Can confirm this is functional on 2.1.5 of VMWare Rest Library. Downgrading to 2.1.5 in a collections/requirements.yml will provide full functionality in pushing uploads of OVF to VMware.

collections/requirements.yml:

Then Run: ansible-galaxy collection install -f -r collections/requirements.yml -p collections

(The above installs the collections to a local "collections" directory in your repo, YMMV on the above command).

This will install 2.1.5 of the rest collection into ansible and you should see things work from there. You will need to pass in BOTH library_id AND library_item_id to get it to function (Their documentation is also dead wrong with no examples).

rgadwagner commented 2 weeks ago

So...we've now released 3.0, but no one can upgrade to it that's using library functionality because this bug still exists?