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

465 views
Skip to first unread message

Dan

unread,
Mar 29, 2015, 1:44:01 AM3/29/15
to ansible...@googlegroups.com
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?

Brian Coca

unread,
Mar 29, 2015, 10:49:28 AM3/29/15
to ansible...@googlegroups.com
not using the file module, you can switch to command/shell: mkdir
/volumes/{usbdisk, nfs, smb}

--
Brian Coca

Dan

unread,
Mar 29, 2015, 11:04:42 AM3/29/15
to ansible...@googlegroups.com
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?

Brian Coca

unread,
Mar 29, 2015, 11:17:57 AM3/29/15
to ansible...@googlegroups.com
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).
Reply all
Reply to author
Forward
0 new messages