# Ansible: Register a VM to sphere ( vcenter)

**URL:** <https://forum.ansible.com/t/ansible-register-a-vm-to-sphere-vcenter/25130>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [July 30, 2017, 6:30am UTC](https://forum.ansible.com/t/ansible-register-a-vm-to-sphere-vcenter/25130 "2017-07-30T06:30:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor1](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@Victor1](https://forum.ansible.com/u/Victor1)\
**Post date:** [July 30, 2017, 6:30am UTC](https://forum.ansible.com/t/ansible-register-a-vm-to-sphere-vcenter/25130/1 "2017-07-30T06:30:28Z")

</div>

Hi ,

I am trying to register a VM through vmware-cmd command line as below but it fails with the following error message.  
has anybody tried this earlier. any help is appreciated.

I just need to register a VM to vcenter ( or in other words register to the datastore associated with ESX host managed by vcenter).

```auto
  name: Register a VM template to VSphere
  shell: vmware-cmd -H '{{hostname}}' -U '{{username}}' -P '{{password}}' --vihost '{{esxi_hostname1}}' -s register {{ template_file_path }}
  register: result
  ignore_errors: true

********************************************************

   fatal: []: FAILED! => {
    "changed": true, 
    "cmd": "vmware-cmd -H 'X.X.X.X' -U 'administrator@vsphere.local' -P 'XXX23' --vihost 'X.x.x.x' -s register /vmfs/volumes/EVC_Store1/myvgpu_clone2/myvgpu_clone2.vmx", 
    "delta": "0:00:00.004544", 
    "end": "2017-07-30 06:26:24.922754", 
    "failed": true, 
    "invocation": {
        "module_args": {
            "_raw_params": "vmware-cmd -H 'xxxx' -U 'xxxx@vsphere.local' -P 'Admin!23' --vihost 'xxxx' -s register /vmfs/volumes/EVC_Store1/myvgpu_clone2/myvgpu_clone2.vmx", 
            "_uses_shell": true, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "warn": true
        }
    }, 
    "rc": 127, 
    "start": "2017-07-30 06:26:24.918210", 
    "stderr": "/bin/sh: vmware-cmd: command not found", 
    "stderr_lines": [
        "/bin/sh: vmware-cmd: command not found"
    ], 
    "stdout": "", 
    "stdout_lines": []
}

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 30, 2017, 9:47am UTC](https://forum.ansible.com/t/ansible-register-a-vm-to-sphere-vcenter/25130/2 "2017-07-30T09:47:52Z")

</div>

> &nbsp;&nbsp;&nbsp;&nbsp;I am trying to register a VM through vmware-cmd command line as below  
> but it fails with the following error message.  
> has anybody tried this earlier. any help is appreciated.

\< snip/\>

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"stderr": "/bin/sh: vmware-cmd: command not found",

It clearly say the command doesn't exist.  
Either it's missing or not in users PATH.

Use full path or search the list for "interactive shell" and "non interactive shell" to learn more about the shell feature when it comes to PATH.

---

<div class="post-metadata">

**Author:** ![Brian\_Keyes](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@Brian\_Keyes](https://forum.ansible.com/u/Brian_Keyes)\
**Post date:** [July 31, 2017, 2:34pm UTC](https://forum.ansible.com/t/ansible-register-a-vm-to-sphere-vcenter/25130/3 "2017-07-31T14:34:38Z")

</div>

this command is only available in the vmware CLI i think
