I'm trying to create a reusable role that does a synchronize where I pass in the src, dest and an exclude parameters.
I'd like to split that exclude parameter into multiple --exclude= parameters if it's defined.
So, effectively what would be running is:
With exclude undefined:
- name: Copy extracted files to remote
synchronize:
src: "{{ src }}"
dest: "{{ dest }}"
rsync_opts:
- "--no-motd"
With exclude=logs,conf:
- name: Copy extracted files to remote
synchronize:
src: "{{ src }}"
dest: "{{ dest }}"
rsync_opts:
- "--no-motd"
- "--exclude=logs"
- "--exclude=conf"
I figure I need to split the variable, but I'm not sure how to add the --exclude= to each one, whilst not adding any if there's nothing passed.