synchronize links

23 views
Skip to first unread message

Gerrit Kuehn

unread,
Sep 17, 2020, 6:54:53 AM9/17/20
to ansibl...@googlegroups.com
Hello,

I have a question concerning the handling of symlinks with the
synchronize module:

What exactly is the difference between the "link" and "copy_link"
options, and how are they intended to be used? The docs say

---
copy_links: Copy symlinks as the item that they point to (the referent)
is copied, rather than the symlink.

links: Copy symlinks as symlinks.
---

This looks rather redundant to me (plus I do not really understand what
the "is copied" part for copy_links should mean).

I have a symlink on the source side that I want to see copied as file.
Setting "links" to "no" does not yield the desired behaviour. I
get a symlink on the destination side.
Setting "copy_links" to "yes" does the trick (but I'd rather expect it
to do the opposite, i.e., COPY the LINK ?!).

This is probably all working as designed, but I can't say I
understand...


cu
Gerrit

Felix Fontein

unread,
Sep 18, 2020, 3:42:06 AM9/18/20
to ansibl...@googlegroups.com
Hi,

> I have a question concerning the handling of symlinks with the
> synchronize module:
>
> What exactly is the difference between the "link" and "copy_link"
> options, and how are they intended to be used? The docs say
>
> ---
> copy_links: Copy symlinks as the item that they point to (the
> referent) is copied, rather than the symlink.
>
> links: Copy symlinks as symlinks.
> ---
>
> This looks rather redundant to me (plus I do not really understand
> what the "is copied" part for copy_links should mean).

the formulation is a bit broken. The "is copied" shouldn't be there.

Feel free to create a PR to remove that part. (The line in question is
here:
https://github.com/ansible-collections/ansible.posix/blob/main/plugins/modules/synchronize.py#L99)

The naming of these two options comes from rsync, BTW. It's man page
says:

--links, -l copy symlinks as symlinks
--copy-links, -L transform symlink into referent file/dir

Or in longer form:

--links, -l
When symlinks are encountered, recreate the symlink on the
destination.

--copy-links, -L
When symlinks are encountered, the item that they point to (the
referent) is copied, rather than the symlink. [...]

Cheers,
Felix


Gerrit Kuehn

unread,
Sep 22, 2020, 3:25:47 AM9/22/20
to ansibl...@googlegroups.com, Felix Fontein

On Fri, 18 Sep 2020 09:41:56 +0200
"'Felix Fontein' via Ansible Development"
<ansibl...@googlegroups.com> wrote:

> > ---
> > copy_links: Copy symlinks as the item that they point to (the
> > referent) is copied, rather than the symlink.
> >
> > links: Copy symlinks as symlinks.
> > ---
> >
> > This looks rather redundant to me (plus I do not really understand
> > what the "is copied" part for copy_links should mean).

> the formulation is a bit broken. The "is copied" shouldn't be there.
> Feel free to create a PR to remove that part. (The line in question is
> here:
> https://github.com/ansible-collections/ansible.posix/blob/main/plugins/modules/synchronize.py#L99)

Ok, I'll look into that.

> --links, -l
> When symlinks are encountered, recreate the symlink on the
> destination.
>
> --copy-links, -L
> When symlinks are encountered, the item that they point to (the
> referent) is copied, rather than the symlink. [...]

I still don't understand why both exist, they appear to be mutually
exclusive.
Or is --links intended to copy links, and --copy-links to copy files,
i.e., they are designed to achieve the opposite of each other? In that
case, I do not understand why ansible offers to turn off or on both of
them independently. That might also explain why setting "links: no" in
ansible does not change the behaviour as expected (because the
underlying rsync option is just removed, but that does not force any
other behaviour).


cu
Gerrit
Reply all
Reply to author
Forward
0 new messages