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' }
Solution 3:
If both source and destination link are named same then that should be even simpler:
- file:
src: /drupal/drush/{{ item }}.aliases.drushrc.php
dest: /home/vagrant/.drush/{{ item }}.aliases.drushrc.php
state: link
with_items:
- new
- vmdev