Creating a symlink with ansible and a list of variables

Solution 1:

Your indentation is wrong, with_items should be on the same level as file. This is what you want:

file:
  src: "/drupal/drush/{{ item.path }}.aliases.drushrc.php"
  dest: "/home/vagrant/.drush/{{ item.dest }}.aliases.drushrc.php"
  state: link
with_items:
  - { path: 'new', dest: 'new' }
  - { path: 'vmdev', dest: 'vmdev' }

Solution 2:

I believe your syntax is wrong. Try this:

file: >
  src=/drupal/drush/{{ item.path }}.aliases.drushrc.php
  dest=/home/vagrant/.drush/{{ item.dest }}.aliases.drushrc.php
  state=link
with_items:
  - { path: 'new', dest: 'new' }
  - { path: 'vmdev', dest: 'vmdev' }