Ansible - choose the most recently updated side and synchronize the local and remote directories?

157 Views Asked by At

I have several workstations with a similar setup (home computer, workstation at the office) and also a server that is used as a remote storage. I'm trying to make Ansible to backup and synchronize several application profile directories (Intellij Idea profile dir, my desktop environment profile dir, some applications unpacked from tar.gz distributions and so on) between these devices. I never use all devices at the same time.

The logic for every dir should be:

  • check local directory modification timestamp
  • check modification timestamp of a directory on the remote server
  • if local copy is older, overwrite it with contents of a directory on the remote server. Otherwise, backup contents of local directory to a remote directory (effectively overwriting it).

I'm going to use Ansible with synchronize module. But implementing the logic above using when for every folder in my (rather long) list sounds like inventing a bycicle to me. It should be a better way to accomplish that.

Seems like a common task, maybe there is a third-party Ansible role/plugin that does that? Or maybe a separate application that may be called using command?

1

There are 1 best solutions below

0
On BEST ANSWER

Ansible is obviously not the appropriate tool for this.

Why don't you use an online storage service with folder sync capabilities, like Dropbox?