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

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?

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

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?

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).