- name: My playbook
vars:
dest_path: /home/ubuntu/some_dir/some_file.txt
tasks:
- name: Make sure destination dir exists
file:
path: "\{\{ dest_path | dirname }}"
state: directory
# now this task is always save to run no matter how dest_path get's changed arround
- name: Add file or template to remote instance
template:
src: foo.txt.j2
dest: "\{\{ dest_path }}"
- name: SBT repo configuration
copy:
src: files/.sbt/ # Copying the file `./files/.sbt/repositories`
dest: $HOME/.sbt/ # Works irrespective of whether the directory exists or not