Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_guest - Can't provision to datacenter inside a folder #22713

Closed
dsears opened this issue Mar 16, 2017 · 13 comments
Closed

vmware_guest - Can't provision to datacenter inside a folder #22713

dsears opened this issue Mar 16, 2017 · 13 comments
Assignees
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@dsears
Copy link

dsears commented Mar 16, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
ansible 2.3.0.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.6.6 (r266:84292, Aug  9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
CONFIGURATION

N/A

OS / ENVIRONMENT

Red Hat Enterprise Linux Server release 6.8 (Santiago)

SUMMARY

A VM folder cannot be targeted when its parent datacenter is inside a folder.

STEPS TO REPRODUCE

My vCenter has uses location-based folders to contain datacenters. A valid path to pyvmomi's FindByInventoryPath might be:

MyCity/MyDatacenter/vm/MyVmFolder

However, looks like vmware_guest calls FindByInventoryPath with just the datacenter name:

        f_obj = self.content.searchIndex.FindByInventoryPath('/%(datacenter)s%(folder)s' % self.params)

This configuration finds the datacenter but not the folder:

      vmware_guest:
        datacenter: MyDatacenter
        folder: /vm/MyVmFolder

This configuration fails to find the datacenter:

      vmware_guest:
        datacenter: MyCity/MyDatacenter
        folder: /vm/MyVmFolder
EXPECTED RESULTS

Datacenter/folder combination are addressable.

ACTUAL RESULTS

Either folder is not found or datacenter is not found. Not clear if there is any workable way to address the datacenter/folder combination.

@ansibot
Copy link
Contributor

ansibot commented Mar 16, 2017

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. vmware VMware community labels Mar 16, 2017
@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Mar 16, 2017
@jctanner
Copy link
Contributor

@dsears have you tried changing the line just to test if it would work?

_obj = self.content.searchIndex.FindByInventoryPath('/%(datacenter)s%(folder)s' % self.params)

to

_obj = self.content.searchIndex.FindByInventoryPath('/<MyCity>/%(datacenter)s%(folder)s' % self.params)

Not the permanent solution, but I would like to know if the rest of the code would succeed after that.

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Mar 17, 2017
@ansibot
Copy link
Contributor

ansibot commented Mar 21, 2017

@dsears This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Mar 21, 2017
@dsears
Copy link
Author

dsears commented Mar 21, 2017

Not totally sure. It gets farther and then fails with a permission denied on the clone operation:

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_d4RXUm/ansible_module_vmware_guest.py\", line 1332, in <module>\n    main()\n  File \"/tmp/ansible_d4RXUm/ansible_module_vmware_guest.py\", line 1321, in main\n    result = pyv.deploy_vm()\n  File \"/tmp/ansible_d4RXUm/ansible_module_vmware_guest.py\", line 1088, in deploy_vm\n    task = vm_obj.Clone(folder=destfolder, name=self.params['name'], spec=clonespec)\n  File \"/usr/lib/python2.6/site-packages/pyVmomi/VmomiSupport.py\", line 580, in <lambda>\n    self.f(*(self.args + (obj,) + args), **kwargs)\n  File \"/usr/lib/python2.6/site-packages/pyVmomi/VmomiSupport.py\", line 386, in _InvokeMethod\n    return self._stub.InvokeMethod(self, info, args)\n  File \"/usr/lib/python2.6/site-packages/pyVmomi/SoapAdapter.py\", line 1373, in InvokeMethod\n    raise obj # pylint: disable-msg=E0702\npyVmomi.VmomiSupport.NoPermission: (vim.fault.NoPermission) {\n   dynamicType = <unset>,\n   dynamicProperty = (vmodl.DynamicProperty) [],\n   msg = 'Permission to perform this operation was denied.',\n   faultCause = <unset>,\n   faultMessage = (vmodl.LocalizableMessage) [],\n   object = 'vim.VirtualMachine:vm-2708',\n   privilegeId = 'VirtualMachine.Provisioning.DeployTemplate'\n}\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

Partial playbook:

  tasks:

    - name: Clone the VM
      vmware_guest:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: no
        datacenter: "{{ datacenter }}"
        cluster: "{{ cluster }}"
        template: "{{ template }}"
        name: "{{ vm_name }}"
        folder: "{{ folder }}"

So it's at least finding the VM, and my user is definitely able to clone things both through the UI and through pyvmomi. Not sure if the error is related to the folder issue or if I have some other input that is wrong/missing.

@ansibot
Copy link
Contributor

ansibot commented Jun 23, 2017

@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Jun 29, 2017
@ansibot
Copy link
Contributor

ansibot commented Jul 18, 2017

@Akasurde
Copy link
Member

@dsears Could you please paste output of govc find / ?

I tried to reproduce your setup. Does it look similar to yours ?

# govc find /mycity
/mycity
/mycity/mydatacenter
/mycity/mydatacenter/vm
/mycity/mydatacenter/host
/mycity/mydatacenter/host/myhost
/mycity/mydatacenter/host/myhost/myhost
/mycity/mydatacenter/host/myhost/Resources
/mycity/mydatacenter/host/myhost/Resources/myrp
/mycity/mydatacenter/datastore
/mycity/mydatacenter/datastore/mydatastore
/mycity/mydatacenter/network
/mycity/mydatacenter/network/VM Network
/mycity/SampleVM01

@rpasche
Copy link

rpasche commented Sep 27, 2017

I think my PR #30826 would fix this.

@ansibot
Copy link
Contributor

ansibot commented Oct 13, 2017

@Akasurde
Copy link
Member

@dsears Could you please re-try with latest or 2.4.2.0 version and let me know if it works for you ?

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Dec 12, 2017
@ansibot
Copy link
Contributor

ansibot commented Dec 12, 2017

@dsears You have not responded to information requests in this issue so we will assume it no longer affects you. If you are still interested in this, please create a new issue with the requested information.

click here for bot help

@ansibot ansibot closed this as completed Dec 12, 2017
@Akasurde Akasurde reopened this Dec 12, 2017
@ansibot
Copy link
Contributor

ansibot commented Jan 13, 2018

@dsears This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@Akasurde
Copy link
Member

Closing this issue as this functionality works in current version. If issue persists, please feel free to re-open.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

No branches or pull requests

6 participants