I have a synchronisation task in ansible:
---
- name: Copy over code - lib
synchronize:
src: ../lib/some/parent/directories/
dest: ~/project/lib/some/parent/directories/
This fails as the destination lacks ~/project/lib/some/parent/
but succeeds otherwise. I produced the following work around:
---
- set_fact:
directory_lib_dest: ~/project/lib/some/parent/directories/
- name: Create directories
file: path={{ item }} state=directory
with_items:
- "{{ directory_lib_dest }}"
- name: Copy over code - lib
synchronize:
src: ../lib/some/parent/directories/
dest: "{{ directory_lib_dest }}"
Is there a better solution that can be done using soley the ansible synchronize module and or avoids me using set_fact
whilst keeping it DRY and the variable declared in the same role .yml that is consuming it?