# synchronize links

**URL:** <https://forum.ansible.com/t/synchronize-links/33840>\
**Category:** Ansible Developer\
**Created:** [September 17, 2020, 10:54am UTC](https://forum.ansible.com/t/synchronize-links/33840 "2020-09-17T10:54:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [September 17, 2020, 10:54am UTC](https://forum.ansible.com/t/synchronize-links/33840/1 "2020-09-17T10:54:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 18, 2020, 7:41am UTC](https://forum.ansible.com/t/synchronize-links/33840/2 "2020-09-18T07:41:56Z")

</div>

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](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:

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

Or in longer form:

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

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

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Gerrit\_Kuehn](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Gerrit\_Kuehn](https://forum.ansible.com/u/Gerrit_Kuehn)\
**Post date:** [September 22, 2020, 7:25am UTC](https://forum.ansible.com/t/synchronize-links/33840/3 "2020-09-22T07:25:39Z")

</div>

> \> ---  
> \> 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](https://github.com/ansible-collections/ansible.posix/blob/main/plugins/modules/synchronize.py#L99))

Ok, I'll look into that.

> --links, -l  
> &nbsp;&nbsp;&nbsp;&nbsp;When symlinks are encountered, recreate the symlink on the  
> &nbsp;&nbsp;&nbsp;&nbsp;destination.
> 
> &nbsp;&nbsp;--copy-links, -L  
> &nbsp;&nbsp;&nbsp;&nbsp;When symlinks are encountered, the item that they point to (the  
> &nbsp;&nbsp;&nbsp;&nbsp;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  
&nbsp;&nbsp;Gerrit
