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

vmware_deploy_ovf: "Failure validating OVF import spec: Host did not have any virtual network defined."

Open ansibleusersili opened this issue 5 years ago • 9 comments

SUMMARY

Hello everyboby, i have a problem with automatic OVF/OVA deployement with Ansible on vmware. I had this error message 'Failure validating OVF import spec: Host did not have any virtual defined' I tried multiple combination and following issue that were referenced on github, but nothing worked.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_deploy_ovf

ANSIBLE VERSION
Ansible 2.9.7
CONFIGURATION
DEFAULT_HOST_LIST(/home/node-manager/Documents/socinbox/ansible.cfg) = ['/home/node-manager/Documents/socinbox/hosts']
OS / ENVIRONMENT

VSPhere version: 6.7 Ubuntu version 18.0.4 TLS Ansible 2.9.7

STEPS TO REPRODUCE
- name: Deploy_ovf
  vmware_deploy_ovf:
    hostname: '{{vcenter_hostname}}'
    username: '{{vcenter_username}}'
    password: '{{vcenter_password}}'
    validate_certs: no
    datacenter: '{{datacenter}}'
    datastore: '{{datastore}}'
    ovf: '/home/user-ansible/Documents/OVF_files/***.ovf'
    ressource_pool: '***'
    networks: "{u'VM Network': u'***'}"
EXPECTED RESULTS

OVF deploy successfully

ACTUAL RESULTS
fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"allow_duplicates": true,
"cluster": null,
"datacenter": "",
"datastore": "",
"deployment_option": null,
"disk_provisioning": "thin",
"fail_on_spec_warnings": false,
"folder": null,
"hostname": "",
"inject_ovf_env": false,
"name": "",
"networks": {
"VM Network": ""
},
"ovf": "/home/node-manager/Documents/socinbox/OVF_files/share-file/share-file.ovf",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"power_on": true,
"properties": null,
"proxy_host": null,
"proxy_port": null,
"resource_pool": "",
"username": "**",
"validate_certs": false,
"wait": true,
"wait_for_ip_address": false
}
},
"msg": "Failure validating OVF import spec: Host did not have any virtual network defined."
}

ansibleusersili avatar May 04 '20 17:05 ansibleusersili

I am also facing same issue. Host did not have any virtual network defined

  - name: Deploy OVA when its VMC 
    vmware_deploy_ovf:
      hostname: '{{ host }}'
      username: '{{ user }}'
      password: "{{ password }}"
      datacenter: "{{ datacenter }}"
      cluster: "{{ cluster }}"
      datastore: "{{ datastore }}"
      name: "{{ ova }}"
      networks: "{u'VM Network':u'192.1.1.x Net'}"
      power_on: no
      ovf: "{{ ovapath }}"
    delegate_to: localhost

Result :

fatal: [example.com -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_duplicates": true,
            "cluster": "Automatic",
            "datacenter": "MYDC",
            "datastore": "AUTO1",
            "deployment_option": null,
            "disk_provisioning": "thin",
            "fail_on_spec_warnings": false,
            "folder": null,
            "hostname": "example.com",
            "inject_ovf_env": false,
            "name": "Windows",
            "networks": {
                "VM Network": "192.1.1.x Net"
            },
            "ovf": "/tmp/abc.ovf",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "power_on": true,
            "properties": null,
            "proxy_host": null,
            "proxy_port": null,
            "resource_pool": "Resources",
            "username": "serviceuser",
            "validate_certs": false,
            "wait": true,
            "wait_for_ip_address": false
        }
    },
    "msg": "Failure validating OVF import spec: Host did not have any virtual network defined."
}

I have tried with dvswitch_name as well as portgroup_name.

Following script is returning correct values which I am using in the above code.

---
- name: Gather dvs portgroup infomation
  hosts: localhost
  gather_facts: no
  vars:
    hostname: change me to vCenter hostname
    username: [email protected]
    password: change me to vCenter user password
    datacenter: change me to datacenter name
  tasks:
    - vmware_dvs_portgroup_info:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        validate_certs: no
        datacenter: "{{ datacenter }}"
      register: dvpg_info

    - debug: msg="{{ dvpg_info }}"

    - debug: msg="{{ item.portgroup_name }}"
      loop: "{{ dvpg_info.dvs_portgroup_info.DSwitch }}"
      loop_control:
        label: "{{ item.dvswitch_name }}"`

Things I have tried -

  1. vswitch_name as well as portgroup_name
  2. Updated ansible to latest

Any suggestions?

mehmoodkha avatar May 18 '20 18:05 mehmoodkha

I was unable to get portgroup details from vmc. It took some manual efforts to get details. I was able to get proper details from VMC. Once I did modification it did worked. networks: "{u'nat':u'mynet'}" Its working for me now.

mehmoodkha avatar May 22 '20 10:05 mehmoodkha

cc @Akasurde @Tomorrow9 @goneri @lparkes @pgbidkar @warthog9 click here for bot help

ansibullbot avatar Aug 19 '20 23:08 ansibullbot

Hello Team,

I am also facing similar issue while deploying the OVA

COMPONENT NAME vmware_deploy_ovf

ANSIBLE VERSION Ansible 2.8.5

ansible 2.8.5 config file = /home/ssh_user/Qualys/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible

Steps to reproduce

tasks:

  • name: Deploy VMware Identity Manager OVA vmware_deploy_ovf: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" validate_certs: no name: UKXSW1EM53 datacenter: Swindon folder: /Swindon/Discovered virtual machine cluster: VONE-C_Customer _M3 datastore: HCS-SWI-VMAX-LUN-24 disk_provisioning: thin networks: "{ u'LAN': u'CUST-04-2042_UC-CC-APPS', u'WAN': u'CUST-04-2042_UC-CC-APPS' }"

    ovf: /home/ssh_user/Qualys/Qualys Virtual Sensor 2.4.26-11.ova allow_duplicates: no power_on: yes fail_on_spec_warnings: no wait: no wait_for_ip_address: no

Expected result: OVA deployed succesfully.

Actual result:

TASK [Deploy VMware Identity Manager OVA] ************************************************************************************************************************************************************ task path: /home/ssh_user/Qualys/vmova_qualys_deploy.yaml:20 <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ssh_user <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0' <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452" && echo ansible-tmp-1599551154.91-79987458012452="echo /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452" ) && sleep 0' Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_deploy_ovf.py <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-23190C1DEYr/tmpNuE0ay TO /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452/AnsiballZ_vmware_deploy_ovf.py <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452/ /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452/AnsiballZ_vmware_deploy_ovf.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452/AnsiballZ_vmware_deploy_ovf.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1599551154.91-79987458012452/ > /dev/null 2>&1 && sleep 0' fatal: [localhost]: FAILED! => { "changed": false, "invocation": { "module_args": { "allow_duplicates": false, "cluster": "VONE-C_Customer _M3", "datacenter": "Swindon", "datastore": "HCS-SWI-VMAX-LUN-24", "deployment_option": null, "disk_provisioning": "thin", "fail_on_spec_warnings": false, "folder": "/Swindon/Discovered virtual machine", "hostname": "195.59.212.199", "inject_ovf_env": false, "name": "UKXSW1EM53", "networks": { "LAN": "CUST-04-2042_UC-CC-APPS", "WAN": "CUST-04-2042_UC-CC-APPS" }, "ovf": "/home/ssh_user/Qualys/Qualys Virtual Sensor 2.4.26-11.ova", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 443, "power_on": true, "properties": null, "resource_pool": "Resources", "username": "[email protected]", "validate_certs": false, "wait": false, "wait_for_ip_address": false } }, "msg": "Failure validating OVF import spec: The provided network mapping between OVF networks and the system network is not supported by any host." }

PLAY RECAP ******************************************************************************************************************************************************************************************* localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Kindly help in providing a solution for the same.

Regards Vivekanand

vivekanand552 avatar Sep 08 '20 08:09 vivekanand552

@ansibleusersili @mehmoodkha hi, does your vCenter have more than one datacenters or more than one ESXi hosts? Can you have a try on one ESXi host environment? I also hit similar issue before.

Tomorrow9 avatar Jan 05 '21 05:01 Tomorrow9

Hello,

Our team is facing the same issue. We are trying to deploy an OVF like this :

fatal: [_ANSIBLE.HOSTNAME_]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_duplicates": true,
            "cluster": "_OVF.CLUSTER_",
            "datacenter": "_OVF.DC_",
            "datastore": "_OVF.DS_",
            "deployment_option": null,
            "disk_provisioning": "thin",
            "esxi_hostname": null,
            "fail_on_spec_warnings": false,
            "folder": "_OVF.FOLDER_",
            "hostname": "_OVF.FQDN_",
            "inject_ovf_env": false,
            "name": "_OVF.HOSTNAME_",
            "networks": {
                "VM Network": "_OVF.NSX_T_VALUE_"
            },
            "ovf": "/images/VCF/identity-manager-3.3.4.0-17498518_OVF10.ova",
            "password": "_VALUE_SPECIFIED_IN_NO_LOG_PARAMETER_",
            "port": 443,
            "power_on": false,
            "properties": {
                "ceip.enabled": "false",
                "vami.DNS.IdentityManager": "xx.xx.xx.xx,xx.xx.xx.xx",
                "vami.domain.IdentityManager": "xx.xx.xx.xx",
                "vami.gateway.IdentityManager": "xx.xx.xx.xx",
                "vami.ip0.IdentityManager": "xx.xx.xx.xx",
                "vami.netmask0.IdentityManager": "xx.xx.xx.xx",
                "vami.searchpath.IdentityManager": "xx.xx.xx.xx",
                "vamitimezone": "Europe/Paris",
                "vm.hostname": "_OVF.FQDN_",
                "vm.name": "IdentityManager"
            },
            "proxy_host": null,
            "proxy_port": null,
            "resource_pool": "Resources",
            "username": "[email protected]",
            "validate_certs": true,
            "wait": true,
            "wait_for_ip_address": false
        }
    },
    "msg": "Failure validating OVF import spec: Host did not have any virtual network defined."
}

Deployement throught a vCenter with multiple VC, multiple DC, etc...

samsam-rolon avatar Jun 17 '21 08:06 samsam-rolon

Solving using networks: "{u'Network 1':u'{{ NetworkVar}}' }" instead of networks: "{u'VM Network':u'{{ NetworkVar}}' }"

samsam-rolon avatar Jun 17 '21 11:06 samsam-rolon

Hi @ansibleusersili @mehmoodkha @samsam-rolon @vivekanand552 would you please refer to the latest comments in issue #164 and have a try on the fix in #1020? Thanks.

Tomorrow9 avatar Sep 02 '21 09:09 Tomorrow9

Hello ! Still issue is present community.vmware 1.17.1.

Can't deploy networks OVA/OVF with param "{u'Network 1':u'{{ NetworkVar}}' }" or "{u'VM Network':u'{{ NetworkVar}}' on NSX-T Segments.

Using VCF solution so multiple vCenter in linked mode, 1DC / VC, 1 or X Cluster / DC. I precise that all var are set for the targeted VC/DC/Cluster

smesguich-orange avatar Mar 14 '22 12:03 smesguich-orange