I seem to recall seeing somewhere that v1.3 allowed some sort of recursive copying without resorting to a local command of rsync. But I can’t seem to find this again after looking again… Am I missing something or do we still need to use this workaround?
It’s almost always going to be a better/faster option.
What we were talking about was the ‘synchronize’ module, a wrapper around rsync to make the playbooks read a bit cleaner, that was very nice but we didn’t quite get a quirk or two worked out in time to include it.
This weekend I was working on integrating fixes to those quirks from smoothify. I’m not finished to submit a pull request but if you want to give it a try and test it out the branch is here:
Before the copy module supported it, you could do recursive copy, but it required multiple tasks.You could also use ansible pull and have an ‘agent’, which simplifies it enormously.
I know many tools offer recursive copy, but doing it right with permissions, sudo/su and multiple hosts is much harder than most realize. The current copy and syncronize modules go a long way, but don’t handle every possible case (and probably will never do), I haven’t found any tool that does so.
I wanted to keep the src directory the “system of record” if you will…so that if I add / delete files from the ansible server i’m executing the playbook on, it will happen on the destination machine.
I know I could use command: rsync or shell: rsync or whatever, but according to the ansible module page, it seems like synchronize should at least handle this:
3 - name: copy install pagages to server 4 synchronize: src=etc/server1/scripts/ dest=/etc/server1/scripts/
I’m using this with roles, and from the error, it seems like it does not follow the same logic other things do with roles:
msg: rsync: change_dir “/home/brian/Documents/scripts/ansible//etc/server1/scripts” failed: No such file or directory (2)
seems like it doesn’t go into the “files” folder of the role it’s executing from, even though the ansible module speaks to relative paths.
I’ve got it working by specifying the relative path to where i am running the playbook from, but synchronize seems to not follow the concept of “roles” (or it doesn’t reference file from the role directory that you’re in.
If you can share a minimal playbook to reproduce the problem of synchronize not knowing about the ‘files/’ subdirectory of a role, please file a ticket on GitHub and be sure to include the version of Ansible (should be x>=1.4) that you’ve tested this on.
I just wanted to confirm that Ansible 1.4.4 still has this issue (synchronize not treating paths specified for src as relative to the role as I would expect).
Also, since this does keep coming up, I use the synchronize module in order to ensure files I delete on the local side also get removed on the remote side.