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

community.vmware.vmware_guest_disk - not the configured datacenter #2021

Open
yakhatape opened this issue Mar 8, 2024 · 8 comments
Open

Comments

@yakhatape
Copy link

yakhatape commented Mar 8, 2024

##### SUMMARY

When we have multiple vSphere Datacenter ex : datacenterovh1 , datacenterovh2 ; both composed of cluster named "Cluster1" and Datastore named "vsanDatastore" we are facing the following error :
msg: Get datastore 'vsanDatastore' in datacenter 'datacenterovh1', not the configured datacenter 'datacenterovh2'

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest_disk

ANSIBLE VERSION
  config file = /etc/ansible/ansible.cfg
python version = 3.9.6 (default, Jun 24 2022, 12:33:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.1.3
  libyaml = True

COLLECTION VERSION
---------------- -------
community.vmware 2.6.0

STEPS TO REPRODUCE

Requirement :
1 vSphere
2 Datacenter : datacenterovh1 , datacenterovh2
Each Datacenter Cluster named with the same name: "Cluster1"
Each Datacenter Datastore named with the same name: "vsanDatastore"

During the play the value of vsphere_datacenter = datacenterovh2

  connection: local
  become: false
    community.vmware.vmware_guest_disk:
    hostname: "{{ vsphere_server }}"
    username: "{{ vsphere_username }}"
    password: "{{ vsphere_password }}"
    validate_certs: no
    datacenter: "{{ vsphere_datacenter }}"
    name: '{{ vmname }}'
    disk:
      - size_gb: "{{ volume_data_size }}"
        datastore: vsanDatastore
        type: thin
        unit_number: "{{ unit_number }}"
        scsi_controller: 0
  delegate_to: localhost
  register: deploy_vm

EXPECTED RESULTS

Ansible vmware module should find the vsanDatastore object from the datacenterovh2 instead of datacenterovh1

ACTUAL RESULTS

Ansible vmware find the vsanDatastore object from the datacenterovh1 instead of datacenterovh2 passing in through var into the tasks

msg: Get datastore 'vsanDatastore' in datacenter 'datacenterovh1', not the configured datacenter 'datacenterovh2'


Code which return the error :

self.module.fail_json(msg="Get datastore '%s' in datacenter '%s', not the configured"

and the datastore value it passing to the helper :

def get_parent_datacenter(obj):

@ihumster
Copy link
Collaborator

ihumster commented Mar 8, 2024

@yakhatape collection version 2.x no longer supported, please update it to latest and try run playbook again.

@yakhatape
Copy link
Author

yakhatape commented Mar 8, 2024

Thanks @ihumster for feedback make sense, I've upgrade my ansible core to 2.13.3 to avoid issue of the collection api download and upgrade the vmware collection.

My deploiment is in progress I will give a feedback asap

@yakhatape
Copy link
Author

yakhatape commented Mar 8, 2024

@ihumster the error still the same :
msg: Get datastore 'vsanDatastore' in datacenter 'datacenterovh1', not the configured datacenter 'datacenterovh2'

Wit following setup :

Collection       Version
---------------- -------
community.vmware 4.2.0

Do you have any idea ?

@ihumster
Copy link
Collaborator

ihumster commented Mar 8, 2024

@yakhatape I looked at the module code and I believe that the problem is that the clusters have the same datastore names. If possible, rename one of them and try running the playbook again.

@yakhatape
Copy link
Author

@ihumster the module shouldn't verify the uuid/id of the object or something like that ?

@ihumster
Copy link
Collaborator

ihumster commented Mar 8, 2024

@yakhatape You specify the name of the datastore in the playbook, the module looks for the first occurrence of the name among the datastore, and then later checks it to see if it belongs to the datacenter. In any case, he will not be able to distinguish datastores by name.

@yakhatape
Copy link
Author

Yep I understand about the datastore name check, but the code who is checking the parent item should not the wrong datacenter.

But let imagine you have multiple datacenter/Cluster on your vmware with a shared vsan , all datastore will have the same name so the code will crash the same error ...

@yakhatape
Copy link
Author

@ihumster , isn't possible to change the code to take datacenter as parameter of the self module datacenter parameter ?

something like this :
self.parent_datacenters = {}

Because i dont understand why the module should call a helper to retrieve the parent datacenter when the datacenter parameter is directly instanciate into the playbook module.

Maybe im wrong ..

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

No branches or pull requests

2 participants