Fix Synchronize Not Sourcing Multiple Paths #519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
rsync supports sourcing files from multiple paths simply by specifying multiple paths on the command line. When the paths are folders, the same files in subsequent paths will take precedence over those in previous paths. This is often used to "merge" multiple local folders onto a remote.
For example, if this is the folder structure on the local machine and we are copying to
/tmp/dest
on the remote machineThe result would be
The syntax to do this in ansible is now as follows:
My primary use case for this is having a set of files stored in
host_vars
,group_vars
, andall
which should be copied over to the remote with files fromhost_vars
supersedinggroup_vars
andgroup_vars
superseding all.ISSUE TYPE
COMPONENT NAME
synchronize
ADDITIONAL INFORMATION
This does not replace specifying a singular path with a string, that still works and thus backwards compatibility is preserved.
The only change this has for existing codebases on end users is in the -vvv debug output and in the invocation args of the variable returned by
register:
. Specificallyvar.invocation.module_args.src
on synchronize tasks will return a list with 1 entry being the path instead of just the entry, which is unlikely to cause any breakage. If this change in output is unacceptable though, I can spend the effort to modify the modules to use strings and splitting to prevent this.