# Parallel VM Creations

**URL:** <https://forum.ansible.com/t/parallel-vm-creations/23285>\
**Category:** Ansible Project\
**Created:** [December 19, 2016, 3:18pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285 "2016-12-19T15:18:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [December 19, 2016, 3:18pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/1 "2016-12-19T15:18:28Z")

</div>

Is it possible to create multiple VMs in parallel? As of now, it’s one VM after another. I use the vmware\_guest module for creating VMs in vCenter Server.

I tried specifying _strategy: free_ but that is not helping.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 20, 2016, 3:20pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/2 "2016-12-20T15:20:47Z")

</div>

if the source of data of your VMs is with\_, it will be serial, if you use inventory and hosts: it will be parallel.

---

<div class="post-metadata">

**Author:** ![Mark\_Phillips](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mark\_Phillips](https://forum.ansible.com/u/Mark_Phillips)\
**Post date:** [December 20, 2016, 7:49pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/3 "2016-12-20T19:49:08Z")

</div>

Funnily enough I had this conversation with somebody on the Twitters a while back. I suggested ‘getting clever’ with inventory (as Brian alludes to too, actually).

Here’s an example …

[https://gist.github.com/phips/1e895096ca70c85ad3c870b38d6677eb](https://gist.github.com/phips/1e895096ca70c85ad3c870b38d6677eb)

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 20, 2016, 7:52pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/4 "2016-12-20T19:52:49Z")

</div>

I was going for even simpler:

# inventory

[vm\_group]

host[1-50] ansible\_connection=local

# play

- hosts: vm\_group  
gather\_facts: false  
tasks:
- create\_vm: name={{inventory\_hostname} …  
delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![Mark\_Phillips](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mark\_Phillips](https://forum.ansible.com/u/Mark_Phillips)\
**Post date:** [December 20, 2016, 7:55pm UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/5 "2016-12-20T19:55:19Z")

</div>

> I was going for even simpler:

Dude, you rock!

---

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [December 21, 2016, 11:38am UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/6 "2016-12-21T11:38:59Z")

</div>

Thank you very much, Brian and Mark. I have been using the with\_items approach and providing the VM names from a static file. Since we use Ansible Tower, these files are fetched from a git repository. We also use the roles way of doing things and being relatively new to Ansible, I am little confused about how to go ahead here.

I believe in your cases, you define the hostnames in the hosts file saved inside the Ansible Server or a common location. I was trying to figure out how do I achieve the same thing in my case where the hostnames are in the git repository i.e., how do I specify that in the ansible.cfg file?

Can you suggest the best approach here - saving the hostnames inside the Ansible server Vs. fetching that from a Git repository during the job run?

In my case

---

<div class="post-metadata">

**Author:** ![nikjain](https://avatars.discourse-cdn.com/v4/letter/n/cdc98d/32.png) [@nikjain](https://forum.ansible.com/u/nikjain)\
**Post date:** [December 22, 2016, 7:14am UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/7 "2016-12-22T07:14:05Z")

</div>

There are couple of options here.

If its a host ini file, which is a static file and is not managed by any version control, you can use tower-manage to import the inventory to tower  
[http://docs.ansible.com/ansible-tower/latest/html/administration/tower-manage.html](http://docs.ansible.com/ansible-tower/latest/html/administration/tower-manage.html)

There is also ability to add custom inventory scripts as dynamic inventory sources through the Tower UI. You’ll need to create a custom script that pulls the inventory data as json.

[http://docs.ansible.com/ansible-tower/latest/html/administration/custom\_inventory\_script.html#custom-inventory-scripts](http://docs.ansible.com/ansible-tower/latest/html/administration/custom_inventory_script.html#custom-inventory-scripts)

[http://docs.ansible.com/ansible/developing\_inventory.html#developing-dynamic-inventory-sources](http://docs.ansible.com/ansible/developing_inventory.html#developing-dynamic-inventory-sources)

Let me know if this helps.

Thanks,  
Nikhil

---

<div class="post-metadata">

**Author:** ![Chethan\_S](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chethan\_S](https://forum.ansible.com/u/Chethan_S)\
**Post date:** [December 23, 2016, 3:55am UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/8 "2016-12-23T03:55:21Z")

</div>

Thanks, Nikhil. The tower-manage inventory import did the trick.

---

<div class="post-metadata">

**Author:** ![Marlon\_Guao](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Marlon\_Guao](https://forum.ansible.com/u/Marlon_Guao)\
**Post date:** [November 29, 2018, 10:50am UTC](https://forum.ansible.com/t/parallel-vm-creations/23285/9 "2018-11-29T10:50:04Z")

</div>

I find it weird, using this approach that… intermittently, network will not be configured on your first entry(VM) in your inventory.
