Hi there -
A common deployment model I’m using is to checkout a git repo on the target machine and then copy the subdirectory(s) I actually want into position (e.g. under /var/www somewhere) using a remote rsync command.
There may be a better way to do this, but here’s how I run rsync so that it shows up correctly in the ‘changed’ statistics, just in case it’s useful for others.
- name: copy repo to live directory
command: rsync -rlpEtv -i --delete
–out-format=‘[changed] %f’
{{repo_root}}/my_key_subdirectory/
{{app_root_dir}}/
register: rsync_result
changed_when: “'[changed] ’ in rsync_result.stdout”
rsync tends to output various statistics even if nothing needs to be copied, so I tell it to use an easily-recognisable output format, where it will print:
[changed] filename1
etc in the output for any files affected. Then I just look for instances of ‘[changed]’ in stdout.
Suggestions for more elegant ways to get a subset of a git archive efficiently are most welcome!
Quentin