I am currently migrating some data between servers and need to make sure I'm copying some data directories while still preserving mappings between old hosts and new hosts. I'm looking at using ansible to do this due to the sheer number of hosts that need files copied.
Example Ansible hosts file:
[source_hosts] olddb1 olddb2 olddb3 [destination_hosts] newdb1 newdb2 newdb3
I would like to copy files between servers like so:
olddbX:/var/opt/<unique dir with db in name>/data --> newdbX:/var/opt/<unique dir with db in name>/data
I've seen many examples of using ansible.posix.synchronize to perform an rsync between two servers, but not between groups of servers with directory names that are slightly variable. In addition I need to ensure that a particular data directory doesn't end up on the wrong host. (i.e. I need olddb1's data to end up on newdb1, and so on...)
- How can I use ansible to synchronize directories between groups of servers?
- How do I handle the directory names not being static on either end?