git checkout and remote rsync

72 views
Skip to first unread message

Quentin Stafford-Fraser

unread,
Aug 6, 2014, 1:27:16 PM8/6/14
to ansible...@googlegroups.com
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


   

Michael DeHaan

unread,
Aug 7, 2014, 5:17:45 PM8/7/14
to ansible...@googlegroups.com
I'm not entirely following this, but have you read the docs for the synchronize module yet?  This wraps rsync and makes it easier than composing the rsync CLI command.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7cab1c94-55e4-4522-866e-546934beede7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages