# Clone VMs on vSphere

**URL:** <https://forum.ansible.com/t/clone-vms-on-vsphere/18220>\
**Category:** Ansible Project\
**Created:** [May 13, 2015, 7:37am UTC](https://forum.ansible.com/t/clone-vms-on-vsphere/18220 "2015-05-13T07:37:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Bezemer](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@Marcel\_Bezemer](https://forum.ansible.com/u/Marcel_Bezemer)\
**Post date:** [May 13, 2015, 7:37am UTC](https://forum.ansible.com/t/clone-vms-on-vsphere/18220/1 "2015-05-13T07:37:59Z")

</div>

Hey,

I am currently playing around with ansible to see if this could be used for us in production with our deployments. Something I am currently have trouble wrapping my head around is the following.

I want to use ansible to deploy entire test invironment on the fly (tower button eventually). This would mean deploying 50ish machines to vSphere. I see you have to specify the datastore when cloning a vsphere\_quest. When you dont have the most expensive version of vCenter you dont have storage pools and have to specifiy the datastore with the most free space. How would I be able to do this in ansible? I saw the vsphere\_guest doesnt support wildcards in datastore names or just picks the one with the most free space if I dont specify any datastore at all. (which would be an awesome feature imho.)

I dont feel like “hardcoding” the datastore in the playbook when cloning the machines cause the environment around you won’t stand still 😉

thnx

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [May 13, 2015, 2:22pm UTC](https://forum.ansible.com/t/clone-vms-on-vsphere/18220/2 "2015-05-13T14:22:58Z")

</div>

You can pass it as variable through the command line and then use a  
fail task to abort unless it's been set. That's how I've done similar  
things in the past.

---

<div class="post-metadata">

**Author:** ![Mark\_Phillips1](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@Mark\_Phillips1](https://forum.ansible.com/u/Mark_Phillips1)\
**Post date:** [May 13, 2015, 6:49pm UTC](https://forum.ansible.com/t/clone-vms-on-vsphere/18220/3 "2015-05-13T18:49:06Z")

</div>

Not sure if you’ve seen this blog post then, but you might find it helpful…

[http://www.ansible.com/blog/managing-vmware-vsphere-guests-with-ansible-tower](http://www.ansible.com/blog/managing-vmware-vsphere-guests-with-ansible-tower)

Cheers!

–Mark
