I'm using rsync through Ansible's synchronize-module with the following task definition:
synchronize: src='{{ local_app_path }}/.' dest='{{ remote_app_path }}/' perms=no owner=yes rsync_opts=--delete-after
Running this task generates the following command:
rsync --delay-updates -FF --compress --archive --no-perms --rsh 'ssh -S none -o StrictHostKeyChecking=no' --rsync-path="sudo rsync" --delete-after --out-format='<<CHANGED>>%i %n%L' "../src/." "vagrant@192.168.55.55:/var/www/app/"
My directory layout goes like this:
src/
# ...
app/
test/
node_modules/
package.json
provisioning/
# ...
playbook.yml
.rsync-filter
This is my .rsync-filter:
exclude /src/.env
exclude /src/node_modules
Now I am expecting to run my synchronize-task and have the resulting directory-structure on the server look like this (notice the missing node_modules
folder):
app/
test/
package.json
This works. However, once I create a node_modules
folder on the server...
app/
test/
node_modules/
package.json
...and run the sync again, the node_modules
-folder is deleted from the server again (even though I had excluded it in my .rsync-filter):
app/
test/
package.json
I am expecting the node_modules
-folder to be kept on the server, because I have it listed in my .rsync-filter
and am not using the --delete-excluded
option.
How can I prevent my excluded files/directories from being deleted with rsync?
Thanks a lot for your help! :)