# copy module with hard link destination

**URL:** <https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693>\
**Category:** Ansible Project\
**Created:** [November 4, 2014, 10:04pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693 "2014-11-04T22:04:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_McGowan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Sean\_McGowan](https://forum.ansible.com/u/Sean_McGowan)\
**Post date:** [November 4, 2014, 10:04pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/1 "2014-11-04T22:04:14Z")

</div>

Background: I am using Ansible 1.5 on RedHat. Apparently system-config-network creates a hard link to /etc/hosts and /etc/resolve.conf. I want to be able to copy the correct hosts file in place if is not there, whether or not the file links is \> 1.

What happens: If the source file is already the same as the destination, I get FAILED with a message “absolute paths are required”.

I can find this message in the code of the file module, not the copy module. Also, if the source file is different, the copy works fine. I am assuming that it gets to the file module somehow after the atomic copy call in the copy module.

Anyhow, can someone please tell me if this should be expected and/or if there is a good work around?

Below is an example… Thanks in advance!

### /etc/hosts has \> 1 links

[root@padishah1 ansible]# ls -l /etc/hosts  
-rw-r–r–. 2 root root 13888 May 16 17:21 /etc/hosts  
[root@padishah1 ansible]# find /etc -xdev -samefile /etc/hosts  
/etc/sysconfig/networking/profiles/default/hosts  
/etc/hosts

### hosts.bkp = hosts && hosts.different != hosts

[root@padishah1 ansible]# md5sum /etc/hosts /etc/hosts.{bkp,different}  
0f7cc9afcb0f17a9864b45391027a6ad /etc/hosts  
0f7cc9afcb0f17a9864b45391027a6ad /etc/hosts.bkp  
9c5799def96f6f2e7309a3914075589b /etc/hosts.different

### Trying to use the copy module with an identical file fails

[root@padishah1 ansible]# ansible all -i \<(echo -e “localhost ansible\_connection=local”) -m copy -a “src=/etc/hosts.bkp dest=/etc/hosts mode=0644 owner=root group=root” --check  
localhost | FAILED \>\> {  
“failed”: true,  
“md5sum”: “0f7cc9afcb0f17a9864b45391027a6ad”,  
“msg”: “absolute paths are required”  
}

### Trying to copy with a new file is sucessful

[root@padishah1 ansible]# ansible all -i \<(echo -e “localhost ansible\_connection=local”) -m copy -a “src=/etc/hosts.different dest=/etc/hosts mode=0644 owner=root group=root” --check  
— before: /etc/hosts  
+++ after: /etc/hosts.different  
—diff redacted—

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 5, 2014, 2:20pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/2 "2014-11-05T14:20:00Z")

</div>

Can you please check and see if you have a problem on Ansible 1.7.2?

We can’t support older versions on this list.

---

<div class="post-metadata">

**Author:** ![Sean\_McGowan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Sean\_McGowan](https://forum.ansible.com/u/Sean_McGowan)\
**Post date:** [November 5, 2014, 9:53pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/3 "2014-11-05T21:53:57Z")

</div>

yes… 1.7.2 is installed now and the result is the same. also, as an interesting aside, I apparently can no longer use bash FIFOs as an inventory file like i did in the previous example.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 7, 2014, 2:13pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/4 "2014-11-07T14:13:29Z")

</div>

Assuming you mean the (\>$) whichever weird syntax, using fifo’s as an inventory file was never really an intended thing.

Please file a bug on the hardlink issue so we can investigate.

Thanks!

---

<div class="post-metadata">

**Author:** ![Sean\_McGowan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Sean\_McGowan](https://forum.ansible.com/u/Sean_McGowan)\
**Post date:** [November 11, 2014, 8:26pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/5 "2014-11-11T20:26:22Z")

</div>

issue #302 - ansible-modules-core

thanks!

and i never expect fifo’s to work, but it is a nice shortcut when testing. 🙂

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [April 19, 2016, 11:53pm UTC](https://forum.ansible.com/t/copy-module-with-hard-link-destination/16693/6 "2016-04-19T23:53:02Z")

</div>

For those who find this same issue in the future, the error will still appear unless you add  
state: file

to the copy module, as documented in here:

[https://github.com/ansible/ansible-modules-core/issues/468](https://github.com/ansible/ansible-modules-core/issues/468)
