ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
349 stars 336 forks source link

Unable to make a clone of VM on Vcenter when launching module community.vmware.vmware_guest_instant_clone with error "msg": "Datacenter not found #1334

Open yashvanthkumar94 opened 2 years ago

yashvanthkumar94 commented 2 years ago
SUMMARY

Hi Community,

I am keep getting the error message "msg": "Datacenter not found. when I launch the below playbook from my ansible tower and this module is unable to create a clone of my VM in Vcenter. As you could see I am using the community module vmware_guest_instant_clone which I had imported into my ansible tower server. The below is my example playbook for your reference. I am reachable via my email yashkumar319@yahoo.com, and my git hub id is yashvanth94

- hosts: localhost
  gather_facts: False
  connection: local

  tasks:
  -  name: Instant Clone a VM
     community.vmware.vmware_guest_instant_clone:
       hostname: "{{ vcenter_hostname }}"
       username: "{{ vcenter_username }}"
       password: "{{ vcenter_password }}"
       validate_certs: False
       folder: "/{{ datacenter }}/vm/"
       datastore: "{{ rw_datastore }}"
       datacenter: "{{ datacenter }}"
       host: "{{ esxi_hostname }}"
       name: "{{ clone_vm }}"
       parent_vm: "{{ parent_vm  }}"
       resource_pool: "{{ resource_pool }}"
     register: vm_clone
     delegate_to: localhost
ISSUE TYPE
COMPONENT NAME

Module name: community.vmware.vmware_guest_instant_clone

ANSIBLE VERSION
ansible version = 2.9.27
COLLECTION VERSION
ansible-galaxy collection list = community.vmware.vmware_guest_instant_clone
CONFIGURATION
OS / ENVIRONMENT

ansible version = 2.9.27 OS Type = Red Hat Enterprise Linux release 8.2 (Ootpa) Ansible Tower version = 3.8.5.1

STEPS TO REPRODUCE

Execute the playbook below with the appropriate variable details, and I am keep getting the error "msg": "Datacenter not found", meanwhile the datacenter name does exists.

- hosts: localhost
  gather_facts: False
  connection: local

  tasks:
  -  name: Instant Clone a VM
     community.vmware.vmware_guest_instant_clone:
       hostname: "{{ vcenter_hostname }}"
       username: "{{ vcenter_username }}"
       password: "{{ vcenter_password }}"
       validate_certs: False
       folder: "/{{ datacenter }}/vm/"
       datastore: "{{ rw_datastore }}"
       datacenter: "{{ datacenter }}"
       host: "{{ esxi_hostname }}"
       name: "{{ clone_vm }}"
       parent_vm: "{{ parent_vm  }}"
       resource_pool: "{{ resource_pool }}"
     register: vm_clone
     delegate_to: localhost
EXPECTED RESULTS

The expected results will be the clone of my target VM is created in my Vcenter in the specified folder.

ACTUAL RESULTS

I am keep getting the error message "msg": "Datacenter not found" when I launch this playbook from my ansible tower and this module is unable to create a clone of my VM in Vcenter.

ansibullbot commented 2 years ago

Files identified in the description: None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

yashvanthkumar94 commented 2 years ago

Hi can anyone help out on this issue please ?

sky-joker commented 2 years ago

Thanks @yashvanthkumar94 for reporting the issue! I will confirm the same problem whether it does occur in my environment. BTY, could you please tell me your tower version?

appdevytlps commented 2 years ago

Hi @sky-joker,

Thanks for responding, the tower version is 3.8.5-1

sky-joker commented 2 years ago

I confirmed the module behavior with your playbook code, the folder error occurred not "Datacenter error".

fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "Folder not found."}

The cause of the error is that the method in the module doesn't support an argument for a full object path.
I'll fix this bug.

Please let me make sure, does the datacenter error still occur now, not "Folder error'?

My Environment Information

mariolenz commented 2 years ago

@yashvanthkumar94 @appdevytlps Could you please test if #1354 fixes your issue?

mariolenz commented 2 years ago

@yashvanthkumar94 @appdevytlps Did you find the time yet to test if #1354 fixes your issue?