# Having trouble with VMWare vMotion Playbook

**URL:** <https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117>\
**Category:** Get Help\
**Tags:** vmware, collections, galaxy-ng\
**Created:** [November 2, 2023, 5:36pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117 "2023-11-02T17:36:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JKD](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@JKD](https://forum.ansible.com/u/JKD)\
**Post date:** [November 2, 2023, 5:36pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/1 "2023-11-02T17:36:13Z")

</div>

Hello, I have installed the community.vmware module for my playbook. I am currently using 4.0. I am trying to run an ansible script where it moves one virtual machine from one host to another host using vMotion. However, every time I run the script, I receive the error: ‘community.vmware.vmware\_vmotion’ is not a valid attribute for a Play.

How is that possible when community.vmware.vmware\_vmotion is listed as a module on the documentation? Listed below:

> [VMware Ansible Documentation](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vmotion_module.html#ansible-collections-community-vmware-vmware-vmotion-module)

.

## Below is my script, and I don’t know what to do to fix this:

- name: Perform vMotion of virtual machine  
community.vmware.vmware\_vmotion:  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
vm\_name: ‘vm\_name\_as\_per\_vcenter’  
destination\_host: ‘destination\_host\_as\_per\_vcenter’  
delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![mariolenz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mariolenz/32/108_2.png) [@mariolenz](https://forum.ansible.com/u/mariolenz)\
**Post date:** [November 2, 2023, 5:50pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/2 "2023-11-02T17:50:34Z")

</div>

I don’t see if your indentation is correct. Either it isn’t or the forum just doesn’t show it correct (to me).

```auto
- name: Perform vMotion of virtual machine
    community.vmware.vmware_vmotion:
      hostname: ‘{{ vcenter_hostname }}’
      username: ‘{{ vcenter_username }}’
      password: ‘{{ vcenter_password }}’
      vm_name: ‘vm_name_as_per_vcenter’
      destination_host: ‘destination_host_as_per_vcenter’
    delegate_to: localhost

```

If you think your indentation is correct, please show a little bit more of your playbook. And use preformatted text so the forum doesn’t “improve” formatting 😜

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [November 2, 2023, 6:21pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/3 "2023-11-02T18:21:22Z")

</div>

Hi,

> is not a valid attribute for a Play

means you are trying to pass a module name (used in tasks) at play level.

In short, a playbook is composed of one or more plays, each of them having one or more tasks (also handlers, vars, …), so something like that in your case:

```yaml
- name: myPlay
  hosts: myHosts
  tasks:
    - name: Perform vMotion of virtual machine
      community.vmware.vmware_vmotion:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        vm_name: vm_name_as_per_vcenter
        destination_host: destination_host_as_per_vcenter
      delegate_to: localhost

```

It may obviously vary a lot; it’s just a barebone example. For instance, you may whish to use `become: true` at play level, or define vars, etc…

---

<div class="post-metadata">

**Author:** ![JKD](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@JKD](https://forum.ansible.com/u/JKD)\
**Post date:** [November 2, 2023, 7:57pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/4 "2023-11-02T19:57:09Z")

</div>

Yes, the way you have it is how I have idented my script.

---

<div class="post-metadata">

**Author:** ![JKD](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@JKD](https://forum.ansible.com/u/JKD)\
**Post date:** [November 2, 2023, 8:00pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/5 "2023-11-02T20:00:43Z")

</div>

Thank you so much, I appreciate it. Silly mistake on my end, but that did help me get past that error. Thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 2, 2023, 8:01pm UTC](https://forum.ansible.com/t/having-trouble-with-vmware-vmotion-playbook/2117/6 "2023-12-02T20:01:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
