Hello Ansible Devel
I have developed a module for copying files locally on the host,
while respecting the Ansible --check option and reporting on
changes.
I would be glad to submit it to Ansible extras modules if it's
appropriate. I've included a draft version as a gist below.
Before submitting I would resolve some of the items on the
"improvements" list.
https://gist.github.com/alex-deref/dc66a0ca7e1904c30508
My motivation for this module is to support an Ansible playbook
for custom software installation that I'm developing.
Alex
wouldn't using copy with -local connection work the same?
wouldn't using copy with -local connection work the same?
I'm using it in amongst remote operations covering several remote
hosts. If I understand local connection correctly, that would
mean installing Ansible on each host and transferring a playbook
to execute. To me it seems more reasonable to execute the copy as
a specific module remotely.
Additionally, I'm not sure exactly how copy works in local
connection mode but looking at the code it seems that it might
copy all files once prior to doing the compare which would be
inefficient in the case that nothing needs to be done.
Alex
ah, misunderstood what you mean by local, there is a feature request
for adding this feature to the existing copy module
also it was just pointed out to me, the syncronize module already does
what you ask.
ah, misunderstood what you mean by local, there is a feature request for
> adding this feature to the existing copy module
Yes, choosing a clear name is hard.
Are these the feature requests you were referring to?
https://github.com/ansible/ansible/issues/9982
https://github.com/ansible/ansible-modules-core/issues/365
Would this be welcomed by the Ansible community? I see there are
no comments on the request.
Would it be better provided as separate modules or just options
on the existing copy module?
Also, looking at the synchronize module, the documentation
suggests that it works local->remote or vice-versa, so has the
same problems for me as the copy module that it would need to be
run as a separate ansible on the remote host.
Alex
Did you try this?:
# Synchronization of src on delegate host to dest on the current inventory host.
# If delegate_to is set to the current inventory host, this can be used to syncronize
# two directories on that host.
Hi Timothy,
Thanks for the suggestion. I have given this a try. (After
dealing with an rsync/SSH authentication issue - I've submitted a
pull request.) I confirm that it does the trick and conveniently
doesn't require authentication.
However, it doesn't support the additional selinux or similar
features of the copy module.
I'd like to come back to my question, would a module which copies
files locally on the remote host be welcome? It could support the
SELinux settings and similar.
Here's another user with a similar request from just a few days
ago:
https://github.com/ansible/ansible-modules-core/pull/1894
Alex
I'd like to come back to my question, would a module which copies files
> locally on the remote host be welcome? It could support the SELinux
> settings and similar.
I've updated my code to support the standard file attributes
(mode, owner, group, SELinux), by using the existing module
functions.
https://gist.github.com/alex-deref/dc66a0ca7e1904c30508
Alex