# create multiple directories (one-by-one slow)?

**URL:** <https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866>\
**Category:** Ansible Project\
**Created:** [March 29, 2015, 5:44am UTC](https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866 "2015-03-29T05:44:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan5](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@Dan5](https://forum.ansible.com/u/Dan5)\
**Post date:** [March 29, 2015, 5:44am UTC](https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866/1 "2015-03-29T05:44:01Z")

</div>

The following works, but is pretty slow (much slower than a mkdir – it creates directories one-by-one, with a delay before each sub-task)

- name: create directories  
file: dest=/volumes/{{item}} state=directory  
with\_items: [usbdisk, nfs, smb]

Is there a faster way?

---

<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:** [March 29, 2015, 2:49pm UTC](https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866/2 "2015-03-29T14:49:26Z")

</div>

not using the file module, you can switch to command/shell: mkdir  
/volumes/{usbdisk, nfs, smb}

---

<div class="post-metadata">

**Author:** ![Dan5](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@Dan5](https://forum.ansible.com/u/Dan5)\
**Post date:** [March 29, 2015, 3:04pm UTC](https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866/3 "2015-03-29T15:04:42Z")

</div>

not using the file module, you can switch to command/shell: mkdir

> /volumes/{usbdisk, nfs, smb}

Thanks – of course, I could translate large parts of the playbook to shell script, after all.

I wonder if the slowness of item-by-item is normal? What’s going on behind the scenes – a new ssh connection for each with\_item?

---

<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:** [March 29, 2015, 3:17pm UTC](https://forum.ansible.com/t/create-multiple-directories-one-by-one-slow/17866/4 "2015-03-29T15:17:51Z")

</div>

Depends, if using control/persist master, no, but you always copy the  
file module and its arguments every time and execute every time. I  
have it on my list to optimize it except cases that require it  
(delegate\_to per item).
