4

Recursive Copy In Ansible 1.5 And --diff

 2 years ago
source link: https://blog.jakubholy.net/2014/03/05/recursive-copy-in-ansible-1-5-and-diff/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Recursive Copy In Ansible 1.5 And --diff

March 5, 2014
Ansible 1.5 has partial support for recursive copy of files:
  • the synchronize module, using rsync
    • cons: does not support group=, owner=
    • -C and --diff - it does not print diff of the files changed; when running ansible with -v, it will print output of rsync's --itemize-changes, i.e., for each changed file/dir, something like "<f.st...... conf/httpd.conf\n" (< = file uploaded, s = size changed, t = timestamp changed, . = this attribute has not been changed)
  • the copy module
    • -C --diff - it only reports "changed" without naming the changed files or showing diffs (unless there is only one changed file)
  • the local_action module, used to run rsync manually (essentially the same as synchronize but more control)
  • So the only way to do a kind of recursive copy with working diff is to use copy with with_fileglob for each directory and subdirectory :-(
To check differences (without diff) manually:
rsync -e ssh -vrnc --itemize-changes source/dir myuser@myserver:/opt/dest/


where v= verbose, r = recursive, n = dry-run, c = check based on checksum, not timestamp+size; a typical output for a changed file is <fcsT...... httpd.conf (< = to be uploaded, f = it is a file, c = checksum differ, s = size differ, T = timestamp would be updated).
Tags: DevOps

Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.

Allow me to write to you!

Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.

Copyright © 2022 Jakub Holý
Powered by Cryogen
Theme by KingMob

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK