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_content_deploy_ovf_template does not respet resource_pool parameter #1290

Closed
Pigi-102 opened this issue Apr 15, 2022 · 14 comments · Fixed by #1362
Closed

vmware_content_deploy_ovf_template does not respet resource_pool parameter #1290

Pigi-102 opened this issue Apr 15, 2022 · 14 comments · Fixed by #1362

Comments

@Pigi-102
Copy link

SUMMARY

When creating a VM from an OVF template in a Content Library, no matter what resource_pool you try to configure ( either it does exist or not ) the VM get created in the top level resource pool ( if such thing exist ).

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_content_deploy_ovf_template

ANSIBLE VERSION
ansible --version
ansible 2.9.20
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/pigi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib64/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.10 (main, Jan 16 2022, 02:41:55) [GCC 11.2.0]

COLLECTION VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE

Have a vmware environment with some resource pools.
Create a Content Library and upload an ovf
Try to create a VM from this ovf in a specific resource pool

- name: CreateBootStrap
  user: root
  hosts: localhost
  #become: true
  gather_facts: false
  vars:
# Define your username and password here that you want to create on target hosts.
    vcenter_hostname: vcsa67
    vcenter_username: pigi
    vcenter_password: Passw0rd
    OCP_template: rhcos-vmware.x86_64
    OCP_Library: Lib_CL_RHCOS
    Cluster: "Compute LAB Cluster"
    DataStore: Compute_03-Sistemi
    folderVM: "Pigi_folder_vm"
    DataCenter: "LAB Datacenter"
    NameVM:  "Test_for_OCP"
    ResPool: "OCP_TST"

   - name: create  machine from template. 
      community.vmware.vmware_content_deploy_ovf_template:
        cluster: '{{ Cluster }}'
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        template: '{{ OCP_template }}'
        content_library:  '{{ OCP_Library }}'
        datastore: '{{ DataStore }}'
        folder: '{{ folderVM }}'
        datacenter: '{{ DataCenter }}'
        name: '{{ NameVM }}'
        resource_pool: '{{ ResPool }}'
        storage_provisioning: thin
        validate_certs: no 
      delegate_to: localhost
EXPECTED RESULTS

I expepct that the VM would be created in the OCP_TST resource pool

ACTUAL RESULTS

The VM get created in the correct cluster but outside the resource pool


@Udayendu
Copy link

Udayendu commented Jun 10, 2022

This bug is still available in the latest version of vmware ansible collections.
Its taking the resource_pool value but there is no code to handle it.

Issue seems to be in

self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)
line. Its trying to get the resource pool details using get_resource_pool_by_name function. But that function itself is not available. Hence no activity is happening at that lebel.

  • My installed version of collection:
$ ansible-galaxy collection list community.vmware

# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection       Version
---------------- -------
community.vmware 1.18.0

Can we get this fixed ?

@mariolenz
Copy link
Collaborator

@Udayendu This issue is about the vmware_content_deploy_ovf_template module. But you're linking to the vmware_content_deploy_template:

Issue seems to be in

self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)

Do you run into this issue with vmware_content_deploy_ovf_template, with vmware_content_deploy_template or with both?

Its trying to get the resource pool details using get_resource_pool_by_name function. But that function itself is not available. Hence no activity is happening at that lebel.

I think you're wrong there. You see, if this method wouldn't be available I think the module would crash. And, anyway, the method is defined in VmwareRestClient from where VmwareContentDeployTemplate inherits it:

def get_resource_pool_by_name(self, datacenter_name, resourcepool_name, cluster_name=None, host_name=None):
"""
Returns the identifier of a resource pool
with the mentioned names.
"""
datacenter = self.get_datacenter_by_name(datacenter_name)

@mariolenz
Copy link
Collaborator

mariolenz commented Jun 11, 2022

@Pigi-102 It looks like the module searches for the resource pool only if both cluster and host are defined:

# Find the resourcepool by the given resourcepool name
if self.resourcepool and self.cluster and self.host:
self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)

Could you please try to deploy to a specific host in the cluster? I'd like to see what happens in this case. It would help me to fix this.

@mariolenz
Copy link
Collaborator

@n3pjk Could you have a look at this? You've been the last one to work on this module, so I thought you might be interested.

@n3pjk
Copy link
Contributor

n3pjk commented Jun 11, 2022 via email

@Pigi-102
Copy link
Author

@Pigi-102 It looks like the module searches for the resource pool only if both cluster and host are defined:

# Find the resourcepool by the given resourcepool name
if self.resourcepool and self.cluster and self.host:
self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)

Could you please try to deploy to a specific host in the cluster? I'd like to see what happens in this case. It would help me to fix this.

Hello,
unfortunally at the moment I don't have access to an infrastructure to execute the test.
In case I will gain a new access I will try it.
Sorry.

@Udayendu
Copy link

@mariolenz,

Issue is with both the modules. As this bug was already opened, so I though I should include it here.
But if you want I can open another bug for vmware_content_deploy_template and map it here as patch should go to both the tools separately.

@mariolenz
Copy link
Collaborator

Issue is with both the modules. As this bug was already opened, so I though I should include it here. But if you want I can open another bug for vmware_content_deploy_template and map it here as patch should go to both the tools separately.

@Udayendu I don't think that's necessary. Let's track both issues here. It's possibly the same basic problem because vmware_content_deploy_template also searches for the resource pool only if both cluster and host are defined

# Find the resourcepool by the given resourcepool name
if self.resourcepool and self.cluster and self.host:
self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)

Could you please specify both host and cluster in addition to resource_pool? If this works, I think we've already found the problem.

@Udayendu
Copy link

Udayendu commented Jun 17, 2022

Issue is with both the modules. As this bug was already opened, so I though I should include it here. But if you want I can open another bug for vmware_content_deploy_template and map it here as patch should go to both the tools separately.

@Udayendu I don't think that's necessary. Let's track both issues here. It's possibly the same basic problem because vmware_content_deploy_template also searches for the resource pool only if both cluster and host are defined

# Find the resourcepool by the given resourcepool name
if self.resourcepool and self.cluster and self.host:
self._resourcepool_id = self.get_resource_pool_by_name(self.datacenter, self.resourcepool, self.cluster, self.host)

Could you please specify both host and cluster in addition to resource_pool? If this works, I think we've already found the problem.

So far I was just using the cluster & resource_pool. Never tried to use the host as cluster supposed to do that selection. But I will try and update you by Monday.

@Udayendu
Copy link

@mariolenz
I have completed the testing and here is my observation:

  • Its able to deploy the vm under resource pool if cluster, resource pool and esxi hosts are selected at a time.
  • ESXi server should be 6.7 and higher. Initial I tried on couple of ESXi 6.5 hosts and it failed with a compatibility error message.

@n3pjk
Copy link
Contributor

n3pjk commented Jun 20, 2022 via email

@n3pjk
Copy link
Contributor

n3pjk commented Jun 22, 2022

@Udayendu and @Pigi-102 - please check if PR #1362 resolves your issues. I have corrected the same behavior in both modules. Zuul passed the PR, thanks @mariolenz! Let me know if you still have issues.

@Udayendu
Copy link

@Udayendu and @Pigi-102 - please check if PR #1362 resolves your issues. I have corrected the same behavior in both modules. Zuul passed the PR, thanks @mariolenz! Let me know if you still have issues.

@n3pjk
Sure. I will check and get back to you in next couple of days.

@Udayendu
Copy link

@n3pjk, this patch fixed the issue in both the modules.
You can GA this and close this bug.

Thanks for the quick fix :)

softwarefactory-project-zuul bot pushed a commit that referenced this issue Jun 23, 2022
ISSUE-1290 Remove cluster host fm Pools

SUMMARY
Fixes #1290
The two template deployment modules both require cluster and host when attempting to identify a resource pool. I have removed that constraint, as the lookup function defaults cluster and host to None if not provided.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_content_deploy_ovf_template
vmware_content_deploy_template
ADDITIONAL INFORMATION

Reviewed-by: Mario Lenz <[email protected]>
softwarefactory-project-zuul bot pushed a commit that referenced this issue Jun 24, 2022
Backport PR #1362 to stable-1

SUMMARY
Backport PR #1362 to stable-1
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
vmware_content_deploy_ovf_template
vmware_content_deploy_template
ADDITIONAL INFORMATION
#1290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants