Executing various commands over a list

Hi All,

I won’t say “include + with_items” :wink: but I am looking for a way to run a bunch of commands, sequentially, over a list. For example:

paths:

  • [ [‘foo:/path/to/dir1’, ‘/dir1’] ]
  • [ [‘foo:/path/to/dir2’, ‘/dir2’] ]
  • etc…

In the playbook, I want to do a set of tasks over these paths… i.e:

  • name: create a temporary mount path
    local_action: command mktemp -d
    register: tempdir
  • name: mount directory
    local_action: shell mount dirname {{ item.0 }} {{ tempdir.stdout }}
    <do stuff with {{ item.1 }} and tempdir.stdout>
  • name: umount and delete temporary dir
    local_action: shell umount {{ tempdir.stdout }} && rm -rf {{ tempdir.stdout }}

Any suggestions on how this can this be achieved?

Thanks.
GS

Look up “with_nested” and “with_together” in the documentation for how to do nested loops.