vmware.vmware_rest icon indicating copy to clipboard operation
vmware.vmware_rest copied to clipboard

vcenter_ovf_libraryitem when run with additional_parameters generates INTERNAL_SERVER_ERROR

Open alice-rc opened this issue 1 year ago • 0 comments

SUMMARY

The first issue is with the documentation. There is no example at all using the parameter deployment_spec.additional_parameters so I consulted the API documentation to try and figure out what structure should be used. I then ran the module using the state: filter parameter to see if that would give me insight. Despite using the structure that appears to be correct from both outputs I cannot get the module to take the parameter without it returning an INTERNAL_SERVER_ERROR.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible [core 2.13.4]
  config file = /home/REDACTED/venv/ee-rcstandard-rhel8-183/meta/ansible.cfg
  configured module search path = ['/home/REDACTED/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/REDACTED/venv/ee-rcstandard-rhel8-183/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/REDACTED/venv/ee-rcstandard-rhel8-183/collections
  executable location = /home/REDACTED/venv/ee-rcstandard-rhel8-183/bin/ansible
  python version = 3.9.7 (default, Apr 11 2022, 06:30:15) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10.0.1)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list vmware.vmware_rest

# /home/REDACTED/venv/ee-rcstandard-rhel8-183/collections/ansible_collections
Collection         Version
------------------ -------
vmware.vmware_rest 2.2.0
CONFIGURATION
$ ansible-config dump --only-changed
COLLECTIONS_PATHS(env: ANSIBLE_COLLECTIONS_PATH) = ['/home/REDACTED/venv/ee-rcstandard-rhel8-183/collections']
GALAXY_SERVER_LIST(/home/REDACTED/venv/ee-rcstandard-rhel8-183/meta/ansible.cfg) = ['automation_hub', 'public_galaxy']
OS / ENVIRONMENT

Oracle Linux Server 8.6 Python 3.9.7 aiohttp 3.8.3 vCenter 7.0.3.00300

STEPS TO REPRODUCE

Output of vmware.vmware_rest.vcenter_ovf_libraryitem: using state: filter https://gist.github.com/alice-rc/120ac1262a2d7f347f428657b79e6589

The VM gets deployed fine if I completely leave out the additional_parameters section, but of course it doesn't have any of the required customization. So I tried to take the output of the filter to build my deploy properties (just tried one parameter this run), but it will not run.

- name: Deploy VM from content library item using the API
      vmware.vmware_rest.vcenter_ovf_libraryitem:
        vcenter_hostname: "{{ __deploy_vcenter_hostname }}"
        vcenter_username: "{{ gv_vcenter_username }}"
        vcenter_password: "{{ gv_vcenter_password }}"
        vcenter_validate_certs: "{{ gv_vcenter_validate_certs }}"
        vcenter_rest_log_file: /tmp/vcenter_ovf_libraryitem.out
        deployment_spec:
          name: "{{ inventory_hostname }}"
          annotation: "{{ __deploy_vm_notes }}"
          accept_all_EULA: "{{ gv_accept_eula }}"
          network_mappings:
            key: Network 1
            value: "{{ __deploy_portgroup }}"
          storage_provisioning: "{{ gv_vm_storage_provisioning }}"
          additional_parameters:
            - properties:
              - category: Application
                class_id: ""
                description: "This will be used as an initial password for the root user account."
                id: varoot-password
                instance_id: ""
                label: Initial root password
                type: "password(..256)"
                ui_optional: false
                value: "{{ vmo_root_password }}"
          default_datastore_id: "{{ __deploy_datastore_id }}"
        ovf_library_item_id: "{{ __deploy_ovf_id }}"
        target:
          resource_pool_id: "{{ __deploy_pool_id }}"
          folder_id: "{{ __deploy_folder_id }}"
        session_timeout: "{{ gv_deploy_timeout }}"
        state: deploy
      register: __deploy_api_results
EXPECTED RESULTS

VM gets deployed from the content library item, and the root password is correctly set

ACTUAL RESULTS

It gives a generic INTERNAL_SERVER_ERROR without any indication of what is wrong.

TASK [Deploy VM from content library item using the API] ***********************
task path: /opt/dev/REDACTED/repo/active/COMPANY.PROJECT/test_deploy_ova.yml:224
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: REDACTED
<127.0.0.1> EXEC /bin/sh -c 'echo ~REDACTED && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/REDACTED/.ansible/tmp `"&& mkdir "` echo /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942 `" && echo ansible-tmp-1673641737.4334395-1255704-229439238123942="` echo /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942 `" ) && sleep 0'
Using module file /home/REDACTED/venv/ee-rcstandard-rhel8-183/collections/ansible_collections/vmware/vmware_rest/plugins/modules/vcenter_ovf_libraryitem.py
<127.0.0.1> PUT /opt/dev/REDACTED/.ansible/tmp/ansible-local-1255576200mds3c/tmpryvywk9l TO /opt/dev/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942/AnsiballZ_vcenter_ovf_libraryitem.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942/ /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942/AnsiballZ_vcenter_ovf_libraryitem.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/REDACTED/venv/ee-rcstandard-rhel8-183/bin/python3 /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942/AnsiballZ_vcenter_ovf_libraryitem.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/REDACTED/.ansible/tmp/ansible-tmp-1673641737.4334395-1255704-229439238123942/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "client_token": null,
            "create_spec": null,
            "deployment_spec": {
                "accept_all_EULA": true,
                "additional_parameters": [
                    {
                        "properties": [
                            {
                                "category": "Application",
                                "class_id": "",
                                "description": "This will be used as an initial password for the root user account.",
                                "id": "varoot-password",
                                "instance_id": "",
                                "label": "Initial root password",
                                "type": "password(..256)",
                                "ui_optional": false,
                                "value": "REDACTED"
                            }
                        ]
                    }
                ],
                "annotation": "VMware Aria Automation Orchestrator 8.10 -- Deployed: 2023-01-13",
                "default_datastore_id": "datastore-35812",
                "name": "xxx06-p77-vmo11",
                "network_mappings": {
                    "key": "Network 1",
                    "value": "Mgmt1"
                },
                "storage_provisioning": "thin"
            },
            "ovf_library_item_id": "b8c7d3d1-658f-47a5-aa36-a35a153cc212",
            "session_timeout": 1800.0,
            "source": null,
            "state": "deploy",
            "target": {
                "folder_id": "group-v9519",
                "resource_pool_id": "resgroup-11499"
            },
            "vcenter_hostname": "xxx06-c01-vcs11.ops.COMPANY.com",
            "vcenter_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "vcenter_rest_log_file": "/tmp/vcenter_ovf_libraryitem.out",
            "vcenter_username": "REDACTED",
            "vcenter_validate_certs": false
        }
    },
    "value": {
        "error_type": "INTERNAL_SERVER_ERROR",
        "messages": [
            {
                "args": [
                    "com.vmware.vapi.std.errors.InternalServerError"
                ],
                "default_message": "Provider method implementation threw unexpected exception: com.vmware.vapi.std.errors.InternalServerError",
                "id": "vapi.bindings.method.impl.unexpected"
            },
            {
                "args": [
                    ""
                ],
                "default_message": "An error occurred: ",
                "id": "com.vmware.vdcs.util.unhandled_error"
            }
        ]
    }
}

alice-rc avatar Jan 13 '23 20:01 alice-rc